在CakePHP中本地化timeAgoInWords

tra*_*nte 5 localization cakephp internationalization cakephp-2.0 timeago

在我的CakePHP应用程序中,通过使用cake.bat我创建了POT文件并使用PoEdit我创建了PO文件.因此,通过编写__('myword'),我可以成功地在我的应用程序中看到本地化的单词.

但现在我需要本地化"timeAgoInWords".当我运行饼国际化提取物,剧本没有得到_dn()的话在CakeTime http://api20.cakephp.org/view_source/cake-time#line-522

所以我创建了一个dummy.ctp文件和从cake-time文件复制粘贴的内容到虚拟文件.我再次运行蛋糕脚本和POEdit.它创建了如下所示的实例到文件app/Locale/tur/LC_MESSAGES/default.po中

#: View\App\dummy.ctp:30;33
msgid "%d minute"
msgid_plural "%d minutes"
msgstr[0] "%d dakika"
msgstr[1] "%d dakika"
Run Code Online (Sandbox Code Playgroud)

在core.php中,我已经将默认语言设置为土耳其语:

Configure::write('Config.language', 'tur');
Run Code Online (Sandbox Code Playgroud)

但是当我检查我的申请时,timeAgoInWords的结果是英文的.

我怎样才能解决这个问题

dr *_*ter 7

Cake的消息被提取到不同的域中,在本例中为cake域.这意味着蛋糕消息不会被提取到您的default.pot文件中,而是会进入cake.pot文件.

奇怪的是,cake.pot似乎没有包含在下载中,i18n shell也不允许你在提取过程中传递一个包含蛋糕核心的参数.但是,它仍然很容易完成(我的评论以a开头#):

$:/var/www/path/app$ cake i18n extract

# if will ask you here if you want to extract from your app folder
# simply press enter to confirm
What is the path you would like to extract?
[Q]uit [D]one  
[/var/www/path/app/]

# now it will ask you again, in this case enter the cake path
What is the path you would like to extract?
[Q]uit [D]one  
[D] > /var/www/path/lib/Cake

# third time, just press enter
What is the path you would like to extract?
[Q]uit [D]one  
[D] > 

# press enter to accept the app/Locale
What is the path you would like to output?
[Q]uit  
[/var/www/path/app//Locale] > 

# press enter to keep translation domains deparate
Would you like to merge all domains strings into the default.pot file? (y/n) 
[n] > 
Run Code Online (Sandbox Code Playgroud)

现在等待提取完成并享受翻译的痛苦;)