• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP locale函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中locale函数的典型用法代码示例。如果您正苦于以下问题:PHP locale函数的具体用法?PHP locale怎么用?PHP locale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了locale函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: register

 public function register()
 {
     Menu::macro('front', function () {
         return Menu::new()->setActiveFromRequest(locale());
     });
     Menu::macro('main', function () {
         return Menu::front()->addClass('nav__list')->url('/', 'Home');
     });
     Menu::macro('language', function () {
         return Menu::build(locales(), function (Menu $menu, string $locale) {
             return $menu->url($locale, strtoupper($locale));
         })->setActiveFromRequest();
     });
     Menu::macro('articleSiblings', function (Article $article) {
         return $article->siblings->reduce(function (Menu $menu, Article $article) {
             return $menu->url($article->fullUrl, $article->name);
         }, Menu::front());
     });
 }
开发者ID:spatie-custom,项目名称:blender,代码行数:19,代码来源:FrontMenus.php


示例2: translate

 /**
  * Get the translation for the given locale. If it doesn't exist create it.
  *
  * @param null $locale
  * @param bool $withFallback
  *
  * @return \Illuminate\Database\Eloquent\Model|null
  */
 public function translate($locale = null, $withFallback = false)
 {
     if ($this->hasTranslation($locale)) {
         return $this->getTranslation($locale, $withFallback);
     }
     return $this->getTranslationOrNew(is_null($locale) ? locale() : $locale);
 }
开发者ID:vanslambrouckd,项目名称:blender,代码行数:15,代码来源:TranslatableEloquent.php


示例3: __construct

 public function __construct(&$params = null)
 {
     parent::__construct(&$params);
     $conf =& $this->using('conf');
     $lang = $conf->get('core/locale', 'en', 's');
     locale($lang);
 }
开发者ID:laiello,项目名称:xiv,代码行数:7,代码来源:i18n.php


示例4: build

 public static function build(CMSNav &$parent, array &$records, $level = 0)
 {
     // Iterate all items on current level
     foreach ($records as &$record) {
         // If if item is current level parent item TODO: How could it be?
         if ($record->StructureID == $parent->StructureID) {
             continue;
         }
         // If this item is connected with current level parent item
         if ($record->ParentID == $parent->StructureID) {
             // Save pointer to parent item
             $record->parent =& $parent;
             $current =& $record;
             $url_base = '';
             while (isset($current)) {
                 $record->parents[] =& $current;
                 $url_base = trim($current->Url . '/' . $url_base);
                 $record->url_base[$current->StructureID] = $url_base;
                 $record->url_base[$current->StructureID . '_' . locale()] = locale() . '/' . $url_base;
                 $current =& $current->parent;
             }
             $record->level = $level;
             $parent->children['id_' . $record->StructureID] = $record;
             // Go deeper in recursion
             self::build($record, $records, $level + 1);
         }
     }
 }
开发者ID:samsonos,项目名称:cms_api,代码行数:28,代码来源:CMSNav.php


示例5: getContentLocale

 /**
  * Get the locale in which the content in lists of the back module must be rendered.
  *
  * @return string
  */
 public function getContentLocale()
 {
     if (!$this->isValidLocale(app()->getLocale())) {
         return $this->app->config->get('app.locales')[0];
     }
     return locale();
 }
开发者ID:bjrnblm,项目名称:blender,代码行数:12,代码来源:CurrentLocale.php


示例6: getContentLocale

 public static function getContentLocale() : string
 {
     if (!static::isValidLocale(locale())) {
         return config('app.locales')[0];
     }
     return locale();
 }
开发者ID:spatie-custom,项目名称:blender,代码行数:7,代码来源:CurrentLocale.php


示例7: __construct

 public function __construct()
 {
     $CI =& get_instance();
     $CI->load->helper('locale');
     $this->_folder = realpath(APPPATH . '../');
     $this->_jarTranslate = APPPATH . 'modules/traductions/third_party/translate.jar';
     $this->_trads = $this->getDico(locale());
 }
开发者ID:Cevantime,项目名称:site-core-modules,代码行数:8,代码来源:Traductor.php


示例8: getLang

 private function getLang()
 {
     $lang = $this->input->post_get('lang');
     if ($lang) {
         return $lang;
     }
     $this->load->helper('locale');
     return locale();
 }
开发者ID:Cevantime,项目名称:site-core-modules,代码行数:9,代码来源:Save.php


