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.createAndListing()
— Converts the given list of items into a listing (e.g.createOrListing()
— Converts the given list of items into a or listing (e.g.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
|null
) —
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
.
createAndListing()
Converts the given list of items into a listing (e.g. One, Two, and Three)
It accepts the following parameter(s):
$items
(array
) —
$language
(string
|null
) —
It returns a string
value.
createOrListing()
Converts the given list of items into a or listing (e.g. One, Two, or Three)
It accepts the following parameter(s):
$items
(array
) —
$language
(string
|null
) —
It returns a string
value.
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.