This decorator is very useful when you want to provide a fallback language for empty strings. It is stackable, so you can have more than one default language.
$tr = new Translation2($driver, $dbinfo, $params);
//set English as the main language
$tr->setLang('en');
//set Italian as the first fallback language
$tr =& $tr->getDecorator('Lang');
$tr->setOption('fallbackLang', 'it');
//set Spanish as the second fallback language
$tr =& $tr->getDecorator('Lang');
$tr->setOption('fallbackLang', 'es'); |
Translation2_Decorator_Lang
Translation2_Decorator_Lang Inherited Methods
Table 34-1. Inherited from Translation2_Decorator
| Method Name | Summary |
|---|---|
| Constructor Translation2_Decorator::Translation2_Decorator() | Constructor |
| Translation2_Decorator::get() | Get translated string |
| Translation2_Decorator::getDecorator() | Return an instance of a decorator |
| Translation2_Decorator::getLang() | get lang info |
| Translation2_Decorator::getLangs() | get langs |
| Translation2_Decorator::getPage() | Same as getRawPage, but resort to fallback language and replace parameters when needed |
| Translation2_Decorator::getRawPage() | Get the array of strings in a page |
| Translation2_Decorator::setLang() | Set default lang |
| Translation2_Decorator::setOption() | set Decorator option |
| Translation2_Decorator::setOptions() | set Decorator options |
| Translation2_Decorator::setPageID() | Set default page |
| Translation2_Decorator::setParams() | Set parameters for next string |
| Translation2_Decorator::translate() | Get translated string |