Localization tools.
More...
Localization tools.
Localization utilities
◆ bootstrap()
◆ init()
static init |
( |
?string |
$code = 'en' | ) |
|
|
static |
L10N initialization
Create global arrays for L10N stuff. Should be called before any work with other methods. For plural-forms, __l10n values can now be array.
- Parameters
-
string | null | $code | Language code to work with |
References $code, $files, $locales, and lang().
◆ lang()
static lang |
( |
?string |
$code = null | ) |
|
|
static |
◆ trans()
static trans |
( |
string |
$singular, |
|
|
?string |
$plural = null , |
|
|
?int |
$count = null |
|
) |
| |
|
static |
Translate a string
Returns a translated string of $singular or $plural according to a number if it is set. If translation is not found, returns the string.
- Parameters
-
string | $singular | Singular form of the string |
string | $plural | Plural form of the string (optionnal) |
integer | $count | Context number for plural form (optionnal) |
- Returns
- string Translated string
References index().
◆ index()
static index |
( |
int |
$count | ) |
|
|
static |
Retrieve plural index from input number
- Parameters
-
integer | $count | Number to take account |
- Returns
- integer Index of plural form
Referenced by trans().
◆ set()
static set |
( |
string |
$file | ) |
|
|
static |
◆ getFilePath()
static getFilePath |
( |
string |
$dir, |
|
|
string |
$file, |
|
|
string |
$lang |
|
) |
| |
|
static |
L10N file
Returns a file path for a file, a directory and a language. If $dir/$lang/$file is not found, it will check if $dir/en/$file exists and returns the result. Returns false if no file were found.
- Parameters
-
string | $dir | Directory |
string | $file | File |
string | $lang | Language |
- Returns
- string|false File path or false
Referenced by dcAdmin\init(), dcModules\loadModuleL10Nresources(), and testGetFilePath().
◆ getPoFile()
static getPoFile |
( |
string |
$file | ) |
|
|
static |
Load gettext file
Returns an array of strings found in a given gettext (.po) file
- Parameters
-
- Returns
- array|false
Referenced by generatePhpFileFromPo().
◆ generatePhpFileFromPo()
static generatePhpFileFromPo |
( |
string |
$file, |
|
|
string |
$license_block = '' |
|
) |
| |
|
static |
Generates a PHP file from a po file
Return a boolean depending on success or failure
- Parameters
-
string | $file | File |
string | $license_block | Optional license block to add at the beginning |
- Returns
- bool true on success
References $locales, and getPoFile().
◆ parsePoFile()
static parsePoFile |
( |
string |
$file | ) |
|
|
static |
Parse Po File
Return an array of po headers and translations from a po file
- Parameters
-
- Returns
- array|false Parsed file
◆ cleanPoLine()
static cleanPoLine |
( |
string |
$type, |
|
|
|
$_ |
|
) |
| |
|
staticprotected |
◆ cleanPoString()
static cleanPoString |
( |
|
$_ | ) |
|
|
staticprotected |
◆ parsePluralExpression()
static parsePluralExpression |
( |
string |
$expression | ) |
|
|
static |
Extract nplurals and plural from po expression
- Parameters
-
string | $expression | Plural form as of gettext Plural-form param |
- Returns
- array Number of plurals and cleaned plural expression
Referenced by testParsePluralExpression().
◆ createPluralFunction()
static createPluralFunction |
( |
int |
$nplurals, |
|
|
string |
$expression |
|
) |
| |
|
static |
Create function to find plural msgstr index from gettext expression
- Parameters
-
integer | $nplurals | Plurals number |
string | $expression | Plural expression |
- Returns
- callable Function to extract right plural index
Referenced by lang().
◆ cleanPluralExpression()
static cleanPluralExpression |
( |
string |
$_ | ) |
|
|
staticprotected |
◆ isCode()
static isCode |
( |
string |
$code | ) |
|
|
static |
Check if a language code exists
- Parameters
-
- Returns
- bool True if code exists
References $code.
Referenced by testCodeLang().
◆ getCode()
static getCode |
( |
string |
$code | ) |
|
|
static |
Get a language code according to a language name
- Parameters
-
- Returns
- string Language code
References $code.
Referenced by testgetCode().
◆ getISOcodes()
static getISOcodes |
( |
bool |
$flip = false , |
|
|
bool |
$name_with_code = false |
|
) |
| |
|
static |
◆ getLanguageName()
static getLanguageName |
( |
string |
$code | ) |
|
|
static |
◆ getLanguagesName()
static getLanguagesName |
( |
| ) |
|
|
static |
Get languages names
- Returns
- array List of languages names by languages codes
◆ getLanguageTextDirection()
static getLanguageTextDirection |
( |
string |
$code | ) |
|
|
static |
◆ getLanguagesTextDirection()
static getLanguagesTextDirection |
( |
| ) |
|
|
static |
Get languages text directions
- Returns
- array List of text directions by languages codes
◆ getLanguagePluralsNumber()
static getLanguagePluralsNumber |
( |
string |
$code | ) |
|
|
static |
◆ getLanguagesPluralsNumber()
static getLanguagesPluralsNumber |
( |
| ) |
|
|
static |
Get languages numbers of plurals
- Returns
- array List of numbers of plurals by languages codes
◆ getLanguagePluralExpression()
static getLanguagePluralExpression |
( |
string |
$code | ) |
|
|
static |
◆ getLanguagesPluralExpression()
static getLanguagesPluralExpression |
( |
| ) |
|
|
static |
Get languages plural expressions
- Returns
- array List of plural expressions by languages codes
◆ getLanguagesDefinitions()
static getLanguagesDefinitions |
( |
int |
$type, |
|
|
string |
$default = '' |
|
) |
| |
|
staticprotected |
Get languages definitions of a given type
The list follows ISO 639.1 norm with additionnal IETF codes as pt-br
Countries codes and names from:
Text direction from:
Plural-forms taken from:
$languages_definitions types look like this: 0 = code ISO 639.1 (2 digit) + IETF add 1 = code ISO 639.2 (english 3 digit) 2 = English name 3 = natal name 4 = text direction (ltr or rtl) 5 = number of plurals (1 means no plural form) 6 = plural expression (as of gettext .po plural form)
null values represent missing values
- Parameters
-
integer | $type | Type of definition |
string | $default | Default value if definition is empty |
- Returns
- array List of requested definition by languages codes
◆ $files
◆ $locales
◆ $languages_definitions
$languages_definitions = [] |
|
staticprotected |
◆ $languages_name
◆ $languages_textdirection
◆ $languages_pluralsnumber
◆ $languages_pluralexpression
$languages_pluralexpression |
|
staticprotected |
◆ $language_code
◆ $language_name
◆ $language_textdirection
◆ $language_pluralsnumber
◆ $language_pluralexpression
$language_pluralexpression |
|
staticprotected |
◆ $language_pluralfunction
The documentation for this class was generated from the following file: