Prev | Current Page 668 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

You??™ll learn how to do this in Steps 2, 3, and 4.
Step 2: Create the Localization Repository
Next you need to create the repository where the translated files will be stored. One
directory should be created for each language/country code combination, and within
that directory you need to create another directory named LC_MESSAGES. So, for example,
if you plan on localizing the Web site to support English (the default), German, Italian,
and Spanish, the directory structure would look like this:
CHAPTER 23 ?–  B U ILDING WE B SITES FOR THE WORLD 595
locale/
de_DE/
LC_MESSAGES/
it_IT/
LC_MESSAGES/
es_ES/
LC_MESSAGES/
You can place this directory anywhere you please because the bindtextdomain()
function (shown in action in Listing 23-1) is responsible for mapping the path to a
predefined domain name.
Step 3: Create the Translation Files
Next you need to extract the translatable strings from the PHP scripts. You do so with
the xgettext command, which is a utility bundled with gettext. xgettext offers an
impressive number of options, each of which you can learn more about by executing
xgettext with the --help option. Executing the following command will cause xgettext
to examine all of the files found in the current directory ending in .php, producing a
file consisting of the desired strings to translate:
%>xgettext -n *.php
The -n option results in the file name and line number being included before each
string entry in the output file.


Pages:
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680