PHP Gettext Internationalization Primer Tutorial

PHP Gettext Internationalization Primer Tutorial

PHP Gettext Internationalization Primer Tutorial

Our (Mac OS X laptop) local MAMP web server is an Apache/PHP/MySql web server. In this environment you can find out a lot with some PHP code as per …

<?php phpinfo(); ?>

… and if, in doing this, you find a reference to the “gettext” Human Language and Character Encoding Support functionality existing, you are a lucky candidate to introduce some language translation internationalization logic to your PHP code.

We followed a lot of the advice of the very useful link (thanks) to create two pieces of PHP called …

… that combined, along with the installation of the Poedit (for our Mac laptop) application that you can use to create (or clone, like we did with an existant WordPress *.po file) the ascii *.po files that get “compiled” into *.mo files facilitating the translation pairs used to map words from the local language to the language you translate to … in our case de_DE (German for Germany), as per (the incomplete) messages.po.

Lo and behold our word “Home” (in get_text.php) got translated to “Startseite” (as the best suggestion by “Poedit”) via the *.po excerpt …


# ...
#: wp-includes/post-template.php:1148
msgid "Home"
msgstr "Startseite"
# ...

… so that, with this thinking under your belt, you can concentrate on translations and *.po editing via “Poedit” to create internationalization functionality for your PHP websites. Sounds great to me, and if you haven’t clicked the picture above here to view the tutorial slides go for it here!

If this was interesting you may be interested in this too.

This entry was posted in eLearning, Operating System, Tutorials and tagged , , , , , , , , , , , , , , . Bookmark the permalink.

15 Responses to PHP Gettext Internationalization Primer Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *