Jet\Translator_Dictionary
This class represents a translator dictionary, a collection of phrases. In normal use of translators, you won't encounter this class, because the entire compiler is used via a facade - the Jet\Translator (Jet\Tr) class. However, you need to know the class if you want to dig into the compiler properly and, for example, create your own backend.
Overview of methods
Method | Meaning of | public __construct( string $dictionary = '', Locale $locale = null ) |
The input parameters of the dictionary constructor can be the name of the dictionary and the locale to which the dictionary belongs. |
---|---|
public getLocale( ): Locale|null |
Returns the locale to which the dictionary belongs. |
public getName( ): string |
Returns the name of the dictionary. |
public getPhrases( ): Translator_Dictionary_Phrase[] |
Returns a list of phrases belonging to the given dictionary. |
public getTranslation( string $phrase_txt, bool $auto_append_unknown_phrase = true ): string |
Returns the translation of the given phrase. If the phrase is not in the dictionary and it is enabled by $auto_append_unknown_phrase, then it adds the phrase to the dictionary (as untranslated). If the phrase is not translated (even if it was already in the dictionary - but untranslated), it returns the original phrase and not its translation. |
public addPhrase( Translator_Dictionary_Phrase $phrase, bool $save_required = true ): void |
Adds a phrase instance to the dictionary. |
public saveRequired( ): bool |
Indication whether or not the dictionary needs to be saved. That is, whether or not the dictionary has been changed. |