Ygettext - The Fundanemt gettext tool
by Kim Schulz
This page is about the small gettext utility ygettext, which is the Fundanemt enabled version of xgettext. The tool is uses to parse all the files in fundanemt, pull out all the strings and create a po-file (translation file) from them. It also merges the translation from earlier translations and remove all strings that a deprecated.
The utility is written in Perl and is primarily ment to be used with Fundanemt, though it is quite simple to correct it to work for any other systems. Latest version is always available with Fundanemt and can be found in fundanemt/extra/ygettext
Some history
When we started to convert Fundanemt to use English as the main language (is started out as a Danish project), we wanted to use the gettext implemtation in PHP. Unfortunatly this is nearly useless due to the fact that you have to reload the webserver, every time you have changed your translation (or else the translations will not be re-cached).
This is a problem we couldn't live with, so we changes all our gettext() functions to our own implementation gt(). We still wanted the po file format, because it makes it really easy for translators to translate fundanemt, so therefore we had to make our own po file parser, cacher and creator.
The parser is implemented directly in Fundanemt core, and the cache uses sessions to hold the strings from site to site.
The po-file creator is ygettext.
How to use it
Is is fairly simple to use ygettext. you just have to run it from the commandline when standing in the root of the fundanemt file tree.
The command format is like this:
ygettext format1,format2,format3,... path/to/messages.po
the formats are the fileendings of the files you want it to parse. This is normally php,inc,class but could be just about anything you would want.
the second argument is the relative path to the po-file you want to create/merge.
if the file exists, then it is merged with the strings that the parser finds. If it doesn't then it creates the file.
After creation/mergin, you can open the po-file and check the translation + adding the new translations that wasn't already in the file.
The parser ignores all files that are situated in the folder called modules. This is because all the modules have their own translations.
To create a translation for a module, you just do the same steps as mentioned above, except for that you have to be in the modules folder indsted (eg. in fundanemt/modules/fundaCalendar/)
The module translations are placed in the module folder locale/[lang]/LC_MESSAGES/[modulename].po
