问题
I'm on Mac OSX, and I'm unable to find a good solution to parse PHP Code and extract the translatable strings.
I've tried PoEdit, but it fail with an anti-verbose trunkated error:
I've also tried Virtaal, but the app crash when I click "Open", event before the browsing windows appear.
I've tried OmegaT, but I think it doesn't support .po files. I can't figure out how it works :(
I've also tried xgettext.pl, and it work really well, except it doesn't detect the PHP dgettext() function, and doesn't seem to offer any additional option to configure extra keyword like poEdit does. Man page is here: http://www.unix.com/man-page/OSX/1/xgettext.pl/
Any solution so far ?
回答1:
Use brew to install it:
brew install gettext
回答2:
Ok, here's the answer ( deduced from Internationalisation Django (on OSX) )
The real xgettext for PHP is available as a tool that come with the gettext extension.
As I've installed gettext with brew ( brew install gettext ), it's located here: /usr/local/Cellar/gettext/0.18.1.1/bin/xgettext
This version of xgettext support the PHP function.
回答3:
You can use php2po from the Translate Toolkit to convert PHP arrays of strings into correctly formatted PO files.
来源:https://stackoverflow.com/questions/8403938/xgettext-in-osx-to-create-po-file-from-php-code