PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Internationalization » I18Nv2 » Bug #5556

I18Nv2.createLocale makes system-wide changes

Details

Submitted2005-09-29 11:13 UTC
Fromt dot nickl at exse dot de
StatusBogus
PackageI18Nv2
PHP VersionIrrelevant
OSUnix
Roadmaps(Not assigned)

Comments

[2005-09-29 11:13 UTC] t dot nickl at exse dot de

Description:
------------
$num= 20.05;
$locale = I18Nv2::createLocale('de_DE');
echo $locale->formatNumber($num);
//...
echo "insert into bla set x='".$num."';";

Prints:

20,05insert into bla set x='20,05';

Okay, why does .createLocale doesen't just create a locale to work with, but changes the whole system (e.g. subsequent db-queries will fail because they need default locale) ?
If you must use setLocale(), then you could just work around by resetting the locale after the work of e.g. .formatNumber() is done.
I as class-user should not be responsible to remember/restore any locale-settings.
That's the whole point of .createLocale, to be able to work with more locales. Or am I wrong?

It's essentially the
"Bug #3494 I18Nv2's modifies the global locale"
, but I can't submit messages there.

Test script:
---------------
$num= 20.05;
$locale = I18Nv2::createLocale('de_DE');
echo $locale->formatNumber($num);
//...
echo "insert into bla set x='".$num."';";

Expected result:
----------------
20,05insert into bla set x='20.05';

Actual result:
--------------
20,05insert into bla set x='20,05';

[2005-09-29 14:35 UTC] t dot nickl at exse dot de

Thank you for pointing that out.
Now that this Framework has no use for me (and I doubt to anyone else), I can continue to use number_format() / roll my own.