本文整理汇总了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);
}
示例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'));
}
示例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'));
}
示例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'));
}
示例5: tearDown
/**
* tearDown
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
I18n::locale(I18n::defaultLocale());
unset($this->controller);
}
示例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);
}
示例7: tearDown
public function tearDown()
{
parent::tearDown();
I18n::locale(I18n::defaultLocale());
TableRegistry::clear();
}
示例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);
}
示例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;
}