Documentation

Language
in package

Language basic class.

Tags
copyright

YetiForce Sp. z o.o

license

YetiForce Public License 4.0 (licenses/LicenseEN.txt or yetiforce.com)

author

Mariusz Krzaczkowski m.krzaczkowski@yetiforce.com

author

Adrian Koń a.kon@yetiforce.com

author

Radosław Skrzypczak r.skrzypczak@yetiforce.com

Table of Contents

DEFAULT_LANG  = 'en-US'
Default language code.
FORMAT  = 'json'
Language files format.
LANG_TYPE  = ['php', 'js']
Allowed types of language variables.
$customDirectory  : string
Custom language directory.
$languageContainer  : array<string|int, mixed>
Contains module language translations.
$language  : string
$pluralizeCache  : array<string|int, mixed>
Pluralize cache.
$shortLanguage  : bool|string
Short current language.
$temporaryLanguage  : string
clearTemporaryLanguage()  : string
Clear temporary language.
getAll()  : array<string|int, mixed>
Function return languages data.
getDisplayName()  : string
Get display language name.
getFromFile()  : array<string|int, mixed>
Get language from file.
getJsStrings()  : array<string|int, string>
Functions that gets translated string.
getLangInfo()  : array<string|int, mixed>
Function return languange data.
getLanguage()  : string
Function that returns current language.
getLanguageLabel()  : bool|string
Function to get the label name of the Langauge package.
getLanguageRegion()  : string
Function that returns region for language prefix.
getLanguageTag()  : string
Get IETF language tag.
getRegion()  : mixed
Get region from language prefix.
getShortLanguageName()  : string
Function that returns current language short name.
getSingularModuleName()  : string
Get singular module name.
getTranslateHelpInfo()  : string
Functions get translate help info.
initLocale()  : mixed
Set locale information.
loadLanguageFile()  : mixed
Load language file.
setTemporaryLanguage()  : mixed
Set temporary language.
translate()  : string
Functions that gets translated string.
translateArgs()  : string
Functions that gets translated string by $args.
translateEncodeHtml()  : string
Functions that gets translated string with encoding html.
translatePluralized()  : string
Functions that gets pluralized translated string.
translateSingleMod()  : string
Translation function based on only one file.
translateSingularModuleName()  : string
Translate singular module name.
translationModify()  : mixed
Translation modification.
getPluralized()  : string
This function returns the modified keycode to match the plural form(s) of a given language and a given count with the same pattern used by i18next JS library Global patterns for keycode are as below : - No plural form : only one non modified key is needed :) - 2 forms : unmodified key for singular values and 'key_PLURAL' for plural values - 3 or more forms : key_X with X indented for each plural form.

Constants

DEFAULT_LANG

Default language code.

public mixed DEFAULT_LANG = 'en-US'

FORMAT

Language files format.

public mixed FORMAT = 'json'

LANG_TYPE

Allowed types of language variables.

public mixed LANG_TYPE = ['php', 'js']

Properties

$customDirectory

Custom language directory.

public static string $customDirectory = 'custom'

$languageContainer

Contains module language translations.

protected static array<string|int, mixed> $languageContainer

$language

private static string $language = ''

Current language.

$pluralizeCache

Pluralize cache.

private static array<string|int, mixed> $pluralizeCache = []

$shortLanguage

Short current language.

private static bool|string $shortLanguage = false

$temporaryLanguage

private static string $temporaryLanguage = ''

Temporary language.

Methods

clearTemporaryLanguage()

Clear temporary language.

public static clearTemporaryLanguage() : string
Return values
string

getAll()

Function return languages data.

public static getAll([bool $active = true ][, bool $allData = false ]) : array<string|int, mixed>
Parameters
$active : bool = true
$allData : bool = false
Return values
array<string|int, mixed>

getDisplayName()

Get display language name.

public static getDisplayName(string $prefix) : string
Parameters
$prefix : string
Return values
string

getFromFile()

Get language from file.

public static getFromFile(string $moduleName, string $language) : array<string|int, mixed>
Parameters
$moduleName : string
$language : string
Return values
array<string|int, mixed>

getJsStrings()

Functions that gets translated string.

public static getJsStrings(string $moduleName) : array<string|int, string>
Parameters
$moduleName : string
Return values
array<string|int, string>

getLangInfo()

Function return languange data.

