-
Notifications
You must be signed in to change notification settings - Fork 148
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
Fix inconsistency with other I18n backends #86
Fix inconsistency with other I18n backends #86
Conversation
Why: So that tests can be run in isolation.
Why: So that the ActiveRecord Backend is consistent with the default rails backend.
lib/i18n/backend/active_record.rb
Outdated
@@ -51,6 +51,10 @@ def lookup(locale, key, scope = [], options = {}) | |||
key = normalize_flat_keys(locale, key, scope, options[:separator]) | |||
result = Translation.locale(locale).lookup(key) | |||
|
|||
if result.empty? && key == '.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we call this before or instead result = Translation.locale(locale).lookup(key)
Maybe smth like
result = if key == '.'
Translation.locale(locale).all
else
Translation.locale(locale).lookup(key)
end
This way we won't run two queries for .
key
@gingermusketeer Thanks for your contribution. I've added one comment |
Why: So the database is only hit once for the lookup.
@Timsly Thanks for pointing that out. I have made the change you suggested! |
Merged! Thanks @gingermusketeer |
Thank you!! |
Released as |
I18n::Backend::Simple
supports returning all keys by invokingI18n.t('.')
. This adds support for this functionality so that it is consistent with the simple backend.I ran into this problem when using different backends across environments in rails.
Hopefully the changes I have made make sense!