Automatically add Gettext to all japanese texts in all php files in a directory

39 views Asked by At

I have some 500 php files which contain some Japanese texts that are to translated. I want to add gettext to all those japanese texts. How can I add it automatically in all php files

1

There are 1 answers

0
Guido Flohr On

As a starter you can extract all strings:

$ find DIRECTORY -name '*.php*' >POTFILES
$ xgettext -a --files-from=POTFILES

That results in a file messages.po in the current directory, containing all possibly translatable strings. When you open messages.po in a PO editor like emacs (key s) or Poedit (check the docs), you can directly visit the source file from the PO file.

Adding gettext() calls automatically is not supported because you will normally have a lot of false positives.