Re: [PATCH] ICU ResourceBundles for ext/unicode
| From: | l0t3k | Date: | Thu, 14 Dec 2006 15:02:49 +0000 |
| Subject: | Re: [PATCH] ICU ResourceBundles for ext/unicode | ||
| References: | 1 2 3 4 | Groups: | php.i18n |
| Request: | Send a blank email to php-i18n+get-1038@lists.php.net to get a copy of this message | ||
"Michael Wallner" <mike@php.net> wrote in message
news:458151D6.7020406@php.net...
> l0t3k wrote:
>> In ICU, resource bundles are cached for efficiency, but the cache is
>> per-process, and i seem to recall that the cache is not currently
>> flushed.
>> Additionally the key is the ICU locale id, so its impossible without
>> source
>> changes to make this work for user-created resources without collision in
>> shared hosting mode.
>
> Sounds like gettext() :) Could you elaborate?
its actually worse than gettext()..
suppose we have an Apache process handling PHP scripts in different web
apps. When a script from app1 requests the resource bundle for "en_US" for
example, ICU performs the search, and if found the internal resource bundle
structure is cached. There is a lot that happens behind the scenes, for
example : file system path search for "en_US", fall back to "en" if not
found, searching for locales in .dat files and falling back to .res file if
not found, etc. Caching here makes sense, but the problem is that the cache
is process wide, and the cache key used is simply the ISO locale id passed
to the constructor, even if a full path to the resource file was specified.
There is nothing to distinguish two resource bundles using the same name in
different web apps, so when app 2 requests a bundle for "en_US", the cache
returns the bundle from app 1. The cache is also not flushed until the
process dies.
Internally, the cache uses a ref count for resource bundles, and there is
code to do a flush (its private), so technically there is a way to handle
this, but not without hacking the ICU source. i did this about 2 years ago,
but the machine i used was stolen ;-(
clayton