Reputation: 1226
i've been googling for the last hour or so trying to find a complete working example of gettext in php - all source files, po files, with proper paths, etc. Just a "hello world" with all the required files.
I was wondering if anybody has such a working example. thanks in advance.
Upvotes: 41
Views: 37651
Reputation: 125
I have created this xgettext command line for my project, it can be used by you as an example:
xgettext --files-from=source_files_list.txt --from-code=UTF-8 -L PHP -o mvap.po -d mvap -p languages --keyword=__:1 --keyword=_e:1 --keyword=_x:1,2c --keyword=_n:1,2 --keyword=_nx:1,2,4c --keyword=_n_noop:1,2 --keyword=_nx_noop:1,2,3c --keyword=_ex:1,2c --keyword=esc_html_e:1 --keyword=esc_html__:1
In this example the source_files_list.txt should be a text file containing the name of the files to be analyzed by xgettext separated by new lines.
the "--keyword=..." options are for recognizing the good functions used for translating strings (in this functions there are all wordpress translation functions I found)
it outputs "mvap.po" in the "./languages" folder with domain "mvap"
Upvotes: 0
Reputation: 5519
There is an outstanding five part tutorial at Sitepoint.com called Localizing PHP Applications “The Right Way”. I highly recommend reviewing all five parts!
Upvotes: 4
Reputation: 13260
I've read these other guides posted for this question, but none of them was complete enough for me and also they seem to be rushing into the subject.
THIS GUIDE is divided in many parts, you'll learn from a simple Hello World
to a complex plural management. It not just explain what every function does, but also the values used for these functions.
As a bonus, this guide teaches how to use Poedit which is a very helpful toll for working with gettext
internationalization and a must have if you are dealing with a huge project.
The OP may change the accepted answer to this one if he also think that guide is better. So this answer can get more attention and more gettext
beginners like me can be helped.
Upvotes: 4