PHP internationalization with gettext
Overview
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 http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu52_52.1-8ubuntu0.2_amd64.deb; 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.:
Related
- "PHP Smarty: a modifier for internationalization tool gettext", blog.ueffing.net, 2013-07-19: /post/2013/07/19/php-smarty-a-modifier-for-internationalization-tool-gettext/
- "Tutorial: Lokalisierung mit Gettext und PHP", a-coding-project.de, 2013-10-03: http://www.a-coding-project.de/ratgeber/php/lokalisierung-mit-gettext
Links
- "gettext", Free Software Foundation, 2013: https://www.gnu.org/software/gettext/
- "GNU gettext", wikipedia, 2013: https://de.wikipedia.org/wiki/GNU_gettext
- "gettext", wikipedia, 2013: https://en.wikipedia.org/wiki/Gettext
- PHP http://php.net/
- Smarty http://www.smarty.net/