1
votes

For my CakePHP 2.3 application, I created pot file and created po files with Poedit. But I have nearly 100 strings and 12 languages. So in every change/add I don't want to recreate pot files and add po files with Poedit.

So I need another solution that fits good to CakePHP.
- Is it possible to use i18n without po files, just using csv files ? (It seems Zend Translate have similar solution)
- Is it possible to use one po file for all of the translations or will it makes performance too bad for this amount of strings ?
- I don't prefer to write translations to database. What would be the better alternative to gettext for small projects ?

Related: CakePHP translations in one or multiple po files and performance

1
By default, CakePHP only supports .po files for localisation, so if you want to use CSV instead, you'll have to implement your own mechanism. Having each locale in a separate file is (IMO) best practice; you'll be able to have separate translators/translation bureaus each translate a language. I don't see any advantage in having all languages in a single file. However, you don't have to re-generate the .pot files with each change? If you keep track of the changes made, you can always just add the 'msgids' to existing .po files?thaJeztah
@thaJeztah You should have posted this as an answer instead of comment so that I could upvote :)ADmad
Also *.mo files should be updated? Because when I updated po file with Notepad++, translations didn't work until I change mo filestrante
@trante Use either .mo or .po not both. (If you have both .mo will take precendence). Cake caches the translations in serialized format anyway so using binary .mo doesn't have much benefit. Just use .po so they are easier to maintain.ADmad
@ADmad using only po files. That's very valuable information for me :))trante

1 Answers

3
votes

By default, CakePHP only supports .po or .mo files for localization, so if you want to use CSV instead, you'll have to implement your own mechanism.

Having each locale in a separate file is (IMO) best practice; you'll be able to have separate translators/translation bureaus for each language. I don't see any advantage in having all languages in a single file. Having all languages in a single file will probably only make things more difficult, because each language will need to have its own unique 'identifier' for each string. Also, having separate files per language makes it easier to compare different languages, for example to check for missing 'msgids'

However, you don't have to re-generate the .pot files with each change. If you keep track of the changes made, you can always just add the new 'msgids' to existing .po files.

As suggested by @Admad, you should not have both .po and .mo (binary) files in your project. If both are present, CakePHP will prefer .mo files.

Personally, I prefer using .po files as they take one less step to create (conversion of .po to binary format) and, because they are binary, are (probably) faster to parse by CakePHP, but this is my preference, it may differ in your situation.