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:
parent
6f802417c6
commit
5508401ed8
1 changed files with 5 additions and 9 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue