PHP internationalization with gettext

2018-04-22 12:30:18 PHP,Internationalization,i18n,Locale,gettext,EN


Installation on Debian/Ubuntu Linux

You must install the Package gettext, which comes as a meta-package and contains a bundle of commands (at this point it is similiar to imagemagick; one package, several commands).

Install gettext

$ sudo apt-get install gettext

Install PHP internationalization Extension

You need to install the internationalization Extension for PHP. Following the Syntax php{Version}-intl, the command to install the extension for PHP5 is:

$ sudo apt-get install php5-intl

Problems running gettext

If you run into trouble using gettext you may need to install the Library libcurl, too.

$ sudo apt-get install libicu52

If libicu52 is not available on your system (e.g.: > Ubuntu 14.04 LTS), you can install manually (64bit system):

$ wget; sudo dpkg -i libicu52_52.1-8ubuntu0.2_amd64.deb

You need to name the Place of Translationtables. That is the place where your Translationfolders reside. You can either do this inside the function (see bindtextdomain($sDomain, 'PATH_TO_MY_LANGUAGES_FOLDER');) or do it outside by defining the appropriate constant, e.g.:

define('PATH_TO_MY_LANGUAGES_FOLDER', '/var/www/App/languages');

The Translationtables itself must hold the official structure, e.g.: php gettext translation-files structure



Diese Website verwendet Cookies, um Ihnen den bestmöglichen Service zu gewährleisten. Weiterführende Informationen finden Sie in unserer Datenschutzerklärung. Klicken Sie in die nachfolgende Checkbox um Cookies zu akzeptieren. Bestätigen Sie anschließend durch Klick auf "Speichern".