Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Toptal.com:
How to Build a Multilingual App: A Demo With PHP and Gettext
Jan 10, 2017 @ 19:51:13

The Toptal.com site has a tutorial posted from Igor Gomes dos Santos about building a multilingual site with a combination of gettext and PHP.

Whether you are building a website or a full-fledged web application, making it accessible to a wider audience often requires it to be available in different languages and locales.

Fundamental differences between most human languages make this anything but easy. The differences in grammar rules, language nuances, date formats, and more combine to make localization a unique and formidable challenge. [...] The way your code is organized, and how your components and interface are designed, plays an important role in determining how easily you can localize your application.

The tutorial starts off talking about some of the difficulties that come along with internationalization of an application and how localization comes into play. He then starts talking about gettext and links to several PHP libraries that can help you integrate support for it into a current (or new) application. He walks you through the setup of gettext, how the PO/MO files are structured and other things to like about like domain separation, locale codes and the directory structure of your PO/MO files. He then gets into a practical example, showing a sample PO file's contents, two schools of thought on the identifiers in the file and a simple template that uses the "gettext" to get a translation. He also includes code to set up the locale correctly and create the language files for it to use.

tagged: multilingual website gettext tutorial internationalization

Link: https://www.toptal.com/php/build-multilingual-app-with-gettext


Trending Topics: