我正在努力让CakePHP的i18n component起作用。我使用i18n控制台任务将我的字符串提取到app/Locale/default.pot
。然后我将其复制到app/Locale/eng/LC_MESSAGES/default.po
和app/Locale/fra/LC_MESSAGES/default.po
,确保更改扩展名。我使用程序Virtaal(类似于Poedit)来翻译一些字符串。
在我的app / Config / core.php中,如果我将其更改为Configure::write('Config.language', 'eng');
,我将默认语言设置为英语Configure::write('Config.language', 'fra');
我希望看到新翻译的字符串,但没有任何改变。我尝试在会话中设置Config.language键,但它没有做任何事情。打印出配置值和会话值我可以看到它们已被设置。
我在这里遗漏了什么吗?还有我在CakePHP中读到的关于i18n的许多不同帖子我已经看到与fre
交替使用的键fra
是否存在差异?
答案 0 :(得分:1)
在http://book.cakephp.org/1.3/en/The-Manual/Common-Tasks-With-CakePHP/Internationalization-Localization.html之后,法语应为fre
。
// locale path
/app/locale/fre/LC_MESSAGES/default.po (French)
// To change or set the language for your application, all you need to do is the following:
Configure::write('Config.language', 'fre');
// To set the language for the current user, store the setting in the Session object, like this:
$this->Session->write('Config.language', 'fre');
除此之外: 在我们的cakePHP应用程序中,我必须在更改文件后重新启动apache webserver以获取新的字符串,因为缓存。也许你必须这样做,但我不太确定,因为我们通过POEdit设置从.po生成.mo文件。我不认为你被迫这样做,因为炊具没有说明任何事情(或者我现在没有发现它:D)。
编辑:
看起来蛋糕正在使用bibliographic
代码用于法语,而terminology
代表德语。这非常令人困惑:/:http://www.loc.gov/standards/iso639-2/php/code_list.php