I18N compatibility mode
- Posted by thomasw at 23:03:34 // //
- Announcements, File Transfer, Locale
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
Application wide locale in Zend Framework
- Posted by thomasw at 00:08:38 // //
- Announcements, I18N, Locale
Hy interested ones,
a new feature has been added within Zend Framework. it now supports the usage of an application wide locale. Anyone who is using I18N classes in his application will love this feature.
So what’s all about this new feature…. let’s look into details. Until Zend Framework 1.5 when you wanted to use several I18N aware classes you had to set the locale you wanted to use within all classes. This looked like this:
$locale = new Zend_Locale('en_US');
$date1 = new Zend_Date($locale);
$date2 = new Zend_Date($locale);
$currency = new Zend_Currency($locale);
When you use only one or two instances there is not much difference. But the more instances you use the more work you would have with the syntax. Looking at this in detail I thought why not simply set the locale once within your bootstrap and let the framework do the rest.
The solution was the usage of the registry. So let’s look at the same example and the difference in the usage:
$locale = new Zend_Locale('en_US');
Zend_Registry::set('Zend_Locale', $locale);
...
$date1 = new Zend_Date();
$date2 = new Zend_Date();
$currency = new Zend_Currency();
As you can notice now, you can forget about the locale as it’s automatically taken from the registry. This is a small and simple solution but it will solve you several headache. You can use this feature within the actual trunk or you have to wait until 1.7 is released.
Have fun with it, anyway.
Greetings,
Thomas Weidner, I18N Team Leader, Zend Framework
