Piwik\Translation\

Translator

Translates messages.

Methods

The class defines the following methods:

__construct()

Signature

  • It accepts the following parameter(s):

    • $loader (Piwik\Translation\Loader\LoaderInterface) —

    • $directories (array) —

translate()

Returns an internationalized string using a translation ID.

If a translation cannot be found for the ID, the ID is returned.

Signature

  • 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()

Signature

  • It returns a string value.

setCurrentLanguage()

Signature

  • It accepts the following parameter(s):

    • $language (string) —
  • It does not return anything.

getDefaultLanguage()

Signature

  • Returns: string — The default configured language.

getJavascriptTranslations()

Generate javascript translations array

Signature

  • It does not return anything.

addDirectory()

Add a directory containing translations.

Signature

  • It accepts the following parameter(s):

    • $directory (string) —
  • It does not return anything.

reset()

Should be used by tests only, and this method should eventually be removed.

Signature

  • It does not return anything.

findTranslationKeyForTranslation()

Signature

  • It accepts the following parameter(s):

    • $translation (string) —
  • Returns: null|string

getAllTranslations()

Returns all the translation messages loaded.

Signature

  • It returns a array value.