Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix i18n/backend/key_value to add data in a array

  • Loading branch information...
commit e2b0fe4c9bbcf473caedf711e018843f6765b676 1 parent 30c27fa
@nledez nledez authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/i18n/backend/key_value.rb
View
4 lib/i18n/backend/key_value.rb
@@ -73,7 +73,7 @@ def store_translations(locale, data, options = {})
raise "Key-value stores cannot handle procs"
end
- @store[key] = ActiveSupport::JSON.encode(value) unless value.is_a?(Symbol)
+ @store[key] = ActiveSupport::JSON.encode([value]) unless value.is_a?(Symbol)
@chrisb
chrisb added a note

Hmm.. I'd also like clarification on why this was done...

Doesn't this break subtree functionality? In store_translations, the old_value will never be a Hash so the deep_merge! will never be performed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
end
end
@@ -90,7 +90,7 @@ def available_locales
def lookup(locale, key, scope = [], options = {})
key = normalize_flat_keys(locale, key, scope, options[:separator])
value = @store["#{locale}.#{key}"]
- value = ActiveSupport::JSON.decode(value) if value
+ value = ActiveSupport::JSON.decode(value)[0] if value
@sashich
sashich added a note

Hi, there! Can you clarify why are we expecting 'value' as an array?
If 'value' is a string we will get only the first character. Is it by design?

I have stumbled upon this problem as well. I don't understand why this is happening, could you clarify, please why it was done?

@knapo Collaborator
knapo added a note

Me neither. @nledez - could you clarify?

This is causing a weird bug in our application, where we use custom key-value backend. The result is that on production only, we get translations truncated after first character.

@knapo Collaborator
knapo added a note

Reverted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
value.is_a?(Hash) ? value.deep_symbolize_keys : value
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.