Skip to content


Fix to close issue #1499 i18n with key/value backend #97

merged 1 commit into from

6 participants


This pull request solve issue #1499


What is issue #1499? Where it is? And test missing.


Ahh...found it rails/rails#1499. I didn't follow that discussion, so let's wait for José and Sven :)

@tigrish tigrish merged commit cd5ad8a into svenfuchs:master

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?


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.




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
Commits on Jun 11, 2011
  1. @nledez
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/i18n/backend/key_value.rb
4 lib/i18n/backend/key_value.rb
@@ -73,7 +73,7 @@ def store_translations(locale, data, options = {})
raise "Key-value stores cannot handle procs"
- @store[key] = ActiveSupport::JSON.encode(value) unless value.is_a?(Symbol)
+ @store[key] = ActiveSupport::JSON.encode([value]) unless value.is_a?(Symbol)
@@ -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
value.is_a?(Hash) ? value.deep_symbolize_keys : value
Something went wrong with that request. Please try again.