|
|||
|
Dear fellows,
I have difficulties using or understanding Zend_Translate. Imagine the following code: try { Zend_Registry::get('translation'); } catch (Zend_Exception $e) { $translate = new Zend_Translate('csv', '../translation/english.csv', 'en'); $translate->addTranslation('../translation/german.csv', 'de'); $translate->addTranslation('../translation/english_US.csv', 'en_US'); Zend_Registry::set('translation', $translate); } .... $translate = Zend_Registry::get('translation'); then I would expect that $translate->isAvailable('xx') to be false. but it is true. so how can I check whether a translation for the desired language is here or not? any help highly appreciated Last edited by PoolSnoopy : 03-21-2008 at 02:34 PM. Reason: SOLVED |
|
|||
|
I'm not sure what was wrong before, but now this code works perfectly for me:
$locale = new Zend_Locale(); $translate = new Zend_Translate('csv', '../translation/english.csv', 'en'); $translate->addTranslation('../translation/german.csv', 'de'); $translate->addTranslation('../translation/english_US.csv', 'en_US'); if (! $translate->isAvailable($locale->getLanguage())) { $translate->setLocale('en'); } else { $translate->setLocale('auto'); } Zend_Translate is now picking the right languages according to browser preferences and sticking to 'en' if an unknown or untranslated language is requested. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|