當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。