Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-21-2008, 11:25 AM
Junior Member
 
Join Date: Mar 2008
Posts: 2
Lightbulb [SOLVED] $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

Last edited by PoolSnoopy : 03-21-2008 at 02:34 PM. Reason: SOLVED
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-21-2008, 02:29 PM
Junior Member
 
Join Date: Mar 2008
Posts: 2
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:03 PM.