Elgg  Version 3.0
Public Member Functions | List of all members
Elgg\I18n\MessageTranslator Class Reference

WARNING: API IN FLUX. More...

Inheritance diagram for Elgg\I18n\MessageTranslator:
Elgg\I18n\TranslatorInterface

Public Member Functions

 __construct (Locale $defaultLocale, MessageBundle $messages)
 Constructor. More...
 
 translate ($key, array $args=[], Locale $locale=null)
 Given a message key, returns a best-effort translated string.If the translator doesn't know how to translate into the specified locale, it can try translating into a related or similar locale (e.g. en-US => en).If no locale is specified, or if no translation can be found for the specified locale, the translator may choose to fall back to some other language(s).It should never throw exceptions, since lack of translation should never be cause to bring down an app or cancel a request. However, implementations may log warnings to alert admins that requested language strings are missing.
Parameters
string$keyA key identifying the message to translate.
array$argsAn array of arguments with which to format the message.
Locale$localeOptionally, the standard language code (defaults to site/user default, then English)
Returns
string The final, best-effort translation.
More...
 

Detailed Description

WARNING: API IN FLUX.

DO NOT USE DIRECTLY.

Definition at line 11 of file MessageTranslator.php.

Constructor & Destructor Documentation

Elgg\I18n\MessageTranslator::__construct ( Locale  $defaultLocale,
MessageBundle  $messages 
)

Constructor.

Parameters
Locale$defaultLocaleThe fallback locale
MessageBundle$messagesMessages that this translator is aware of

Definition at line 26 of file MessageTranslator.php.

Member Function Documentation

Elgg\I18n\MessageTranslator::translate (   $key,
array  $args = [],
Locale  $locale = null 
)

Given a message key, returns a best-effort translated string.If the translator doesn't know how to translate into the specified locale, it can try translating into a related or similar locale (e.g. en-US => en).If no locale is specified, or if no translation can be found for the specified locale, the translator may choose to fall back to some other language(s).It should never throw exceptions, since lack of translation should never be cause to bring down an app or cancel a request. However, implementations may log warnings to alert admins that requested language strings are missing.

Parameters
string$keyA key identifying the message to translate.
array$argsAn array of arguments with which to format the message.
Locale$localeOptionally, the standard language code (defaults to site/user default, then English)
Returns
string The final, best-effort translation.

Implements Elgg\I18n\TranslatorInterface.

Definition at line 34 of file MessageTranslator.php.


The documentation for this class was generated from the following file: