Correct generation of .po files
Permalink 2 users found helpful
Hello
Since I've noticed a lot of missing strings in .po file, I've created a script that automatically extracts the strings to be extracted, either from .php files and from .sql files ('update' mode).
This script also can compile the .po files of all the languages to generate the .mo files ('compile' mode).
The 'update' mode (execute 'php manage-languages.php update') follow these steps:
1) uses xgettext to generate .pot file with xgettext, parsing all the php files (comments for translators should be marked as "// i18n: ...")
2) extracts all the relevant field values from the sql dump files (/concrete/config/install/no_sample_content.sql and /concrete/config/install/sample_content.sql) and generate a second .pot file.
3) with msgcat it merges the two .pot files to create the final language template (saved as /languages/messages.pot)
4) Updates each po file (eventually it creates empty .po files if they are not found) with msgmerge. Please remark that translations no more in use are not discarded: they are just marked as "removed"
The 'compile' mode (execute 'php manage-languages.php compile') simply compiles each .po file to generate the final .mo files.
In the attached archive you can find this script ('/languages/manage-languages.php') among with gettext utilities compiled for win32 ('/languages/.win32/') (for Linux these utilities are simply available with apt).
I've added also all the languages present at the moment inhttp://mygengo.com/string/p/concrete5-1... (I've used the 542.po + 541.po and 5405.po files), and the translations not currently in use are marked as 'removed'.
All this with the hope that someone at concrete5 takes care of this...
Thank you
Michele
Since I've noticed a lot of missing strings in .po file, I've created a script that automatically extracts the strings to be extracted, either from .php files and from .sql files ('update' mode).
This script also can compile the .po files of all the languages to generate the .mo files ('compile' mode).
The 'update' mode (execute 'php manage-languages.php update') follow these steps:
1) uses xgettext to generate .pot file with xgettext, parsing all the php files (comments for translators should be marked as "// i18n: ...")
2) extracts all the relevant field values from the sql dump files (/concrete/config/install/no_sample_content.sql and /concrete/config/install/sample_content.sql) and generate a second .pot file.
3) with msgcat it merges the two .pot files to create the final language template (saved as /languages/messages.pot)
4) Updates each po file (eventually it creates empty .po files if they are not found) with msgmerge. Please remark that translations no more in use are not discarded: they are just marked as "removed"
The 'compile' mode (execute 'php manage-languages.php compile') simply compiles each .po file to generate the final .mo files.
In the attached archive you can find this script ('/languages/manage-languages.php') among with gettext utilities compiled for win32 ('/languages/.win32/') (for Linux these utilities are simply available with apt).
I've added also all the languages present at the moment inhttp://mygengo.com/string/p/concrete5-1... (I've used the 542.po + 541.po and 5405.po files), and the translations not currently in use are marked as 'removed'.
All this with the hope that someone at concrete5 takes care of this...
Thank you
Michele
Here's an updated version, which includes a "import-mygengo" option. This new option allow to download the languages for myGengo, fixes them (some contains some errors) and merge the available translations.
So the correct workflow should be:
// Create .pot file and merge/create .po files
php manage-languages.php update
// Download myGengo translations and merge them with local .po files
php manage-languages.php import-mygengo
// Compile all the .po files into .mo files
php manage-languages.php compile
Please remarks that all the 3 actions accept an optional parameter to limit the language to work on (eg "php manage-languages.php import-mygengo it_IT")
So the correct workflow should be:
// Create .pot file and merge/create .po files
php manage-languages.php update
// Download myGengo translations and merge them with local .po files
php manage-languages.php import-mygengo
// Compile all the .po files into .mo files
php manage-languages.php compile
Please remarks that all the 3 actions accept an optional parameter to limit the language to work on (eg "php manage-languages.php import-mygengo it_IT")
quite good i'll test it as soon as possible, it seem to be very interesting :) specially the mygengo update.
I'm glad to read that.
Just a note: you can place this script in the languages folder of concrete5. Otherwise you have to uncomment and change the line
Ciao!
Michele
Just a note: you can place this script in the languages folder of concrete5. Otherwise you have to uncomment and change the line
//defined('SITE_ROOT', '/the/root/folder/of/concrete5');
Ciao!
Michele
i'll crertainly test it this week end and make a feed back ;)
Here's an updated version with improved error detection and correction of .po files downloaded from myGengo
So I made the following changes:
- ar_AW: I renamed it to ar_KW since AW is Aruba and the right code for Kuwait is KW.
- bg: for consistency I added the country code of Bulgaria, so we have bg_BG
- el: for consistency I added the country code of Greece, so we have el_GR
- et_ET: I renamed it to et_EE since ET is Ethiopia and the right code for Estonia is EE
- no_NB: I renamed it to nb_NO since the language code is before the country code
- slv: for consistency I renamed it to sl_SI (sl = Slovene, SI = Slovenia)
- tr: for consistency I added the country code for Turkey, so we have tr_TR