\Pluf_L10n

Localization class.

The localization of the code is performed using the __() function call. This function is directly available in the Pluf.php file.

The Pluf_L10n class is used to load the localization strings in memory in the $GLOBALS['_PX_locale'] array. All the strings are stored in utf-8 as all the applications created with the Plume Framework must use the utf-8 encoding. The Pluf locale files are in the Pluf/locale/ folder.

The locale files can be optimized and an optimized version of the files stored in the Pluf temp folder. The temp folder is defined in the global configuration as 'tmp_folder'.

2 letter ISO codes from http://www.oasis-open.org/cover/iso639a.html

Summary

Methods
Properties
Constants
__construct()
loadDomain()
loadFile()
optimizeLocale()
getAvailableLocales()
getAcceptedLanguage()
getIsoCodes()
getCountryCodes()
getNativeLanguages()
getInstalledLanguages()
$locale_folder
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$locale_folder

$locale_folder : 

Folder in which the locale file are available.

Type

Methods

__construct()

__construct(  $folder = '',   $lang = 'en',   $domain = 'pluf') 

Constructor.

See loadDomain(). If no folder is provided, the default Pluf/locale folder is used to load the locales from.

Parameters

$folder
$lang
$domain

loadDomain()

loadDomain(  $lang = 'en',   $domain = 'pluf') : boolean

Load a domain file.

A domain file is a .lang file in the main locale folder of plume.

Parameters

$lang
$domain

Returns

boolean —

Success

loadFile()

loadFile(  $file) : boolean

Load a locale file

Parameters

$file

Returns

boolean —

Success

optimizeLocale()

optimizeLocale(  $file) : boolean

Optimize a locale.

Convert the .lang in a .php file ready to be included. The optimized file is encoded with the current encoding.

Parameters

$file

Returns

boolean —

Success

getAvailableLocales()

getAvailableLocales(  $domain = '') : array

Get the available locales for a domain.

Parameters

$domain

Returns

array —

List of 2 letter iso codes

getAcceptedLanguage()

getAcceptedLanguage(  $available,   $accepted = '') : string

Return the "best" accepted language from the list of available languages.

Use $_SERVER['HTTP_ACCEPT_LANGUAGE'] if the accepted language is empty

Parameters

$available
$accepted

Returns

string —

Language 2 letter iso code, default is 'en'

getIsoCodes()

getIsoCodes(  $lang = false) : array

Returns iso codes.

Parameters

$lang

Returns

array —

The key is either the language or the iso code

getCountryCodes()

getCountryCodes(  $idx_by_code = false) : array

Get the country codes.

Parameters

$idx_by_code

Returns

array —

English name indexed country code or reverse

getNativeLanguages()

getNativeLanguages(  $lang = false) : array

Returns iso codes.

Parameters

$lang

Returns

array —

The key is either the language or the iso code

getInstalledLanguages()

getInstalledLanguages()