From 61f3911ed0daa75b51809469bbf4ad974f327e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Dugarte?= Date: Sun, 28 Aug 2016 16:32:50 -0400 Subject: [PATCH 1/3] fix: keys with array values are not being imported --- lib/lit/i18n_backend.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/lit/i18n_backend.rb b/lib/lit/i18n_backend.rb index a9056a07..cc37a5e1 100644 --- a/lib/lit/i18n_backend.rb +++ b/lib/lit/i18n_backend.rb @@ -90,12 +90,16 @@ def store_item(locale, data, scope = [], unless_changed = false) store_item(locale, value, scope + [key], unless_changed) end # end - elsif data.respond_to?(:to_str) - key = ([locale] + scope).join('.') - @cache.update_locale(key, data, false, unless_changed) - elsif data.nil? + else key = ([locale] + scope).join('.') - @cache.delete_locale(key, unless_changed) + if data.respond_to?(:to_str) + @cache.update_locale(key, data, false, unless_changed) + elsif data.is_a?(Array) + @cache.update_locale(key, data, true, unless_changed) + elsif data.nil? + key = ([locale] + scope).join('.') + @cache.delete_locale(key, unless_changed) + end end end From ad48b3d1ed1887535a8a0125d8b018374f7fdd5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Dugarte?= Date: Sun, 28 Aug 2016 18:52:20 -0400 Subject: [PATCH 2/3] fix: only string and arrays were being imported, not number and booleans --- lib/lit/i18n_backend.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/lit/i18n_backend.rb b/lib/lit/i18n_backend.rb index cc37a5e1..ed3f3b2b 100644 --- a/lib/lit/i18n_backend.rb +++ b/lib/lit/i18n_backend.rb @@ -92,13 +92,13 @@ def store_item(locale, data, scope = [], unless_changed = false) # end else key = ([locale] + scope).join('.') - if data.respond_to?(:to_str) - @cache.update_locale(key, data, false, unless_changed) - elsif data.is_a?(Array) - @cache.update_locale(key, data, true, unless_changed) - elsif data.nil? + if data.nil? key = ([locale] + scope).join('.') @cache.delete_locale(key, unless_changed) + elsif data.is_a?(Array) + @cache.update_locale(key, data, true, unless_changed) + else + @cache.update_locale(key, data, false, unless_changed) end end end From 57eaf8a5664eddf10c7e345aedc5cd67d1b503fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Dugarte?= Date: Sun, 28 Aug 2016 18:52:34 -0400 Subject: [PATCH 3/3] fix: don't cast to string numbers and booleans --- lib/lit/cache.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lit/cache.rb b/lib/lit/cache.rb index 6c034100..eddd40dc 100644 --- a/lib/lit/cache.rb +++ b/lib/lit/cache.rb @@ -253,7 +253,7 @@ def parse_value(v, locale) where(localization_key_id: lk.id).first new_value = loca.get_value if loca && loca.get_value.present? end - when String then + when String, Numeric, TrueClass, FalseClass then new_value = v when Hash then new_value = nil