2

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: poEdit anti-verbose 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 ?

FMaz008
  • 11,161
  • 19
  • 68
  • 100

3 Answers3

7

Use brew to install it:

brew install gettext

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
sorin
  • 161,544
  • 178
  • 535
  • 806
  • 1
    you should use the "gettext" formula, not "xgettext". it's a keg however, so it does not symlink the binaries to /usr/local/bin. you can symlink it yourself though, see FMaz008 answer. – Jonatan Nov 22 '13 at 12:03
  • It says its already installed. xgettext command still not found – trainoasis Aug 09 '19 at 13:11
  • I had to reinstall `brew reinstall gettext` and update bash profile from my zsh. https://stackoverflow.com/questions/41870164/xgettext-no-such-file-or-directory/58192587#58192587 – Victor Oliveira Oct 01 '19 at 21:41
6

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.

Community
  • 1
  • 1
FMaz008
  • 11,161
  • 19
  • 68
  • 100
0

You can use php2po from the Translate Toolkit to convert PHP arrays of strings into correctly formatted PO files.

Dwayne
  • 845
  • 7
  • 11