Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace lookup does not include fallback keys #368

Open
tf opened this issue May 11, 2017 · 6 comments
Open

Namespace lookup does not include fallback keys #368

tf opened this issue May 11, 2017 · 6 comments

Comments

@tf
Copy link

tf commented May 11, 2017

What I tried to do

Given locales like:

en:
  namespace:
    some: "some text"
    other: "other text"

de:
  namespace:
    some "etwas Text" 

What I expected to happen

Looking up a single translation falls back to default locale:

I18n.locale = :de
I18n.default_locale = :en
I18n.t('namespace.some') # => "etwas Text"
I18n.t('namespace.other') # => "other text"

Looking up a namespace should return the same results as an object:

I18n.locale = :de
I18n.default_locale = :en
I18n.t('namespace') # => {some: "etwas Text", other: "other text"}

What actually happened

Since the namespace key is found, fallback logic does not kick in:

I18n.locale = :de
I18n.default_locale = :en
I18n.t('namespace') # => {some: "etwas Text"}

Versions of i18n, rails, and anything else you think is neccessary

I18n 0.8.1
Rails 4.2

@tf tf changed the title Namespace lookup does not include Namespace lookup does not include fallback keys May 11, 2017
@dmitry
Copy link

dmitry commented May 14, 2017

This might be complex on computation, as it requires run logic on each key located inside the namespace. Are you using Fallbacks module for your backend or is it Simple (default) backend?

@tf
Copy link
Author

tf commented May 15, 2017

I'm not doing anything special, so I guess I'm using the Simple backend, but with config.i18n.fallbacks = true in the Rails environment. Not sure if that means I'm using the Fallbacks backend. Without that setting, there appears to be no fallback to the default locale at all.

For my special use case of needing to extract all translations from a specific namespace including the fallbacks, I worked around the current behavior by doing a second namespace lookup in the default locale and performing a deep merge.

From my point of view, it would be more consistent if that was the default behavior, but I'm not sure I understand all the implications and also there might be a performance trade off.

@radar
Copy link
Collaborator

radar commented Oct 15, 2017

Hi, this issue might be fixed by #387. Could you please try it out and let me know?

@tf
Copy link
Author

tf commented Oct 16, 2017

@radar Tried 0.9.0 and saw unchanged behavior far as I can tell.

@siadminsykio
Copy link

hi,
I have same issue.
any update on this?
thanks

@radar
Copy link
Collaborator

radar commented Oct 10, 2018

If there was, you can be sure it would be posted here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants