Allow translations for admin_js in plugins. Use deep_merge so plugins can add to existing sections.

This commit is contained in:
Neil Lalonde 2013-11-20 11:51:07 -05:00
parent 9de07fd83f
commit f3feb441f9
1 changed files with 2 additions and 1 deletions

View File

@ -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)