Documentation

Language
in package

Table of Contents

Constants

LANGUAGES  = ['zh_TW' => ['name' => 'Chinese', 'htmlCode' => 'zh-TW'], 'zh_CN' => ['name' => 'Chinese (Simplified)', 'htmlCode' => 'zh-CN'], 'cs_CZ' => ['name' => 'Czech', 'htmlCode' => 'cs'], 'da_DK' => ['name' => 'Danish', 'htmlCode' => 'da'], 'nl_NL' => ['name' => 'Dutch', 'htmlCode' => 'nl'], 'en_UK' => ['name' => 'English UK', 'htmlCode' => 'en'], 'en_US' => ['name' => 'English US', 'htmlCode' => 'en'], 'fa_IR' => ['name' => 'Persian (Iran)', 'htmlCode' => 'fa', 'rtl' => \true], 'fr_FR' => ['name' => 'French', 'htmlCode' => 'fr'], 'de_DE' => ['name' => 'German', 'htmlCode' => 'de'], 'el_GR' => ['name' => 'Greek', 'htmlCode' => 'el'], 'hu_HU' => ['name' => 'Hungarian', 'htmlCode' => 'hu'], 'it_IT' => ['name' => 'Italian', 'htmlCode' => 'it'], 'ja_JP' => ['name' => 'Japanese', 'htmlCode' => 'ja'], 'lt_LT' => ['name' => 'Lithuanian', 'htmlCode' => 'lt'], 'no_NO' => ['name' => 'Norwegian', 'htmlCode' => 'no'], 'pl_PL' => ['name' => 'Polish', 'htmlCode' => 'pl'], 'pt_BR' => ['name' => 'Portuguese', 'htmlCode' => 'pt'], 'ro_RO' => ['name' => 'Romanian', 'htmlCode' => 'ro'], 'ru_RU' => ['name' => 'Russian', 'htmlCode' => 'ru'], 'sk_SK' => ['name' => 'Slovak', 'htmlCode' => 'sk'], 'sq_AL' => ['name' => 'Albanian', 'htmlCode' => 'sq'], 'sr_RS' => ['name' => 'Serbian', 'htmlCode' => 'sr'], 'es_419' => ['name' => 'Spanish', 'htmlCode' => 'es'], 'es_ES' => ['name' => 'Spanish ES', 'htmlCode' => 'es'], 'sv_SE' => ['name' => 'Swedish SE', 'htmlCode' => 'sv'], 'th_TH' => ['name' => 'Thai', 'htmlCode' => 'th'], 'tr_TR' => ['name' => 'Turkish', 'htmlCode' => 'tr'], 'uk_UA' => ['name' => 'Ukrainian', 'htmlCode' => 'uk'], 'ko_KR' => ['name' => 'Korean (Korea)', 'htmlCode' => 'ko'], 'vi_VN' => ['name' => 'Vietnamese', 'htmlCode' => 'vi'], 'hr_HR' => ['name' => 'Croatian', 'htmlCode' => 'hr'], 'id_ID' => ['name' => 'Indonesian', 'htmlCode' => 'id'], 'fi_FI' => ['name' => 'Finnish', 'htmlCode' => 'fi'], 'lv_LV' => ['name' => 'Latvian (Latvia)', 'htmlCode' => 'lv'], 'sl_SI' => ['name' => 'Slovenian', 'htmlCode' => 'sl']]

Properties

$_activeLanguage  : string
$_activeLanguageFile  : string
$_i18n  : i18next

Methods

__construct()  : mixed
Construct Language class.
acceptFromHttp()  : false|array<string|int, mixed>
Attempt to get a language code from browser headers for setting an automatic language for guests.
get()  : string
Return a term in the currently active language.
getActiveLanguage()  : string
Return the current active language code.
getActiveLanguageFile()  : string
Return the path to the active language file.
getPluralForm()  : Closure|null
Get a closure that can be used to get a pluralised term in the currently active language, or null if the active language does not support pluralisation.
set()  : void
Set a term in specific file.

Constants

LANGUAGES

