A singleton class to provide simple, generic mechanism for dealing with languages encodings, and locales. This class does not handle translation strings.
author |
Robert Campbell |
---|---|
since | 1.11 |
package |
CMS |
license |
GPL |
get_installed_languages() : array
array
Array of language names
get_language_info(string $lang) : \CmsNls
string
$langlanguage name.
object repesenting the named language. or null.
get_current_language() : string
If not explicitly set this method will try to detect the current language. different detection mechanisms are used for admin requests vs. frontend requests. if no match could be found in any way, en_US is returned.
string
Language name.
get_default_language() : string
This method will behave differently for admin or frontend requests.
For admin requests first the preference is checked. Secondly, an attempt is made to find a language understood by the browser that is compatible with what is avaialable. If no match can be found, en_US is assumed.
For frontend requests if a language detector has been set into this object it will be called to attempt to find a language. If that fails, then the frontend language preference is used. Thirdly, if no match is found en_US is assumed.
string
get_frontend_language() : string
the language returned must be available as specified by the available NLS Files.
string
language name.
get_admin_language() : string
The language returned must be an available language as specified by the available NLS Files. If no suitable language can be detected this function will return en_US
string
The language name
detect_browser_language() : string
string
First suitable lang string. or nothing.
get_browser_languages() : array
array
of Strings representing the languages the browser supports.
get_encoding() : \string.
If an encoding has not been explicitly set, the default_encoding value from the config file will be used If that value is empty, the encoding associated with the current language will be used. If no suitable encoding can be found, UTF-8 will be assumed.
\string.
set_encoding(mixed $str)
mixed
$strThe encoding (comma separated encodings is acceptable.
set_locale()
if language has not been set... does nothing. will use the locale from the nls information for the current locale if config entry is set... it will be used, but subsequent calls to this method will do nothing.
set_language_detector(\CmsLanguageDetector &$obj)
The module can provide an object derived from CmsLanguageDetector to this method.
i.e: CmsNlsOperations::set_language_detector(myLanguageDetector)
Note, this module must return a language for which there is an available NLS file.
\CmsLanguageDetector
$objfind_nls_match(string $str) : \hash
string
$strAn approximate language specification (an alias matchis done if possible).
\hash
containing NLS information.