You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to integrate CLDR data provided by ruby-i18n/ruby-cldr, the interaction between symbols and the Fallbacks backend is not quite what I'm hoping for.
CLDR defines "aliases" that indicate that a lookup should restart at a different key than the key currently being looked up. i18n allows for a similar thing by "resolving" Symbols that it finds.
However, CLDR aliases restart the lookup from the original locale, while i18n restarts the lookup from the locale that it found the alias in.
I'm wondering if there is a way to support CLDR aliases in i18n?
Aside: I'm the new maintainer of ruby-cldr 👋, so we can make changes on that end if needed.
I18n config:
I18n::Backend::Simple.include(I18n::Backend::Fallbacks,I18n::Backend::Pluralization,)I18n.enforce_available_locales=falseI18n.fallbacks=I18n::Locale::Fallbacks.new(:root)# Overly simple fallback implementation for demonstrationI18n.load_path += Dir[File.join("data/**/*.yml")]
The lookup fails in ak, and falls back to root. When a symbol is found, it resolves that symbol, by starting a new lookup.
However, that lookup doesn't restart at ak, but at root. The result is that it finds root's :calendars.gregorian.months.format.abbreviated instead of ak's.
Desired: Entries from ak's :calendars.gregorian.months.format.abbreviated via root's calendars.gregorian.months.stand-alone.abbreviated
Received: Entries from root's :calendars.gregorian.months.format.wide via root's :calendars.gregorian.months.format.abbreviated via root's calendars.gregorian.months.stand-alone.abbreviated
When trying to integrate CLDR data provided by
ruby-i18n/ruby-cldr
, the interaction between symbols and theFallbacks
backend is not quite what I'm hoping for.CLDR defines "aliases" that indicate that a lookup should restart at a different key than the key currently being looked up.
i18n
allows for a similar thing by "resolving"Symbol
s that it finds.However, CLDR aliases restart the lookup from the original locale, while
i18n
restarts the lookup from the locale that it found the alias in.I'm wondering if there is a way to support CLDR aliases in
i18n
?Aside: I'm the new maintainer of
ruby-cldr
👋, so we can make changes on that end if needed.I18n config:
data/ak/calendars.yml
:data/root/calendars.yml
:The lookup fails in
ak
, and falls back toroot
. When a symbol is found, it resolves that symbol, by starting a new lookup.However, that lookup doesn't restart at
ak
, but atroot
. The result is that it findsroot
's:calendars.gregorian.months.format.abbreviated
instead ofak
's.Desired: Entries from
ak
's:calendars.gregorian.months.format.abbreviated
viaroot
'scalendars.gregorian.months.stand-alone.abbreviated
Received: Entries from
root
's:calendars.gregorian.months.format.wide
viaroot
's:calendars.gregorian.months.format.abbreviated
viaroot
'scalendars.gregorian.months.stand-alone.abbreviated
Run this example
Runnable code can be found here: https://github.com/movermeyer/i18n_test/tree/movermeyer/fallbacks_with_symbols
Potential solution?
IDK yet. I threw together a "proof-of-concept" PR here.
The text was updated successfully, but these errors were encountered: