Don't modify default translations when merging with other language

`deep_merge!` modifies the hash of the default translation, and it looks
like `I18n.t` always returns the same instance, so after that, the
default stays translated. So lets duplicate the hash first, before
modifying it, this also helps because we also add more keys below, which
probably also shouldn't be added to the original.
This commit is contained in:
Benjamin Neff 2023-06-10 04:07:01 +02:00
parent 6f802417c6
commit 5508401ed8
No known key found for this signature in database
GPG key ID: 971464C3F1A90194

View file

@ -12,16 +12,12 @@ module LanguageHelper
end
def get_javascript_strings_for(language, section)
defaults = I18n.t(section, :locale => DEFAULT_LANGUAGE)
translations = I18n.t(section, locale: DEFAULT_LANGUAGE).dup
translations.deep_merge!(I18n.t(section, locale: language)) if language != DEFAULT_LANGUAGE
if language != DEFAULT_LANGUAGE
translations = I18n.t(section, :locale => language)
defaults.deep_merge!(translations)
end
defaults['pluralization_rule'] = I18n.t('i18n.plural.js_rule', :locale => language)
defaults['pod_name'] = pod_name
defaults
translations["pluralization_rule"] = I18n.t("i18n.plural.js_rule", locale: language)
translations["pod_name"] = pod_name
translations
end
def direction_for(string)