示例9: rewriteEntityLocale

 /**
  * Entity additional fields localization support.
  */
 protected function rewriteEntityLocale()
 {
     // Iterate all generated entity classes
     foreach (get_declared_classes() as $entityClass) {
         if (is_subclass_of($entityClass, '\\samsoncms\\api\\Entity')) {
             // Insert current application locale
             str_replace('@locale', locale(), $entityClass::$_sql_select);
         }
     }
 }
开发者ID:rmolodyko,项目名称:api,代码行数:13,代码来源:CMS.php


示例10: __construct

 /** {@inheritdoc} */
 public function __construct($renderer, $query = null, $pager = null)
 {
     // Call parents
     parent::__construct($renderer, $query, $pager, locale());
     // Call external handlers
     $this->entityHandler(array($this, 'joinTables'));
     $this->baseEntityHandler(array($this, 'parentIdInjection'));
     // Fill default column fields for collection
     $this->fields = array(new Generic('MaterialID', '#', 0, 'id', false), new Generic('Name', t('Наименование', true), 0), new Generic('Url', t('Идентификатор', true), 0), new Navigation(), new Generic('Modyfied', t('Последнее изменение', true), 7, 'modified', false, true), new User(), new Generic('Published', t('Показывать', true), 11, 'publish'), new Control());
 }
开发者ID:samsoncms,项目名称:material,代码行数:11,代码来源:Collection.php


示例11: getFullUrlAttribute

 public function getFullUrlAttribute() : string
 {
     $localeSegment = '';
     if (locales()->count() > 1) {
         $localeSegment = '/' . locale();
     }
     if ($this->technical_name === SpecialArticle::HOME) {
         return $localeSegment;
     }
     $parentUrl = $this->hasParent() ? $this->parent->url . '/' : '';
     return "{$localeSegment}/{$parentUrl}{$this->url}";
 }
开发者ID:spatie-custom,项目名称:blender,代码行数:12,代码来源:Article.php


示例12: translate

 public function translate($lang = null)
 {
     if (!$lang) {
         $lang = locale();
     }
     $this->layout->css('css/traductions/trads.css');
     $this->layout->js('js/homePopup.js');
     $this->load->helper('form');
     $this->traductor->export();
     $fullTrads = $this->traductor->getFull();
     $datas = array('fullTrads' => $fullTrads, 'lang' => $lang);
     $this->layout->view('traductions/index', $datas);
 }
开发者ID:Cevantime,项目名称:site-core-modules,代码行数:13,代码来源:Index.php


示例13: gfscanada_preprocess_search_block_form

function gfscanada_preprocess_search_block_form(&$vars, $hook)
{
    // Modify elements of the search form
    $vars['form']['search_block_form']['#title'] = t('Site Search');
    // Set a default value for text inside the search box field.
    $vars['form']['search_block_form']['#value'] = locale('Enter Keywords');
    // Change the text on the submit button
    $vars['form']['submit']['#value'] = locale('GO');
    // Rebuild the rendered version (search form only, rest remains unchanged)
    unset($vars['form']['search_block_form']['#printed']);
    unset($vars['form']['submit']['#printed']);
    $vars['search']['search_block_form'] = drupal_render($vars['form']['search_block_form']);
    $vars['search']['submit'] = drupal_render($vars['form']['submit']);
    // Collect all form elements to make it easier to print the whole form.
    $vars['search_form'] = implode($vars['search']);
}
开发者ID:davidclarkmoore,项目名称:vintage-enoteca,代码行数:16,代码来源:template.php


示例14: map

 public function map(Router $router)
 {
     Route::group(['namespace' => $this->namespace], function () {
         /*
          * Special routes
          */
         Route::group(['middleware' => 'web'], function () {
             Route::demoAccess('/demo');
             Route::get('coming-soon', function () {
                 return view('temp/index');
             });
         });
         /*
          * Back site
          */
         Route::group(['namespace' => 'Back', 'middleware' => 'web', 'prefix' => 'blender'], function () {
             Auth::routes();
             Route::group(['middleware' => 'auth'], function () {
                 require base_path('routes/back.php');
             });
         });
         /*
          * Frontsite
          */
         Route::group(['namespace' => 'Front'], function () {
             Route::group(['namespace' => 'Api', 'middleware' => 'api', 'prefix' => 'api'], function () {
                 require base_path('routes/frontApi.php');
             });
             Route::group(['middleware' => ['web', 'demoMode', 'rememberLocale']], function () {
                 $multiLingual = count(config('app.locales')) > 1;
                 Route::group($multiLingual ? ['prefix' => locale()] : [], function () {
                     try {
                         Auth::routes();
                         require base_path('routes/front.php');
                     } catch (Exception $exception) {
                         logger()->warning("Front routes weren't included.");
                     }
                 });
                 if ($multiLingual) {
                     Route::get('/', function () {
                         return redirect(locale());
                     });
                 }
             });
         });
     });
 }
