Sunday, November 18, 2007

Internationalization/Localization Cheat Sheet

ISO 639-2 Language Codes live here:

Command Line Tools
xgettext will collect all your strings for you from a file or set of files into a po file.

msgfmt will turn your po files into mo files.

info gettext will get you all the info you need to use the GNU gettext utility.

File Structure
Stick your po and mo files into a structure like this:


PHP Functions
putenv ("LC_ALL=es"); sets your locale to Spanish.
bindtextdomain ("messages", "./locale"); shows where to find the translation tables.
textdomain ("messages"); says what domain we're using.

Internationalize your strings in PHP using the handy-dandy underscore operator.
print(_("Hello World"));

More info on gettext functions in PHP:

No comments: