Hy Shekar,

> Please correct me if I'm wrong as I haven't gone 
> through the Zend_Locale source as yet:

Ok...

Here comes the correction ;-)

> foreach($list as $language => $content) {
>   $lang = new Zend_Locale($language);
>   print "\n<br>[".$language."] ".$lang->getLanguageDisplay($language);
> }
> In the above chunk, the $language argument
> is passed to both - the construct as well as 
> the getLanguageDisplay methods. Can't the 
> first locale object already created outside the 
> loop ( for the list) return the language display 
> for any language from inside the loop? Is it 
> necessary to create the locale object for each 
> language (inside the loop)?

Yes, it is necessary to have an new locale object.
getLanguageDisplay displays a localized string for a language.

So when you have set the english locale (Zend_Locale('en'); for example you 
will get the following.

$locale->getLanguageDisplay('de'); // returns german
$locale->getLanguageDisplay('en'); // returns english

But when you have your locale set to Zend_Locale('de'); you will get

$locale->getLanguageDisplay('de'); // returns deutsch
$locale->getLanguageDisplay('en'); // returns englisch

As you see getLanguageDisplay shows a description for a language in the set 
locale.

So when you want to know how a language is written in its own language
you MUST change the locale to the wished language before you can use
getLanguageDisplay to return the proper string.

You can also use the function setLocale() instead of creating a new object.
Which is maybe the better approach.

But I think it's not necessary to have an optional set locale within this 
function.
Better to manualy set a new locale so the user must KNOW what he wants to do.

Greetings
Thomas
(I18N Author and Team Leader)

Reply via email to