Documentation

Core_I18n
in package

Internationalization

Tags
subpackage

Core

version
7.x
author

Hostmake LLC

copyright

© 2005-2024 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru

Table of Contents

Properties

$_cache  : array<string|int, mixed>
Cache
$_defaultLng  : string
Default language
$_instance  : mixed
The singleton instance.
$_lng  : string
Current language

Methods

check()  : bool
Check if text for key exists
expandLng()  : self
Expand LNG
get()  : string
Get text for key
getLng()  : mixed
Get current language
getLngFile()  : array<string|int, mixed>
Include lng file
instance()  : object
Register an existing instance as a singleton.
loadLng()  : self
Load LNG into cache
setLng()  : self
Set target language
__construct()  : mixed
Constructor.

Properties

$_cache

Cache

protected array<string|int, mixed> $_cache = array()

$_defaultLng

Default language

protected string $_defaultLng = 'ru'

$_instance

The singleton instance.

protected static mixed $_instance

$_lng

Current language

protected string $_lng = \NULL

Methods

check()

Check if text for key exists

public check(string $key[, mixed $lng = NULL ]) : bool
Parameters
$key : string

module name dot key name, e.g. 'Constant.menu'

$lng : mixed = NULL

language, default NULL

Return values
bool

expandLng()

Expand LNG

public expandLng(string $className, array<string|int, mixed> $value[, mixed $lng = NULL ]) : self
Parameters
$className : string

class name

$value : array<string|int, mixed>
$lng : mixed = NULL

language

Return values
self

get()

Get text for key

public get(string $key[, mixed $lng = NULL ][, mixed $count = NULL ]) : string
$value = Core_I18n::instance()->get('Constant.menu'); $value = Core_I18n::instance()->get('Constant.menu', 'en');

Be careful when using short alias, function Core::() has different parameters. $value = Core::('Constant.menu');

Parameters
$key : string

module name dot key name, e.g. 'Constant.menu'

$lng : mixed = NULL

language, default NULL

$count : mixed = NULL

default NULL

Return values
string

getLng()

Get current language

public getLng() : mixed

getLngFile()

Include lng file

public getLngFile(string $className, string $lng) : array<string|int, mixed>
Parameters
$className : string

class name

$lng : string

language name

Return values
array<string|int, mixed>

instance()

Register an existing instance as a singleton.

public static instance() : object
Return values
object

loadLng()

Load LNG into cache

public loadLng(mixed $lng, string $className) : self
Parameters
$lng : mixed

language

$className : string

class name

Return values
self

setLng()

Set target language

public setLng(string $lng) : self
Parameters
$lng : string

language short name

Return values
self

__construct()

Constructor.

protected __construct() : mixed

        
On this page

Search results