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
FALLBACK_LANG
mixed
$FALLBACK_LANG
= 'es_ES'
Properties
$currentLang
private
string
$currentLang
$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
mixedtrans()
Translate the text into the default language.
public
trans(
$txt :
string
[, $parameters :
array
= [] ]
)
: string
Parameters
- $txt : string
- $parameters : array = []
Return values
stringcustomTrans()
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
stringgetAvailableLanguages()
Returns an array with the languages with available translations.
public
getAvailableLanguages(
)
: array
Return values
arraygetDefaultLang()
private
getDefaultLang(
)
: string
Return values
stringgetLang()
Returns the language code in use.
public
getLang(
)
: string
Return values
stringgetMissingStrings()
Returns the missing strings.
public
getMissingStrings(
)
: array
Return values
arraygetTransKey()
private
getTransKey(
$txt :
string
)
: string
Parameters
- $txt : string
Return values
stringgetUsedStrings()
Returns the strings used.
public
getUsedStrings(
)
: array
Return values
arraysetDefaultLang()
public
setDefaultLang(
$langCode :
string
)
: mixed
Parameters
- $langCode : string
Return values
mixedsetLang()
Sets the language code in use.
public
setLang(
$langCode :
string
)
: mixed
Parameters
- $langCode : string
Return values
mixedfindLang()
private
findLang(
$langCode :
string
)
: string
Parameters
- $langCode : string
Return values
stringlocateFiles()
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