\Nano4\UtilsTranslation

Translation Class

Creates the object which represents your translation database.

Summary

Methods
Properties
Constants
__construct()
getStr()
strArray()
strStruct()
lookupStr()
offsetExists()
offsetUnset()
offsetSet()
offsetGet()
$default_lang
$default_ns
No constants found
get_opts()
No protected properties found
N/A
strStruct_getDef()
$languages
N/A

Properties

$default_lang

$default_lang : string

Type

string — The default language to use. If set to true, we use Accept-Language header. If none can be found, we fallback to 'en'.

$default_ns

$default_ns : array

Type

array — The namespaces to look in.

$languages

$languages : 

Type

Methods

__construct()

__construct(array  $data, array  $ns = array(), string  $lang = true) 

Create our object.

Parameters

array $data

An associative array representing the translations.

array $ns

Optional. Default namespaces to look in.

string $lang

Optional. Language to use. Default: true

getStr()

getStr(  $key,   $opts = array()) 

Parameters

$key
$opts

strArray()

strArray(  $array,   $prefix = '',   $opts = array()) 

Parameters

$array
$prefix
$opts

strStruct()

strStruct(  $array,   $sep = '.',   $ns = '',   $opts = array()) 

Generate a translation table from an associative array.

In this version, we support a complex nested structure, were the first level key is the prefix (minus separator) and the definitions nest from there. The default separator between prefix and name is a period. You can also specify an optional top-level prefix or namespace which the rest of the prefixes must exist within. No separator will be put between the namespace and the inner prefix, so specify it in its entirety with closing colon (e.g. "mysection:")

Parameters

$array
$sep
$ns
$opts

lookupStr()

lookupStr(  $string,   $opts = array()) 

Parameters

$string
$opts

offsetExists()

offsetExists(  $offset) 

Parameters

$offset

offsetUnset()

offsetUnset(  $offset) 

Parameters

$offset

offsetSet()

offsetSet(  $offset,   $value) 

Parameters

$offset
$value

offsetGet()

offsetGet(  $offset) 

Parameters

$offset

get_opts()

get_opts(  $opts) 

Parameters

$opts

strStruct_getDef()

strStruct_getDef(  $def,   $prefix,   $sep,   $ns,   $opts) 

Parameters

$def
$prefix
$sep
$ns
$opts