开发者ID:spatie-custom,项目名称:blender,代码行数:47,代码来源:RouteServiceProvider.php


示例15: t

function t($string, $args = array(), $langcode = NULL)
{
    global $language;
    static $custom_strings;
    $langcode = isset($langcode) ? $langcode : $language->language;
    // First, check for an array of customized strings. If present, use the array
    // *instead of* database lookups. This is a high performance way to provide a
    // handful of string replacements. See settings.php for examples.
    // Cache the $custom_strings variable to improve performance.
    if (!isset($custom_strings[$langcode])) {
        $custom_strings[$langcode] = variable_get('locale_custom_strings_' . $langcode, array());
    }
    // Custom strings work for English too, even if locale module is disabled.
    if (isset($custom_strings[$langcode][$string])) {
        $string = $custom_strings[$langcode][$string];
    } elseif (function_exists('locale') && $langcode != 'en') {
        $string = locale($string, $langcode);
    }
    if (empty($args)) {
        return $string;
    } else {
        // Transform arguments before inserting them.
        foreach ($args as $key => $value) {
            switch ($key[0]) {
                case '@':
                    // Escaped only.
                    $args[$key] = check_plain($value);
                    break;
                case '%':
                default:
                    // Escaped and placeholder.
                    $args[$key] = theme('placeholder', $value);
                    break;
                case '!':
                    // Pass-through.
            }
        }
        return strtr($string, $args);
    }
}
开发者ID:khaledaSabina,项目名称:php-codeigniter-tips-tricks,代码行数:40,代码来源:drupal_learning.php


示例16: __construct

 /** @inheritdoc */
 public function __construct(RenderInterface $renderer, QueryInterface $query, Record $entity)
 {
     // Get all locales
     $locales = \samson\core\SamsonLocale::get();
     // Set current locale as first value of array
     $localArray = array(locale());
     // Iterate all locales
     foreach ($locales as $local) {
         // Avoid current locale
         if ($local == locale()) {
             continue;
         }
         $localArray[] = $local;
     }
     // Set locales in the new order
     \samson\core\SamsonLocale::$locales = $localArray;
     // TODO This is fix loading SEO module
     // Because seo module used this class, and for checking class_exists function this class have to be exists
     // And we have to call it this but when cms and app will be one single application please remove this line
     new \samsoncms\app\material\form\tab\LocaleTab($renderer, $query, $entity);
     // Fill generic tabs
     $this->tabs = array(new Main($renderer, $query, $entity), new Field($renderer, $query, $entity));
     $this->navigationIDs = dbQuery('structurematerial')->cond('MaterialID', $entity->id)->fields('StructureID');
     // Get all another tabs
     if (sizeof($this->navigationIDs)) {
         $wysiwygFields = dbQuery('field')->cond('Type', 8)->join('structurefield')->cond('structurefield_StructureID', $this->navigationIDs)->exec();
         foreach ($wysiwygFields as $field) {
             $this->tabs[] = new MaterialField($renderer, $query, $entity, $field);
         }
     }
     parent::__construct($renderer, $query, $entity);
     // Fire new event after creating form tabs
     Event::fire('samsoncms.material.form.created', array(&$this, $renderer, $query, $entity));
     // Set old locales
     \samson\core\SamsonLocale::$locales = $locales;
 }
开发者ID:samsoncms,项目名称:material,代码行数:37,代码来源:Form.php


示例17: dispatch

