Saturday
3
April
2010

Using countries for localization

Hy interested ones,

I did not find a correct heading for what I want to describe you today.
But there is a new feature which has been implemented by me so let’s see some details:

Most of you are already using Zend_Locale. Give a language and get a locale in return.
You used this for translation, currency, date or other purposes.

Now the idea for this new feature is simple… why should a user not be able to give a country instead of a language to get a locale in return. For example “austria”… when I give “AT” then I could expect that the locale “de_AT” is being used.

And exactly this feature is available as with ZF 1.10.4 or ZF 2.0.

Of course there are much other usecases where this feature could be used.
For example, when your user selects a flag which represents his country. Then you could use only the region/country to get a locale with language in return.

$locale = new Zend_Locale('US');
// returns "en_US"

Or think of currencies. You could just give the country and get the currency for this country.

$currency = new Zend_Currency(array('locale' => 'AT'));
// uses "EUR" which is the currency for the locale "de_AT"

Generally you can use this feature everywhere within the whole framework where you used only languages or locales before.

But of course there is one thing to note:
You have to uppercase countries when you want to use them. The reason is that there are countries which are equal to languages. For example “om”… you could mean the country Oman and expect “ar_OM” as locale, or you could mean the language “Oromo” and expect “or_KE” as locale.

When you find this feature useful, feel free to use it yourself. :-)

Greetings
Thomas Weidner
I18N Team Leader, Zend Framework

Zend Framework Advisory Board Member
Zend Certified Engineer for Zend Framework

Back to top
Wednesday
20
May
2009

New CLDR implemented

Today I updated the locale database to the latest release (CLDR 1.7) which is available since 2 weeks by unicode. It provides several corrections for existing locale informations.

Corrected currency signs, additional locales, additional timezone data and much more. This update changes about 5MB of data and is only provided within trunk. It will be available to ZF with the next minor release 1.9.

Additional new informations are provided by CLDR like
* postalcodes
* phonecodes
* locale upgrading
and several more.

This new informations will be integrated within ZF soon.
See http://framework.zend.com/issues/browse/ZF-6681 for informations about new features to be integrated.

Please note, that like in past Zend (and me) is not allowed to provide changed CLDR files. When you find a error you have to possibilities.

* Anyone who finds an error can keep it private
* Or feel free to write a issue to unicode (unicode.org/cldr) about incorrect informations

I hope you find it usefull

Greetings
Thomas Weidner
I18N Team Leader, Zend Framework

Zend Framework Advisory Board Member
Zend Certified Engineer for Zend Framework

Back to top
Saturday
18
October
2008

I18N compatibility mode

Hy interested ones,

to prevent problems when you want to change from Zend Framework 1.6 to 1.7 I added a so called “compatibility mode”.

It’s simply a static variable which changes between old API and new API behaviour.
Within release 1.7 the old behaviour is per default active (true).
So your old code will still work with this settings but it will throw a user warning.

You can change this mode by simply setting it to false in your bootstrap.

Zend_Locale::$compatibilityMode = false;

This will no longer return user warnings, but could be in a position where you have to change your code to work again. See the migration chapter of Zend_Locale for details.

The changes include:
* changes on isLocale which now only returns boolean
* changes on getDefault which returns only the framework default
* changes on calling information methods which were made static
* changes on returned locales which do no longer degrade to other types

In 75% of the cases you will not have to change anything. But you should properly check this.

With the next release 1.8 we will change the compatibility mode to false per default, and with 1.9 we will delete it completly so only the new API behaviour is active.

Greetings
Thomas Weidner
I18N Team Leader, Zend Framework

Zend Framework Advisory Board Member
Zend Certified Engineer for Zend Framework

Back to top