i18n is a collection of PHP classes for managing multilanguage webpages
i18n is a collection of PHP classes for managing multilanguage webpages. Translation strings can be stored in flat text files, precompiled gettext files or a mysql database.
The i18n package is a punch of classes for internationalization. It gives you the possibility to maintain multilanguage webpages more easily. The translation strings are stored in flat text files, special Gettext files which are basically precompiled translation files or in a MySQL database. And it works independently from PHPís setlocale function.
First, to avoid problems, make sure that for all pages that use the package you start and end your scripts with:
Getting the language:
Letís start with one of the base classes, the language class. Itís propose is to determinate the preferred locale of the user, by looking at the HTTP_ACCEPT_LANGUAGE header an the users IP address.
First create a new object:
$lg = new Language();
Letís say the user has set his browser to ďGerman Ė AustriaĒ (de-at). Now get your information with those methods:
$lg->getLocale() outputs de_at (the hyphen is replaced with an underscore)
$lg->getLang() outputs de
$lg->getCountry() outputs at
Of course some users have set more than one locale. To get those informations use:
$lg->getUserRawArray() to get an array with all locales accepted by the user
$lg->getUserLangArray() for all Languages
$lg->getUserCountryArray() for all countries
But what if the user has set no specific country code or no locale information could be found at all? Thatís where the default values kick in. Stuff like this is saved in the i18n_settings.ini file:
default_locale = "en"
default_language = "en"
default_country = "us"
To retrieve those settings in your script use
But there are much more settings for the package you can change in the i18n_settings.ini file:
* The method for getting the translations (normal text files, Gettext files, MySQL),
* The extensions for the translation files
* The database connection settings
* If translation errors should be shown or not
You can also force a specific locale to overrule all other locale sources when you create a language object:
$lg_gb = new Language('en_gb');
tags the user gettext files for all text files the i18n user has new language you can language letís for the has set settings ini the language
Download FLP-i18n 2.1b2
Other software in this category
- Desktop Environment
- Science and Engineering
- Text Editing&Processing