function dispatch($languages)
{
    global $base_path;
    global $request_path, $request_query;
    global $closing_time, $opening_time;
    global $track_visitor, $track_visitor_agent;
    $req = $base_path ? substr(request_uri(), strlen($base_path)) : request_uri();
    if ($track_visitor) {
        track($req, $track_visitor_agent);
    }
    $url = @parse_url($req);
    $path = isset($url['path']) ? trim(urldecode($url['path']), '/') : false;
    $query = isset($url['query']) ? $url['query'] : false;
    $request_query = $query;
    if (empty($path)) {
        $path = false;
    }
    /* site language */
    $p = $path ? explode('/', $path) : false;
    $lang = $p ? $p[0] : false;
    if ($lang && in_array($lang, $languages, true)) {
        array_shift($p);
        $path = implode('/', $p);
    } else {
        require_once 'locale.php';
        $lang = locale();
        if (!$lang or !in_array($lang, $languages, true)) {
            $lang = $languages[0];
        }
    }
    $request_path = $path ? $lang . '/' . $path : $lang;
    $action = $args = $params = false;
    if ($closing_time) {
        $action = 'error/serviceunavailable';
        $args = array($closing_time, $opening_time);
    } else {
        $r = route($path, $lang);
        if (!$r) {
            $action = 'error/notfound';
        } else {
            list($action, $args) = $r;
            if ($query) {
                $params = array();
                foreach (explode('&', $query) as $q) {
                    $p = explode('=', $q);
                    if (count($p) == 2) {
                        list($key, $value) = $p;
                        if ($key) {
                            $params[$key] = urldecode($value);
                        }
                    }
                }
            }
        }
    }
    $arglist = $args ? $params ? array_merge($args, $params) : $args : $params;
    run($action, $lang, $arglist);
}
开发者ID:RazorMarx,项目名称:izend,代码行数:58,代码来源:engine.php


示例18: afterCompress

 /** @see \samson\core\CompressableExternalModule::afterCompress() */
 public function afterCompress(&$obj = null, array &$code = null)
 {
     // Fill additional fields data to material db request data for automatic altering material request
     self::$fields = array();
     $t_name = '_mf';
     // Save original material attributes
     self::$materialAttributes =& Material::$_attributes;
     // Copy original material table attributes
     CMSMaterial::$_attributes = \samson\activerecord\Material::$_attributes;
     CMSMaterial::$_sql_select = \samson\activerecord\Material::$_sql_select;
     CMSMaterial::$_sql_from = \samson\activerecord\Material::$_sql_from;
     CMSMaterial::$_own_group = \samson\activerecord\Material::$_own_group;
     CMSMaterial::$_map = \samson\activerecord\Material::$_map;
     // Perform db query to get all possible material fields
     if (dbQuery('field')->cond('Active', 1)->cond('Name', '', dbRelation::NOT_EQUAL)->exec($this->material_fields)) {
         foreach ($this->material_fields as $db_field) {
             // Add additional field localization condition
             if ($db_field->local == 1) {
                 $equal = '((' . $t_name . '.FieldID = ' . $db_field->id . ')&&(' . $t_name . ".locale = '" . locale() . "'))";
             } else {
                 $equal = '((' . $t_name . '.FieldID = ' . $db_field->id . ')&&(' . $t_name . ".locale is NULL))";
             }
             // Define field value DB column for storing data
             $v_col = 'Value';
             // We must get data from other column for this type of field
             if ($db_field->Type == 7 || $db_field->Type == 3 || $db_field->Type == 10) {
                 $v_col = 'numeric_value';
             } else {
                 if ($db_field->Type == 6) {
                     $v_col = 'key_value';
                 }
             }
             // Save additional field
             self::$fields[$db_field->Name] = "\n" . ' MAX(IF(' . $equal . ',' . $t_name . '.`' . $v_col . '`, NULL)) as `' . $db_field->Name . '`';
             // Set additional object metadata
             CMSMaterial::$_attributes[$db_field->Name] = $db_field->Name;
             CMSMaterial::$_map[$db_field->Name] = dbMySQLConnector::$prefix . 'material.' . $db_field->Name;
         }
     }
     // Set additional object metadata
     CMSMaterial::$_sql_select['this'] = ' STRAIGHT_JOIN ' . Material::$_sql_select['this'];
     if (sizeof(self::$fields)) {
         CMSMaterial::$_sql_select['this'] .= ',' . implode(',', self::$fields);
     }
     CMSMaterial::$_sql_from['this'] .= "\n" . 'LEFT JOIN ' . dbMySQLConnector::$prefix . 'materialfield as ' . $t_name . ' on ' . dbMySQLConnector::$prefix . 'material.MaterialID = ' . $t_name . '.MaterialID';
     CMSMaterial::$_own_group[] = dbMySQLConnector::$prefix . 'material.MaterialID';
 }
开发者ID:samsonos,项目名称:cms_api,代码行数:48,代码来源:CMS.php


