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) —

clean()

Clean a string that may contain HTML special chars, single/double quotes, HTML entities, leading/trailing whitespace

Signature

  • 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.

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.

createAndListing()

Converts the given list of items into a listing (e.g. One, Two, and Three)

Signature

  • It accepts the following parameter(s):

    • $items (array) —

    • $language (string) —

  • It returns a string value.

createOrListing()

Converts the given list of items into a or listing (e.g. One, Two, or Three)

Signature

  • It accepts the following parameter(s):

    • $items (array) —

    • $language (string) —

  • It returns a string value.

getCurrentLanguage()

Signature

  • It returns a string value.

setCurrentLanguage()

Signature

  • It accepts the following parameter(s):

    • $language (string) —
  • It does not return anything or a mixed result.

getDefaultLanguage()

Signature

  • Returns: string — The default configured language.

getJavascriptTranslations()

Generate javascript translations array

Signature

  • It does not return anything or a mixed result.

addDirectory()

Add a directory containing translations.

Signature

  • 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.

Signature

  • It does not return anything or a mixed result.

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.