Piwik\Translation\
Translates messages.
The class defines the following methods:
__construct()
clean()
— Clean a string that may contain HTML special chars, single/double quotes, HTML entities, leading/trailing whitespacetranslate()
— Returns an internationalized string using a translation ID.getCurrentLanguage()
setCurrentLanguage()
getDefaultLanguage()
getJavascriptTranslations()
— Generate javascript translations arrayaddDirectory()
— Add a directory containing translations.reset()
— Should be used by tests only, and this method should eventually be removed.findTranslationKeyForTranslation()
getAllTranslations()
— Returns all the translation messages loaded.__construct()
It accepts the following parameter(s):
$loader
(Piwik\Translation\Loader\LoaderInterface
) —
$directories
(array
) —
clean()
Clean a string that may contain HTML special chars, single/double quotes, HTML entities, leading/trailing whitespace
It accepts the following parameter(s):
$s
(string
) —It returns a string
value.
translate()
Returns an internationalized string using a translation ID. If a translation cannot be found for the ID, the ID is returned.
It accepts the following parameter(s):
$translationId
(string
) —
Translation ID, eg, General_Date
.$args
(array
|string
|int
) —
sprintf
arguments to be applied to the internationalized string.$language
(string
|null
) —
Optionally force the language.Returns: string
—
The translated string or $translationId
.
getCurrentLanguage()
string
value.setCurrentLanguage()
It accepts the following parameter(s):
$language
(string
) —It does not return anything or a mixed result.
getDefaultLanguage()
string
—
The default configured language.getJavascriptTranslations()
Generate javascript translations array
addDirectory()
Add a directory containing translations.
It accepts the following parameter(s):
$directory
(string
) —It does not return anything or a mixed result.
reset()
Should be used by tests only, and this method should eventually be removed.
findTranslationKeyForTranslation()
It accepts the following parameter(s):
$translation
(string
) —Returns: null
|string
—
getAllTranslations()
Returns all the translation messages loaded.
array
value.