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


PHP I18n::defaultLocale方法代码示例

本文整理汇总了PHP中Cake\I18n\I18n::defaultLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP I18n::defaultLocale方法的具体用法?PHP I18n::defaultLocale怎么用?PHP I18n::defaultLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\I18n\I18n的用法示例。


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

示例1: __construct

 /**
  * Constructor
  *
  * @param \Cake\ORM\Table $table The table this behavior is attached to.
  * @param array $config The config for this behavior.
  */
 public function __construct(Table $table, array $config = [])
 {
     $config += ['defaultLocale' => I18n::defaultLocale(), 'referenceName' => $this->_referenceName($table)];
     if (isset($config['tableLocator'])) {
         $this->_tableLocator = $config['tableLocator'];
     }
     parent::__construct($table, $config);
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:14,代码来源:TranslateBehavior.php

示例2: edit

 /**
  * Edit a category.
  *
  * @return \Cake\Network\Response|void
  */
 public function edit()
 {
     $this->loadModel('BlogCategories');
     $this->BlogCategories->locale(I18n::defaultLocale());
     $category = $this->BlogCategories->find('slug', ['slug' => $this->request->slug, 'slugField' => 'BlogCategories.slug'])->find('translations')->first();
     //Check if the category is found.
     if (empty($category)) {
         $this->Flash->error(__d('admin', 'This category doesn\'t exist or has been deleted.'));
         return $this->redirect(['action' => 'index']);
     }
     if ($this->request->is('put')) {
         $this->BlogCategories->patchEntity($category, $this->request->data());
         $category->setTranslations($this->request->data);
         if ($this->BlogCategories->save($category)) {
             $this->Flash->success(__d('admin', 'This category has been updated successfully !'));
             return $this->redirect(['action' => 'index']);
         }
     }
     $this->set(compact('category'));
 }
开发者ID:edukondaluetg,项目名称:Xeta,代码行数:25,代码来源:CategoriesController.php

示例3: edit

 /**
  * Edit a Group.
  *
  * @return \Cake\Network\Response|void
  */
 public function edit()
 {
     $this->Groups->locale(I18n::defaultLocale());
     $group = $this->Groups->find('translations')->where(['Groups.id' => $this->request->id])->first();
     //Check if the group is found.
     if (empty($group)) {
         $this->Flash->error(__d('admin', 'This group doesn\'t exist or has been deleted.'));
         return $this->redirect(['action' => 'index']);
     }
     if ($this->request->is('put')) {
         $this->Groups->patchEntity($group, $this->request->data());
         $group->setTranslations($this->request->data);
         if ($this->Groups->save($group)) {
             //Event.
             $this->eventManager()->attach(new Statistics());
             $stats = new Event('Model.Groups.update', $this);
             $this->eventManager()->dispatch($stats);
             $this->Flash->success(__d('admin', 'This group has been updated successfully !'));
             return $this->redirect(['action' => 'index']);
         }
     }
     $this->set(compact('group'));
 }
开发者ID:Xety,项目名称:Xeta,代码行数:28,代码来源:GroupsController.php

示例4: edit

 /**
  * Edit an Article.
  *
  * @return \Cake\Network\Response|void
  */
 public function edit()
 {
     $this->loadModel('BlogArticles');
     $this->BlogArticles->locale(I18n::defaultLocale());
     $article = $this->BlogArticles->find('translations')->where(['BlogArticles.slug' => $this->request->slug])->contain(['BlogAttachments', 'BlogCategories', 'Users' => function ($q) {
         return $q->find('short');
     }])->first();
     //Check if the article is found.
     if (empty($article)) {
         $this->Flash->error(__d('admin', 'This article doesn\'t exist or has been deleted.'));
         return $this->redirect(['action' => 'index']);
     }
     if ($this->request->is('put')) {
         $this->BlogArticles->patchEntity($article, $this->request->data());
         $article->setTranslations($this->request->data);
         if ($this->BlogArticles->save($article)) {
             $this->Flash->success(__d('admin', 'This article has been updated successfully !'));
             return $this->redirect(['action' => 'index']);
         }
     }
     $categories = $this->BlogArticles->BlogCategories->find('list');
     $this->set(compact('article', 'categories'));
 }
开发者ID:edukondaluetg,项目名称:Xeta,代码行数:28,代码来源:ArticlesController.php

示例5: tearDown

 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     I18n::locale(I18n::defaultLocale());
     unset($this->controller);
 }
开发者ID:edukondaluetg,项目名称:Xeta,代码行数:11,代码来源:LanguageTest.php

示例6: __construct

 /**
  * Constructor
  *
  * @param \Cake\ORM\Table $table The table this behavior is attached to.
  * @param array $config The config for this behavior.
  */
 public function __construct(Table $table, array $config = [])
 {
     $config += ['defaultLocale' => I18n::defaultLocale(), 'referenceName' => $this->_referenceName($table)];
     parent::__construct($table, $config);
 }
开发者ID:wepbunny,项目名称:cake2,代码行数:11,代码来源:TranslateBehavior.php

示例7: tearDown

 public function tearDown()
 {
     parent::tearDown();
     I18n::locale(I18n::defaultLocale());
     TableRegistry::clear();
 }
开发者ID:alexunique0519,项目名称:Blog_Cakephp_association,代码行数:6,代码来源:TranslateBehaviorTest.php

示例8: __construct

 /**
  * Constructor
  *
  * @param \Cake\ORM\Table $table The table this behavior is attached to.
  * @param array $config The config for this behavior.
  */
 public function __construct(Table $table, array $config = [])
 {
     $config += ['defaultLocale' => I18n::defaultLocale()];
     parent::__construct($table, $config);
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:11,代码来源:TranslateBehavior.php

示例9: i18nScript

 /**
  * Generate the script tag to initialize CkEditor for textarea.
  *
  * @param array $options The options passed to the function.
  *
  * @return string
  */
 public function i18nScript($options = [])
 {
     $html = '';
     $file = isset($options['file']) ? $options['file'] : 'article';
     $name = isset($options['name']) ? $options['name'] : 'CkEditorBox';
     $i = 0;
     foreach ($this->_locales as $locale => $lang) {
         if ($locale == I18n::defaultLocale()) {
             continue;
         }
         $i++;
         $html .= '
         <script type="text/javascript">
         CKEDITOR.replace(\'' . $name . '-' . $i . '\', {
             customConfig: \'config/' . $file . '.js\'
         });
         </script>';
     }
     return $html;
 }
开发者ID:edukondaluetg,项目名称:Xeta,代码行数:27,代码来源:I18nHelper.php


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