问题
In my CakePHP application, By using cake.bat i created POT files and by using PoEdit I created PO files. So by writing __('myword') i can see localized word in my application successfully.
But now I need to localize "timeAgoInWords". When i run cake i18n extract, script didn't get the _dn() words in CakeTime http://api20.cakephp.org/view_source/cake-time#line-522
So i created a dummy.ctp file and copy-pasted contents from cake-time file to dummy file. I run cake script and POEdit again. And it created instances like below, into the file 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"
In core.php i already set default language to Turkish:
Configure::write('Config.language', 'tur');
But when i check my application, results of timeAgoInWords came in English.
How can i fix this
回答1:
Cake's messages are extracted into a different domain, in this case, the cake
domain. This means that cake messages will not be extracted into your default.pot
file, but will go into cake.pot
file.
Curiously, cake.pot doesn't seem to be included in the download, nor does the i18n shell allow you to pass a param to include the cake core during extraction. However, it is still easily done (my comments start with 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] >
Now wait for the extraction to finish and enjoy the pain of translating ;)
来源:https://stackoverflow.com/questions/10402330/localizing-timeagoinwords-in-cakephp