Hi,
I just ran into the same thing. Zend_Translate under ZF 1.7 now raises
these notices if you call Zend_Translate::setLocale($locale) with a
$locale that has no translation data added. You can suppress these
notices by passing the option 'disableNotices'=true when instantiating
Zend_Translate.
But I don't think that a notice makes sense in this case. As far as I
understand the translation engine of ZF, if no translation is found for
the requested key, Zend_Translate will always return the key itself. So,
for example, you would write your application output strings in english
and never worry about wrong translations beeing displayed if the
language requested by the user is english. To tell the application that
english is an accepted locale, I would always add the 'en' locale with
an empty set of translations anyway, to benefit from methods like
Zend_Translate::isAvailabe('en') and the like, and so that I may add
translations into the english translation table later on if necessary
(for larger texts or something). Now with notices raised on empty
translation tables, the unpleasant feeling remains to do something wrong
or at least unintended there. And imho suppressing the notices is
usually not a good idea either, because you never know what useful hints
you might miss this way.
Please correct me if I am wrong, but I think this notice is not really
needed. Or, more likely, I'm not getting the point.
Greetings,
Florian
Robert Castley schrieb:
Hi,
I thought I would take the Preview Release for a spin. But I
immediately hit an issue with Zend_Translate.
My error message is:
*Notice*: No translation for the language 'en_GB' available. in
*/Users/rwc/Sites/ZendFramework-SVN/library/Zend/Translate/Adapter.php*
on line *301*
**
I have a language plugin I call in my bootstrap. This works perfectly
under 1.6.3, here is the code:
<?php
class Magik_Plugin_Language extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$locale = new Zend_Locale();
$frontendOptions = array(
'automatic_cleaning_factor' => 0,
'cache_id_prefix' => 'Magik_',
'lifetime' => null
);
$backendOptions = array(
'cache_dir' => CACHE
);
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions,
$backendOptions);
Zend_Translate::setCache($cache);
$options = array('scan' => Zend_Translate::LOCALE_DIRECTORY);
$translate = new Zend_Translate('csv', 'languages', 'auto',
$options);
if ($translate->isAvailable($locale->getLanguage()) != 1) {
$locale->setLocale('en');
}
$translate->setLocale($locale->getLanguage());
setcookie('lang', $locale->getLanguage(), null, '/');
Zend_Registry::set('locale', $locale->getLanguage());
Zend_Registry::set('Zend_Translate', $translate);
}
}
The other interesting thing to note is that in my cache directory with
1.6.3 I get two files, but with the PR I get loads! One for each lang
file and one for each file under my CVS directory (repository,
entries, root etc).
I had a look at the docs online and there was some mention of Zend
Locale compatibility mode which I have set to false, but still no luck.
Any pointers?
Cheers,
- Robert
________________________________________________________________________
This email has been scanned for all known viruses by the MessageLabs
Email Security Service and the Macro 4 plc internal virus protection
system.
________________________________________________________________________