Skip to content

Commit

Permalink
Fix i18n/backend/key_value to add data in a array
Browse files Browse the repository at this point in the history
  • Loading branch information
nledez committed Jun 11, 2011
1 parent 30c27fa commit e2b0fe4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/i18n/backend/key_value.rb
Expand Up @@ -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)

This comment has been minimized.

Copy link
@chrisb

chrisb Nov 27, 2012

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.

end
end

Expand All @@ -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

This comment has been minimized.

Copy link
@sashich

sashich Oct 4, 2012

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?

This comment has been minimized.

Copy link
@hubertlepicki

hubertlepicki Dec 28, 2012

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

This comment has been minimized.

Copy link
@knapo

knapo Dec 28, 2012

Collaborator

Me neither. @nledez - could you clarify?

This comment has been minimized.

Copy link
@hubertlepicki

hubertlepicki Dec 31, 2012

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.

This comment has been minimized.

Copy link
@knapo

knapo Dec 31, 2012

Collaborator

Reverted.

value.is_a?(Hash) ? value.deep_symbolize_keys : value
end
end
Expand Down

0 comments on commit e2b0fe4

Please sign in to comment.