This is more or less a reminder to myself. Since there do not seem to be many sources about this exact issue and I had to search for it a couple of times already I thought it might be nice to have it up on my own blog.
Working on many international project I’ve been using Poedit for a while now. Poedit is an editor for gettext catalogs (.po files). To gether with PHP and the gettext extension it’s a great tool to implement multilingual web applications.
The issue is that you can set up a parsers in Poedit, basically definitions of file types and command line parameters for xgettext, which is executed fo find the parts in a file that should be translated. So there is a parser for PHP in there, but often, for example in the CakePHP framework, you have to deal with files that are PHP files, but that have a different extension, in the CakePHP case views end with .thtml … Just adding “*.thtml” to the list of extensions in the PHP parser setup does not cut the mustard and you end up getting an error message like this:
xgettext: warning: file ‘[...].thtml’ extension ‘thtml’ is unknown; will try C.
To solve this, you need to tell xgettext that it has to deal with PHP files by adding “–language=PHP” to the list of commandline options. This is done by opening Poedit’s preferences and navigating to the parsers section there. In the PHP parser under “Parser command” (btw. this is the MAC version of Poedit) I have now the following line:
xgettext --language=PHP --force-po -o %o %C %K %F
Voila, .thtml files or any file specified in the PHP parser is now treated as PHP and my translation sections are found.
Thanks to Vaclav for his answer here.
Recent Comments