public static getLangInfo(string $prefix) : array<string|int, mixed>
Parameters
$prefix : string
Return values
array<string|int, mixed>

getLanguage()

Function that returns current language.

public static getLanguage() : string
Return values
string

getLanguageLabel()

Function to get the label name of the Langauge package.

public static getLanguageLabel(string $prefix) : bool|string
Parameters
$prefix : string
Return values
bool|string

getLanguageRegion()

Function that returns region for language prefix.

public static getLanguageRegion([string|null $lang = null ]) : string
Parameters
$lang : string|null = null
Return values
string

getRegion()

Get region from language prefix.

public static getRegion(string $prefix) : mixed
Parameters
$prefix : string
Return values
mixed

getShortLanguageName()

Function that returns current language short name.

public static getShortLanguageName() : string
Return values
string

getSingularModuleName()

Get singular module name.

public static getSingularModuleName(string $moduleName) : string
Parameters
$moduleName : string
Return values
string

getTranslateHelpInfo()

Functions get translate help info.

public static getTranslateHelpInfo(Vtiger_Field_Model $fieldModel, string $view) : string
Parameters
$fieldModel : Vtiger_Field_Model
$view : string
Return values
string

initLocale()

Set locale information.

public static initLocale() : mixed
Return values
mixed

loadLanguageFile()

Load language file.

public static loadLanguageFile(string $language[, string $moduleName = '_Base' ]) : mixed
Parameters
$language : string
$moduleName : string = '_Base'
Return values
mixed

setTemporaryLanguage()

Set temporary language.

public static setTemporaryLanguage(string $language) : mixed
Parameters
$language : string
Return values
mixed

translate()

Functions that gets translated string.

public static translate(string $key[, string $moduleName = '_Base' ][, bool|string $language = false ][, mixed $encode = true ]) : string
Parameters
$key : string
  • string which need to be translated
$moduleName : string = '_Base'
  • module scope in which the translation need to be check
$language : bool|string = false
  • language of translation
$encode : mixed = true
Return values
string
  • translated string

translateArgs()

Functions that gets translated string by $args.

public static translateArgs(string $key[, string $moduleName = '_Base' ]) : string
Parameters
$key : string
  • string which need to be translated
$moduleName : string = '_Base'
  • module scope in which the translation need to be check
Return values
string
  • translated string

translateEncodeHtml()

Functions that gets translated string with encoding html.

public static translateEncodeHtml(string $key[, string $moduleName = '_Base' ][, mixed $currentLanguage = false ]) : string
Parameters
$key : string
  • string which need to be translated
$moduleName : string = '_Base'
  • module scope in which the translation need to be check
$currentLanguage : mixed = false
Return values
string
  • translated string with encoding html

translatePluralized()

Functions that gets pluralized translated string.

public static translatePluralized(string $key, string $moduleName, int $count) : string
Parameters
$key : string

String which need to be translated

$moduleName : string

Module scope in which the translation need to be check

$count : int

Quantityu for plural determination

Tags
see
https://www.i18next.com/plurals.html
see
http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html?id=l10n/pluralforms#pluralforms-list
Return values
string

translateSingleMod()

Translation function based on only one file.

public static translateSingleMod(string $key[, string $moduleName = '_Base' ][, bool|string $language = false ]) : string
Parameters
$key : string
$moduleName : string = '_Base'
$language : bool|string = false
Return values
string

translateSingularModuleName()

Translate singular module name.

public static translateSingularModuleName(string $moduleName) : string
Parameters
$moduleName : string
Return values
string

translationModify()

Translation modification.

public static translationModify(string $language, string $fileName, string $type, string $label, string $translation[, bool $remove = false ]) : mixed
Parameters
$language : string
$fileName : string
$type : string
$label : string
$translation : string
$remove : bool = false
Tags
throws
AppException
Return values
mixed

getPluralized()

This function returns the modified keycode to match the plural form(s) of a given language and a given count with the same pattern used by i18next JS library Global patterns for keycode are as below : - No plural form : only one non modified key is needed :) - 2 forms : unmodified key for singular values and 'key_PLURAL' for plural values - 3 or more forms : key_X with X indented for each plural form.

private static getPluralized(float $count) : string
Parameters
$count : float

Quantityu for plural determination

Tags
see
https://www.i18next.com/plurals.html

for some examples

see
http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html?id=l10n/pluralforms

for whole plural rules used by getText

Return values
string

Pluralized key to look for


        

Search results