Re: Intl ResourceBundle Class: No Fallback When Using Iteration

Joel Sahleen <[email protected]> Tue, 17 Aug 2010 04:13:15 -0700
Newsgroups gmane.comp.php.internationalization
Message-ID <C88FCAEB.2FED%[email protected]>
Sorry about the double message. I was using Nabble and it didn't seem to
post correctly. Values are null when iterating in the sense that if you hav=
e
an empty bundle, there is no fallback.

As I said this isn't immediately necessary for my project, but the expected
behavior would seem to be that iteration should work over all contents,
including fallbacks. I understand why that might be difficult to implement,
however. At very least a note should be added explaining that iteration wil=
l
not work with fallback. I'm afraid I will have developers trying to do that
if they just go by the documentation.

Joel


On 8/17/10 5:02 AM, "David Z=FClke" <[email protected]> wrote:

> That seems to be a bug.
>=20
> Among other things, resourcebundle_iterator_read calls
> resourcebundle_extract_value instead of resourcebundle_array_get (which
> handles fallbacks via resourcebundle_array_fetch).
>=20
> I'm not sure if the fix is that simple though, as that only fixes getting=
 of
> values, but the iterated range probably still doesn't include the fallbac=
k
> values. What would the expected behavior be for iterators? Should it iter=
ate
> over all contents, including fallbacks? You sent another message to the l=
ist
> earlier which appears to be describing a similar, but different problem w=
here
> values are null when iterating?
>=20
> - David
>=20
>=20
>=20
> On 16.08.2010, at 23:05, Joel Sahleen wrote:
>=20
>> All,
>>=20
>> I am working on a large-scale internationalization project that use the =
intl
>> extension. I am storing localized strings in ICU resource bundles and
>> accessing them via the intl ResourceBundle class. Part of my project rel=
ies
>> on the fallback functionality of the ResourceBundle class. I have put al=
l the
>> US English strings (base language) in the root bundle and created an emp=
ty
>> bundle for en_US as suggested in the ICU guide. That way if any string i=
s
>> missing in the localized bundles, everything automatically falls back to=
 US
>> English.
>>=20
>> Fallback works great if I use the ResourceBundles get method, or if I us=
e
>> array access (e.g., $bundle->get(=8CKEY=B9) or $bundle[=8CKEY=B9]), but =
if I try to
>> iterate over the en_US bundle=B9s content with foreach, it returns a nul=
l
>> result because the bundle is empty. Is there any way to support fallback=
 when
>> using iteration? It=B9s not absolutely necessary for my project, but it =
seems
>> that if the class is going to offer iteration support, that functionalit=
y
>> should also support the fallback functionality.
>>=20
>> Thanks for the help.
>>=20
>> Joel Sahleen
>> Software Engineer
>> Adobe Systems
>=20


-- 
PHP Unicode & I18N Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php