Skip to content

A platform for community discussion. Free, open, simple.

Safety in case translations are missing root keys

Robin Warde0096b0d1c72
diff --git a/lib/js_locale_helper.rb b/lib/js_locale_helper.rb
index 8b66f56be96..0207aee1b49 100644
--- a/lib/js_locale_helper.rb
+++ b/lib/js_locale_helper.rb
@@ -55,6 +55,10 @@ module JsLocaleHelper
# merge translations (plugin translations overwrite default translations)
if translations[locale_str] && plugin_translations(locale_str)
+ translations[locale_str]['js'] ||= {}
+ translations[locale_str]['admin_js'] ||= {}
+ translations[locale_str]['wizard_js'] ||= {}
+
translations[locale_str]['js'].deep_merge!(plugin_translations(locale_str)['js']) if plugin_translations(locale_str)['js']
translations[locale_str]['admin_js'].deep_merge!(plugin_translations(locale_str)['admin_js']) if plugin_translations(locale_str)['admin_js']
translations[locale_str]['wizard_js'].deep_merge!(plugin_translations(locale_str)['wizard_js']) if plugin_translations(locale_str)['wizard_js']