public array<string|int, mixed> LANGUAGES = ['zh_TW' => ['name' => 'Chinese', 'htmlCode' => 'zh-TW'], 'zh_CN' => ['name' => 'Chinese (Simplified)', 'htmlCode' => 'zh-CN'], 'cs_CZ' => ['name' => 'Czech', 'htmlCode' => 'cs'], 'da_DK' => ['name' => 'Danish', 'htmlCode' => 'da'], 'nl_NL' => ['name' => 'Dutch', 'htmlCode' => 'nl'], 'en_UK' => ['name' => 'English UK', 'htmlCode' => 'en'], 'en_US' => ['name' => 'English US', 'htmlCode' => 'en'], 'fa_IR' => ['name' => 'Persian (Iran)', 'htmlCode' => 'fa', 'rtl' => \true], 'fr_FR' => ['name' => 'French', 'htmlCode' => 'fr'], 'de_DE' => ['name' => 'German', 'htmlCode' => 'de'], 'el_GR' => ['name' => 'Greek', 'htmlCode' => 'el'], 'hu_HU' => ['name' => 'Hungarian', 'htmlCode' => 'hu'], 'it_IT' => ['name' => 'Italian', 'htmlCode' => 'it'], 'ja_JP' => ['name' => 'Japanese', 'htmlCode' => 'ja'], 'lt_LT' => ['name' => 'Lithuanian', 'htmlCode' => 'lt'], 'no_NO' => ['name' => 'Norwegian', 'htmlCode' => 'no'], 'pl_PL' => ['name' => 'Polish', 'htmlCode' => 'pl'], 'pt_BR' => ['name' => 'Portuguese', 'htmlCode' => 'pt'], 'ro_RO' => ['name' => 'Romanian', 'htmlCode' => 'ro'], 'ru_RU' => ['name' => 'Russian', 'htmlCode' => 'ru'], 'sk_SK' => ['name' => 'Slovak', 'htmlCode' => 'sk'], 'sq_AL' => ['name' => 'Albanian', 'htmlCode' => 'sq'], 'sr_RS' => ['name' => 'Serbian', 'htmlCode' => 'sr'], 'es_419' => ['name' => 'Spanish', 'htmlCode' => 'es'], 'es_ES' => ['name' => 'Spanish ES', 'htmlCode' => 'es'], 'sv_SE' => ['name' => 'Swedish SE', 'htmlCode' => 'sv'], 'th_TH' => ['name' => 'Thai', 'htmlCode' => 'th'], 'tr_TR' => ['name' => 'Turkish', 'htmlCode' => 'tr'], 'uk_UA' => ['name' => 'Ukrainian', 'htmlCode' => 'uk'], 'ko_KR' => ['name' => 'Korean (Korea)', 'htmlCode' => 'ko'], 'vi_VN' => ['name' => 'Vietnamese', 'htmlCode' => 'vi'], 'hr_HR' => ['name' => 'Croatian', 'htmlCode' => 'hr'], 'id_ID' => ['name' => 'Indonesian', 'htmlCode' => 'id'], 'fi_FI' => ['name' => 'Finnish', 'htmlCode' => 'fi'], 'lv_LV' => ['name' => 'Latvian (Latvia)', 'htmlCode' => 'lv'], 'sl_SI' => ['name' => 'Slovenian', 'htmlCode' => 'sl']]

Metadata about different languages available

Properties

$_activeLanguage

private string $_activeLanguage

Name of the language translation currently being used.

$_activeLanguageFile

private string $_activeLanguageFile

Path of the language JSON file currently being used.

$_i18n

private i18next $_i18n

Instance of i18next.

Methods

__construct()

Construct Language class.

public __construct([string $module = 'core' ][, string|null $active_language = null ]) : mixed
Parameters
$module : string = 'core'

Path to the custom language files to use, "core" by default for builtin language files.

$active_language : string|null = null

The translation to use.

Tags
throws
RuntimeException

If the language file cannot be found.

acceptFromHttp()

Attempt to get a language code from browser headers for setting an automatic language for guests.

public static acceptFromHttp(string $header) : false|array<string|int, mixed>
Parameters
$header : string

HTTP_ACCEPT_LANGUAGE header.

Return values
false|array<string|int, mixed>

The browsers preferred language and its name, or false if there is no valid preferred language.

get()

Return a term in the currently active language.

public get(string $section[, string|null $term = null ][, array<string|int, mixed> $variables = [] ]) : string
Parameters
$section : string

Section name.

$term : string|null = null

The term to translate.

$variables : array<string|int, mixed> = []

Any variables to pass through to the translation.

Return values
string

Translated phrase.

getActiveLanguage()

Return the current active language code.

public getActiveLanguage() : string
Return values
string

Active language name.

getActiveLanguageFile()

Return the path to the active language file.

public getActiveLanguageFile() : string
Return values
string

Active language path.

getPluralForm()

Get a closure that can be used to get a pluralised term in the currently active language, or null if the active language does not support pluralisation.

public getPluralForm() : Closure|null
Tags
@return

Closure(int, array)|null Closure or null if not available.

Return values
Closure|null

set()

Set a term in specific file.

public set(string $section, string $term, string $value) : void

Used for email message editing & dropdown name editing.

Parameters
$section : string

Name of file without extension to edit.

$term : string

Term which value to change.

$value : string

New value to set for term.


        
On this page

Search results