The user can define the interface language of a web application.
This module allow to choose the language to display by using the user prefs proposed by its browser and the application's translations available.
The selected choice can also be stored in a cookie to overwrite the automatic process
// Language
$language = new Domframework\Language ();
// The application name is used to choose the
// locale/fr_FR.UTF8/LC_MESSAGES/application.po file.
// The second parameter is the cookie name.
$lang = $language->activeLanguage ("application", "application-Language");
// Define the default value if none can be automatically detected from the
// user preferences.
if ($lang === "C") $lang = "fr_FR";Namespace Domframework
/** Language class : change the messages
/** Language cache directory
/** The complete stack of language selection@param string $packageThe package name (package.(po|mo) files)@param string $languageCookieThe name of the cookie saved in the browser@param string $forcedLanguageThe name of a forced language@returnstring The language with format fr_FR to be used
/** Start the Gettext support with the cached file .mo provided as parameter@param string $moFileThe .mo file@param string $languageCodeThe language code to use@param integer $categorythe LC_ type to use@param string|null $repLocaleThe locale directory. Use "./locale" if not provided
/** This function manage the cache of $package.mo files as Apache cache them It return the directory to use@param string $languageCodeLanguage with format "fr_FR"@param string|null $packageThe package name of the soft ($package.mo file). "messages" by default@param string|null $categoryThe folder name LC_MESSAGES by default@param string|null $repLocaleThe folder where all the locales are stored
/** Return the language recorded in the Cookie. Check if this language is@param string $cookieNameThe cookie name@param string|null $repLocaleThe directory use to store the locale files allowed@returnstring The language allowed or FALSE
/** Set the cookie with a TTL of one month@param string $cookieNameThe name of the cookie@param string $languageCodeLanguage to store@param string $sitepathThe site path
/** Return the language name from the language Ex. : $languageCode=fr_FR, return France@param string $languageCodeLanguage with format "fr_FR"@returnstring Then language name
/** Choose the best language in the browser list and which is available in locale path@param string|null $repLocaleDirectory where are stored the translations@param string|null $languageCodeThe coding langugage of the soft@returnstring The choosed locale whithout charset (like fr_FR)
/**
Return the language subtag for the language
http://www.iana.org/assignments/language-subtag-registry/
language-subtag-registry
@param string $languageCode The language code to convert
/**
Return an array with all the languages available in the $repLocale dir
The languages are in the format 'en_US' without the codeset.
@param string|null $repLocale The directory use to store the locale files
Return FALSE if there is an error