5

在我的CakePHP應用程序中, 通過使用cake.bat我創建了POT文件並使用PoEdit創建了PO文件。 所以通過編寫__('myword')我可以在我的應用程序中成功地看到本地化的單詞。在CakePHP中本地化時間AgoInWords

但現在我需要本地化「timeAgoInWords」。 當我運行蛋糕國際化提取物,劇本沒有得到_dn()單詞CakeTime http://api20.cakephp.org/view_source/cake-time#line-522

所以我創建了一個dummy.ctp文件,並從cake-複製粘貼內容時間文件到虛擬文件。 我再次運行Cake腳本和POEdit。它創建的實例如下圖所示,進入文件應用程序/地點/ 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" 

在core.php中我已經設置默認的語言土耳其:

Configure::write('Config.language', 'tur'); 

但當我檢查我的申請時,timeAgoInWords的英文結果。

我怎樣才能解決這個

+0

相關:http://stackoverflow.com/questions/7954199/trouble-with-internationalization-on-cakephp-2-0?rq = 1 http://stackoverflow.com/questions/15722716/cakephp-automating-i18n-extract-shell-process-from-batch-文件 – trante

回答

7

蛋糕的消息被提取到一個不同的域,在這種情況下,cake域。這意味着蛋糕消息不會被提取到您的default.pot文件中,但會進入cake.pot文件。

奇怪的是,cake.pot似乎沒有包含在下載中,i18n shell也沒有允許你在提取過程中傳遞一個參數來包含蛋糕核心。然而,它仍然是很容易做到(我的意見與#開始):

$:/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] > 

現在等待提取完成,享受翻譯的疼痛;)