-
Notifications
You must be signed in to change notification settings - Fork 149
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
Silently ignore the parent #83
base: master
Are you sure you want to change the base?
Conversation
Hey @nvanoorschot |
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.
Could you please also add specs for this new functionality?
@@ -49,29 +49,28 @@ def store_translations(locale, data, options = {}) | |||
|
|||
def lookup(locale, key, scope = [], options = {}) | |||
key = normalize_flat_keys(locale, key, scope, options[:separator]) | |||
result = Translation.locale(locale).lookup(key) | |||
results = Translation.locale(locale).lookup(key).order(key: :desc) |
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 do we need ordering here?
It will just make query more complicated but I don't see any benefits of using it
iterator[key] = translation_nested_keys[index + 1] ? {} : translation.value | ||
iterator[key] | ||
translation_nested_keys = translation.key.slice(chop_range) | ||
return {} if translation_nested_keys.nil? |
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.
Let's use unless translation_nested_keys
instead of if translation_nested_keys.nil?
👍 for this PR |
Closes #82
First I order the translations so that a parent element would be the last result. This makes sure that when checking the key of the first result it is not parents value that is returned.
In the
build_translation_hash_by_key
method I simply return an empty Hash when the parent is evaluated.