From f3feb441f9ccd3e5e80cb7d017016a3aa7796c9f Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 20 Nov 2013 11:51:07 -0500 Subject: [PATCH] Allow translations for admin_js in plugins. Use deep_merge so plugins can add to existing sections. --- lib/js_locale_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/js_locale_helper.rb b/lib/js_locale_helper.rb index e17578bc4db..0e090e01959 100644 --- a/lib/js_locale_helper.rb +++ b/lib/js_locale_helper.rb @@ -11,7 +11,7 @@ module JsLocaleHelper plugin_translations.merge! YAML::load(File.open(file)) end # merge translations (plugin translations overwrite default translations) - translations[locale_str]['js'].merge!(plugin_translations[locale_str]['js']) if translations[locale_str] && plugin_translations[locale_str] + translations[locale_str]['js'].deep_merge!(plugin_translations[locale_str]['js']) if translations[locale_str] && plugin_translations[locale_str] && plugin_translations[locale_str]['js'] # We used to split the admin versus the client side, but it's much simpler to just # include both for now due to the small size of the admin section. @@ -20,6 +20,7 @@ module JsLocaleHelper # it again later, so we'll merge the JSON ourselves. admin_contents = translations[locale_str].delete('admin_js') translations[locale_str]['js'].merge!(admin_contents) if admin_contents.present? + translations[locale_str]['js'].deep_merge!(plugin_translations[locale_str]['admin_js']) if translations[locale_str] && plugin_translations[locale_str] && plugin_translations[locale_str]['admin_js'] message_formats = strip_out_message_formats!(translations[locale_str]['js']) result = generate_message_format(message_formats, locale_str)