KWeb  6.4
Strings Class Reference

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()

Detailed Description

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.

Author:
Rafal Lindemann, STAMINA

Constructor & Destructor Documentation

Strings::__construct ( name,
lang 
) [protected]
Strings::__destruct ( )

Member Function Documentation

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.

Parameters:
$nameStrings catalog to use
$textpolish text to be translated
$langLanguage 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

Parameters:
$nameStrings catalog to use
$idSingularId or english text for singular
$idPluralenglish text for plural, or FALSE if you've used id for singular
$number
$langLanguage 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.

Parameters:
$nameStrings catalog to use
$pluralsarray of polish texts for plurals
$number
$langLanguage 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

Parameters:
$nameOrMessageStrings catalog to use, or message if you are using main catalog
$messageId or english text to be translated
$langLanguage 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.

Parameters:
$id
$default- if not provided, {PACKAGE/ID} will be returned in case there is no translation available
Returns:
unknown|string
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

Parameters:
$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)
Returns:
KDBSettings
Strings::initialize ( ) [protected]
static Strings::instance ( name,
lang = false,
create = true 
) [static]
Returns:
Strings
static Strings::instanceExists ( name,
lang = false 
) [static]
Returns:
Strings
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

See also:
translateString
Strings::translateString ( text,
lang 
)

Tries to translate specified text into specified language.

Warning:
$text is NOT and id, it's a text in THIS catalog's language!

Field Documentation

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]

The documentation for this class was generated from the following file: