Over a million developers have joined DZone.

Tutorial: Localizing PHP Applications the Right Way, with gettext

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

English has become the default language of software development for economic and historical reasons. But maintaining only English-language code is not ideal, because plenty of developers' first language isn't English; and maintaining multiple codebases, in different languages, is, like every code-multiplication, an easy recipe for disaster.

The gettext utilities offer a workaround -- but implementation isn't always obvious. (The full documentation is quite thorough, but rather long.) The continuing popularity of PHP makes gettext particularly useful for PHP developers -- but the php.net documentation is pretty terse, and barely addresses Windows (where PHP is growing rapidly).

The solution? Abdullah Abouzekry's step-by-step guide to localizing PHP, recently posted on phpmaster.com.

As Abdullah explains:

In this series of articles you will learn how to gettext to localize your PHP application. Part 1 will provide just a quick foray into gettext. Each subsequent part will build on preceding parts, teaching you how to handle multiple translation domains, plural forms, and even how you can automate some of the localization process.

One of the neat things about this walkthrough is its attention to detail: in 'Preparing the Environment', for example, Abdullah includes special instructions for Windows and Linux users, something the php.net documentation left out (resulting in a small patchwork of anonymously contributed notes).

Only Part 1 is up so far. But check it out and, if it helps you, stay tuned for additions in the future.


Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}