The original message was not delivered to the mailinglist so I can only
answer to this one...
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.
The point is, that you are trying to set a language for which no translation
exists wether for the wished locale nor for the degraded locale.
This would mean that in this case only the key is returned. Often users do
not write out complete centences as described in the manual but simple
string keys like "mykey1".
Even if this is sometimes wished, it is no good way of translation...
because we do not translate anything in this case.
And exactly for this reason this notice has been added.
Still, when you think that having the key displayed as translated message is
ok for you, you can disable this notice with the mentioned option.
The thing is simply that not in every case it's really usefull to have the
key returned.
This notice is simply nothing more than a "Beware... it is possible that
what you requested is not what you wanted"
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
----- Original Message -----
From: "Florian Sonnenburg" <[EMAIL PROTECTED]>
To: "Robert Castley" <[EMAIL PROTECTED]>;
<fw-general@lists.zend.com>
Sent: Wednesday, November 19, 2008 6:40 PM
Subject: Re: [fw-general] Zend_Translate and 1.7.0PR issue/question
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.
________________________________________________________________________