FacturaScripts

Translator
in package

The Translator class manage all translations methods required for internationalization.

Tags
author

Carlos García Gómez [email protected]

deprecated

since FacturaScripts 2023.06

Table of Contents

FALLBACK_LANG  = 'es_ES'
$currentLang  : string
$defaultLang  : string
Default language.
$languages  : array<string|int, mixed>
Loaded languages.
$missingStrings  : array<string|int, mixed>
List of strings without translation.
$translator  : Translator
The Symfony translator.
$usedStrings  : array<string|int, mixed>
List of used strings.
__construct()  : mixed
Translator's constructor.
customTrans()  : string
Translate the text into the selected language.
getAvailableLanguages()  : array<string|int, mixed>
Returns an array with the languages with available translations.
getLang()  : string
Returns the language code in use.
getMissingStrings()  : array<string|int, mixed>
Returns the missing strings.
getUsedStrings()  : array<string|int, mixed>
Returns the strings used.
reload()  : void
setDefaultLang()  : mixed
setLang()  : mixed
Sets the language code in use.
trans()  : string
Translate the text into the default language.
findLang()  : string
getDefaultLang()  : string
getTransKey()  : string
locateFiles()  : mixed
Load the translation files following the priority system of FacturaScripts.

Constants

FALLBACK_LANG

public mixed FALLBACK_LANG = 'es_ES'

Properties

$defaultLang

Default language.

private static string $defaultLang

$languages

Loaded languages.

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

$missingStrings

List of strings without translation.

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

$translator

The Symfony translator.

private static Translator $translator

$usedStrings

List of used strings.

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

Methods

__construct()

Translator's constructor.

public __construct([string $langCode = '' ]) : mixed
Parameters
$langCode : string = ''
Return values
mixed

customTrans()

Translate the text into the selected language.

public customTrans(string $langCode, string $txt[, array<string|int, mixed> $parameters = [] ]) : string
Parameters
$langCode : string
$txt : string
$parameters : array<string|int, mixed> = []
Return values
string

getAvailableLanguages()

Returns an array with the languages with available translations.

public getAvailableLanguages() : array<string|int, mixed>
Return values
array<string|int, mixed>

getLang()

Returns the language code in use.

public getLang() : string
Return values
string

getMissingStrings()

Returns the missing strings.

public getMissingStrings() : array<string|int, mixed>
Return values
array<string|int, mixed>

getUsedStrings()

Returns the strings used.

public getUsedStrings() : array<string|int, mixed>
Return values
array<string|int, mixed>

reload()

public static reload() : void
Return values
void

setDefaultLang()

public setDefaultLang(string $langCode) : mixed
Parameters
$langCode : string
Return values
mixed

setLang()

Sets the language code in use.

public setLang(string $langCode) : mixed
Parameters
$langCode : string
Return values
mixed

trans()

Translate the text into the default language.

public trans(string|null $txt[, array<string|int, mixed> $parameters = [] ]) : string
Parameters
$txt : string|null
$parameters : array<string|int, mixed> = []
Return values
string

findLang()

private findLang(string $langCode) : string
Parameters
$langCode : string
Return values
string

getDefaultLang()

private getDefaultLang() : string
Return values
string

getTransKey()

private getTransKey(string $txt) : string
Parameters
$txt : string
Return values
string

locateFiles()

Load the translation files following the priority system of FacturaScripts.

private locateFiles(string $langCode) : mixed

In this case, the translator must be provided with the routes in reverse order.

Parameters
$langCode : string
Return values
mixed

Search results