Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Merged
merged 1 commit into from

6 participants

@nledez

This pull request solve issue #1499

@knapo
Collaborator

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

@knapo
Collaborator

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
@sashich

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?

Collaborator

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.

Collaborator

Reverted.

@chrisb

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
This page is out of date. Refresh to see the latest.
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)
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
value.is_a?(Hash) ? value.deep_symbolize_keys : value
end
end
Something went wrong with that request. Please try again.