示例19: setUp

 /**
  * Installs Atrium instead of Drupal
  * 
  * Generates a random database prefix, runs the install scripts on the
  * prefixed database and enable the specified modules. After installation
  * many caches are flushed and the internal browser is setup so that the
  * page requests will run on the new prefix. A temporary files directory
  * is created with the same name as the database prefix.
  *
  * @param ...
  *   List of modules to enable for the duration of the test.
  */
 protected function setUp()
 {
     global $db_prefix, $user, $language, $profile, $install_locale;
     // $language (Drupal 6).
     // Store necessary current values before switching to prefixed database.
     $this->originalPrefix = $db_prefix;
     $this->originalLanguage = clone $language;
     $clean_url_original = variable_get('clean_url', 0);
     // Must reset locale here, since schema calls t().  (Drupal 6)
     if (module_exists('locale')) {
         $language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');
         locale(NULL, NULL, TRUE);
     }
     // Generate temporary prefixed database to ensure that tests have a clean starting point.
     //    $db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
     $db_prefix = 'simpletest' . mt_rand(1000, 1000000);
     $install_locale = $this->install_locale;
     $profile = $this->install_profile;
     //    include_once DRUPAL_ROOT . '/includes/install.inc';
     include_once './includes/install.inc';
     drupal_install_system();
     //    $this->preloadRegistry();
     // Set up theme system for the maintenance page.
     // Otherwise we have trouble: https://ds.openatrium.com/dsi/node/18426#comment-38118
     // @todo simpletest module patch
     drupal_maintenance_theme();
     // Add the specified modules to the list of modules in the default profile.
     $args = func_get_args();
     //    $modules = array_unique(array_merge(drupal_get_profile_modules('default', 'en'), $args));
     $modules = array_unique(array_merge(drupal_verify_profile($this->install_profile, $this->install_locale), $args));
     //    drupal_install_modules($modules, TRUE);
     drupal_install_modules($modules);
     // Because the schema is static cached, we need to flush
     // it between each run. If we don't, then it will contain
     // stale data for the previous run's database prefix and all
     // calls to it will fail.
     drupal_get_schema(NULL, TRUE);
     if ($this->install_profile == 'openatrium') {
         // Download and import translation if needed
         if ($this->install_locale != 'en') {
             $this->installLanguage($this->install_locale);
         }
         // Install more modules
         $modules = _openatrium_atrium_modules();
         drupal_install_modules($modules);
         // Configure intranet
         // $profile_tasks = $this->install_profile . '_profile_tasks';
         _openatrium_intranet_configure();
         _openatrium_intranet_configure_check();
         variable_set('atrium_install', 1);
         // Clear views cache before rebuilding menu tree. Requires patch
         // [patch_here] to Views, as new modules have been included and
         // default views need to be re-detected.
         module_exists('views') ? views_get_all_views(TRUE) : TRUE;
         menu_rebuild();
     }
     _drupal_flush_css_js();
     $this->refreshVariables();
     $this->checkPermissions(array(), TRUE);
     user_access(NULL, NULL, TRUE);
     // Drupal 6.
     // Log in with a clean $user.
     $this->originalUser = $user;
     //    drupal_save_session(FALSE);
     //    $user = user_load(1);
     session_save_session(FALSE);
     $user = user_load(array('uid' => 1));
     // Restore necessary variables.
     variable_set('install_profile', $this->install_profile);
     variable_set('install_task', 'profile-finished');
     variable_set('clean_url', $clean_url_original);
     variable_set('site_mail', '[email protected]');
     // Use temporary files directory with the same prefix as database.
     $this->originalFileDirectory = file_directory_path();
     variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
     $directory = file_directory_path();
     // Create the files directory.
     file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
     set_time_limit($this->timeLimit);
 }
开发者ID:jamon8888,项目名称:atrium_features,代码行数:92,代码来源:atrium_web_test_case.php


示例20: date

            </div>
          </div>
        </div>
    
        <div id="footer-region" class="region grid-16 clear-block">
          <?php 
print $footer;
?>
          <p class="copyright">&#169; <?php 
echo date('Y');
?>
  <?php 
print locale('GFS Canada Company, Inc. All Rights Reserved.');
?>
</p>
          <?php 
print $footer_bottom;
?>
          <?php 
print locale('<a id="footer_us_homepage_link" href="http://www.gfs.com/" title="Go to GFS US"><img alt="Go to Gordon Food Service (US)." src="/sites/all/themes/gfscanada/images/GFSUSLogoImageChangeAsset.png"></img></a>');
?>
          <br/>
        </div>
      </div>
    </div>

    <?php 
print $closure;
?>
  </body>
</html>
开发者ID:davidclarkmoore,项目名称:vintage-enoteca,代码行数:31,代码来源:page-front.tpl.php



注:本文中的locale函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP localeFN函数代码示例发布时间:2022-05-15
下一篇:
PHP localdatetime2db函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap