|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
$translate->isAvailable() always true?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 |
|
|
Re: $translate->isAvailable() always true?Hy Snoopy,
I am getting false when I recode your example with usage of my own files. All works ok and I am gettings false which means that the language 'xx' does not exist in this adapter. Maybe you've made a problem by checking or you've set an option before initialisation. It would be good to have a complete working example for your problem. Just to mention: isAvailable checks if a language is available or not as you can read in the API doc and in the manual. Regarding to the manual and the API doc, you should use isTranslated() if you want to check if a message id is translatable or not. Greetings Thomas Weidner, I18N Team Leader http://www.thomasweidner.com ----- Original Message ----- From: "PoolSnoopy" <tlatzelsberger@...> To: <fw-i18n@...> Sent: Friday, March 21, 2008 1:56 PM Subject: [fw-i18n] $translate->isAvailable() always true? > > 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 > -- > View this message in context: > http://www.nabble.com/%24translate-%3EisAvailable%28%29-always-true--tp16197708s16154p16197708.html > Sent from the Zend I18N/Locale mailing list archive at Nabble.com. |
|
|
Re: $translate->isAvailable() always true?Hi Thomas,
thank you very much for your quick response. I'm not sure what I did wrong but this code now 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'); } it now automatically selects fitting languages and chooses 'en' if the language is not known. regards, PoolSnoopy
|
| Free Forum Powered by Nabble | Forum Help |