FacturaScripts

Translator

The Translator class manage all translations methods required for internationalization.

Table of Contents

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

Constants

Properties

$defaultLang

Default language.

private static string $defaultLang

$languages

Loaded languages.

private static array $languages = []

$missingStrings

List of strings without translation.

private static array $missingStrings = []

$translator

The Symfony translator.

private static Translator $translator

$usedStrings

List of used strings.

private static array $usedStrings = []

Methods

__construct()

Translator's constructor.

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

trans()

Translate the text into the default language.

public trans( $txt : string [, $parameters : array = [] ] ) : string
Parameters
$txt : string
$parameters : array = []
Return values
string

customTrans()

Translate the text into the selected language.

public customTrans( $langCode : string , $txt : string [, $parameters : array = [] ] ) : string
Parameters
$langCode : string
$txt : string
$parameters : array = []
Return values
string

getAvailableLanguages()

Returns an array with the languages with available translations.

public getAvailableLanguages( ) : array
Return values
array

getDefaultLang()

private getDefaultLang( ) : string
Return values
string

getLang()

Returns the language code in use.

public getLang( ) : string
Return values
string

getMissingStrings()

Returns the missing strings.

public getMissingStrings( ) : array
Return values
array

getTransKey()

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

getUsedStrings()

Returns the strings used.

public getUsedStrings( ) : array
Return values
array

setDefaultLang()

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

setLang()

Sets the language code in use.

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

findLang()

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

locateFiles()

Load the translation files following the priority system of FacturaScripts.

private locateFiles( $langCode : string ) : mixed

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

Parameters
$langCode : string
Return values
mixed

Search results