本文整理汇总了PHP中Translation::forLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Translation::forLocale方法的具体用法?PHP Translation::forLocale怎么用?PHP Translation::forLocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translation
的用法示例。
在下文中一共展示了Translation::forLocale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateLocaleSettings
public function testCreateLocaleSettings()
{
$settings = array('basedOn' => 'no', 'nested' => false);
$result = $this->Translation->createLocale('da', $settings);
$expected = Translation::forLocale('no', $settings);
$this->assertSame($expected, $result);
}
示例2: testCreateNotDefaultLanguage
/**
* testCreateNotDefaultLanguage
*
* If a record is created in a not-default language, it should still store
* in the original field the translated value. While this isn't particularly
* correct - it's better than the original translated field being blank in the
* default language - and therefore in all other langauges.
*
* @return void
*/
public function testCreateNotDefaultLanguage()
{
Configure::write('Config.defaultLanguage', 'en');
Configure::write('Config.language', 'es');
$this->Tag->create();
$this->Tag->save(array('tag' => 'nuevo'));
$expected = array(1 => 'tag1', 'tag2', 'tag3', 'nuevo');
$this->Tag->Behaviors->disable('Translate');
$result = $this->Tag->find('list');
$this->assertSame($expected, $result);
$this->Tag->Behaviors->enable('Translate');
$result = $this->Tag->find('list');
$this->assertSame($expected, $result);
$expected = array('Tag.1.tag' => 'tag1', 'Tag.2.tag' => 'tag2', 'Tag.3.tag' => 'tag3', 'Tag.4.tag' => 'nuevo');
$translations = Translation::forLocale('en', array('domain' => 'data', 'section' => 'Tag', 'nested' => false));
ksort($translations);
$this->assertSame($expected, $translations);
}