ZF-6612: Zend_Translate and automatic locale detection with directory scanning

Issue Type: Improvement Created: 2009-05-11T17:36:08.000+0000 Last Updated: 2009-05-11T23:19:12.000+0000 Status: Resolved Fix version(s): - 1.8.1 (12/May/09)

Reporter: Edoardo Serra (eserra) Assignee: Thomas Weidner (thomas) Tags: - Zend_Translate

Related issues: Attachments:


I have the following code:

<pre class="highlight">
$locale = new Zend_Locale(Zend_Locale::BROWSER);

$translate = new Zend_Translate(
    array('scan' => Zend_Translate::LOCALE_DIRECTORY));
// setting the right locale
if ($translate->isAvailable($locale->getLanguage())) {
} else {

In my $path I have it and fr subdirectories.

When initializing Zend_Translate, an implicit setLocale is called with the user's preferred locale according to his browser's preferences. Here is the error message I get if my preferred language is 'en': {quote} Notice: The language 'en_US' has to be added before it can be used. in /home/eserra/ on line 317 Notice: No translation for the language 'en' available. in /home/eserra/ on line 330 {quote}

I think that, in case of scan option the automatic locale detection should be disabled. At the end of the scan process, if the locale coming from user's browser is found it could be set, otherwise I think that no notices should be generated, this allow the developer to provide fallback code as I did in my snippet.

My .02 $


Posted by Thomas Weidner (thomas) on 2009-05-11T23:18:30.000+0000

Or you simply disable the notices when you know that you don't need them. See the 'disableNotices' option within the manual.

That's how the manual describes this usecase.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.