|
KWeb
6.4
|
Class for retrieving translation strings. More...
Public Member Functions | |
| __destruct () | |
| getName () | |
| getLang () | |
| getUserDB ($lang=false) | |
| getCachePath () | |
| recreateData () | |
| __get ($id) | |
| __isset ($id) | |
| getString ($id, $default=false) | |
| Returns translation with specified id. | |
| getPlural ($idSingular, $idPlural, $number) | |
| Returns plural depending on the number, and this catalog's language. | |
| findTranslation ($text) | |
| Returns translation id or false if not found. | |
| translateString ($text, $lang) | |
| Tries to translate specified text into specified language. | |
| translatePlural ($plurals, $number, $lang) | |
| Tries to translate specified plural into specified language. | |
| getStringScripted ($id, $params=false, $default=false) | |
| Returns translation that is parsed by KScript. | |
Static Public Member Functions | |
| static | instance ($name, $lang=false, $create=true) |
| static | instanceExists ($name, $lang=false) |
| static | get ($name, $id, $lang=false, $default=false) |
| Calls getString() on specified package. | |
| static | getEx ($name, $id, $params=false, $lang=false, $default=false) |
| Calls getStringScripted() on specified package. | |
| static | getScripted ($name, $id, $params=false, $lang=false, $default=false) |
| Calls getStringScripted() on specified package. | |
| static | __s ($nameOrMessage, $message=false, $lang=false, $default=false) |
| Translates message using provided strings catalog. | |
| static | __plural ($name, $idSingular, $idPlural, $number, $lang=false) |
| Translates plurals using provided strings catalog. | |
| static | __PL ($nameOrMessage, $text=null, $lang=false) |
| Translates POLISH message using provided strings catalog. | |
| static | __pluralPL ($name, $singular, $plural2, $plural5, $number, $lang=false) |
| Translates POLISH plural using provided strings catalog. | |
Data Fields | |
| $strings | |
Static Public Attributes | |
| static | $languageRouting = array('en') |
| static | $stringsDiscoveryId = 'strings' |
| static | $useUserStrings = true |
| static | $defaultLanguage = 'en' |
| static | $instances = array() |
Protected Member Functions | |
| __construct ($name, $lang) | |
| initialize () | |
| loadCache () | |
| storeCache () | |
Protected Attributes | |
| $name | |
| $lang | |
| $userDBs = array() | |
Class for retrieving translation strings.
Translations are divided into packages, and stored in /strings/LANGUAGE/PACKAGE.php.
Each package file should return only a table with text definitions...
Additionaly, it's possible to override every single string using KDBSettings::instance('strings_PACKAGE_LANGUAGE'). This way they become user editable.
| Strings::__construct | ( | $ | name, |
| $ | lang | ||
| ) | [protected] |
| Strings::__destruct | ( | ) |
| Strings::__get | ( | $ | id | ) |
| Strings::__isset | ( | $ | id | ) |
| static Strings::__PL | ( | $ | nameOrMessage, |
| $ | text = null, |
||
| $ | lang = false |
||
| ) | [static] |
Translates POLISH message using provided strings catalog.
If $lang is not polish, message is first translated into english id, and then translated to the target language. If the message is not translated, original message is returned.
| $name | Strings catalog to use |
| $text | polish text to be translated |
| $lang | Language to translate to, or FALSE for current language |
| static Strings::__plural | ( | $ | name, |
| $ | idSingular, | ||
| $ | idPlural, | ||
| $ | number, | ||
| $ | lang = false |
||
| ) | [static] |
Translates plurals using provided strings catalog.
If the message is not translated, original message is returned
| $name | Strings catalog to use |
| $idSingular | Id or english text for singular |
| $idPlural | english text for plural, or FALSE if you've used id for singular |
| $number | |
| $lang | Language to translate to, or FALSE for current language |
| static Strings::__pluralPL | ( | $ | name, |
| $ | singular, | ||
| $ | plural2, | ||
| $ | plural5, | ||
| $ | number, | ||
| $ | lang = false |
||
| ) | [static] |
Translates POLISH plural using provided strings catalog.
If $lang is not polish, message is first translated into english id, and then translated to the target language. If the message is not translated, original message is returned.
| $name | Strings catalog to use |
| $plurals | array of polish texts for plurals |
| $number | |
| $lang | Language to translate to, or FALSE for current language |
| static Strings::__s | ( | $ | nameOrMessage, |
| $ | message = false, |
||
| $ | lang = false, |
||
| $ | default = false |
||
| ) | [static] |
Translates message using provided strings catalog.
If the message is not translated, original message is returned
| $nameOrMessage | Strings catalog to use, or message if you are using main catalog |
| $message | Id or english text to be translated |
| $lang | Language to translate to, or FALSE for current language |
| Strings::findTranslation | ( | $ | text | ) |
Returns translation id or false if not found.
| static Strings::get | ( | $ | name, |
| $ | id, | ||
| $ | lang = false, |
||
| $ | default = false |
||
| ) | [static] |
Calls getString() on specified package.
| Strings::getCachePath | ( | ) |
| static Strings::getEx | ( | $ | name, |
| $ | id, | ||
| $ | params = false, |
||
| $ | lang = false, |
||
| $ | default = false |
||
| ) | [static] |
Calls getStringScripted() on specified package.
| Strings::getLang | ( | ) |
| Strings::getName | ( | ) |
| Strings::getPlural | ( | $ | idSingular, |
| $ | idPlural, | ||
| $ | number | ||
| ) |
Returns plural depending on the number, and this catalog's language.
Plural rules are taken from Zend_Translate_Plural
| static Strings::getScripted | ( | $ | name, |
| $ | id, | ||
| $ | params = false, |
||
| $ | lang = false, |
||
| $ | default = false |
||
| ) | [static] |
Calls getStringScripted() on specified package.
| Strings::getString | ( | $ | id, |
| $ | default = false |
||
| ) |
Returns translation with specified id.
| $id | |
| $default | - if not provided, {PACKAGE/ID} will be returned in case there is no translation available |
| Strings::getStringScripted | ( | $ | id, |
| $ | params = false, |
||
| $ | default = false |
||
| ) |
Returns translation that is parsed by KScript.
To access parameters passed with $params use this syntax:
'id' => 'Parameter name HTML stripped: {{svar|name|#html}}'
Check KScript and KWebScript documentations
| $id | |
| $params | - parameters for KScript |
| $default | - if not provided, {PACKAGE/ID} will be returned in case there is no translation available |
| Strings::getUserDB | ( | $ | lang = false | ) |
| Strings::initialize | ( | ) | [protected] |
| static Strings::instance | ( | $ | name, |
| $ | lang = false, |
||
| $ | create = true |
||
| ) | [static] |
| static Strings::instanceExists | ( | $ | name, |
| $ | lang = false |
||
| ) | [static] |
| Strings::loadCache | ( | ) | [protected] |
| Strings::recreateData | ( | ) |
| Strings::storeCache | ( | ) | [protected] |
| Strings::translatePlural | ( | $ | plurals, |
| $ | number, | ||
| $ | lang | ||
| ) |
Tries to translate specified plural into specified language.
If the language of this catalog is the same as target language
| Strings::translateString | ( | $ | text, |
| $ | lang | ||
| ) |
Tries to translate specified text into specified language.
Strings::$defaultLanguage = 'en' [static] |
Strings::$instances = array() [static] |
Strings::$lang [protected] |
Strings::$languageRouting = array('en') [static] |
Strings::$name [protected] |
| Strings::$strings |
Strings::$stringsDiscoveryId = 'strings' [static] |
Strings::$userDBs = array() [protected] |
Strings::$useUserStrings = true [static] |