当前位置: 首页>>代码示例>>PHP>>正文


PHP locale函数代码示例

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


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


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