Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keys with array/numeric/boolean values are not being imported #81

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/lit/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions lib/lit/i18n_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.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

Expand Down