FIX: Ensure that translations bundle exists before merging plugin bundle.

This commit is contained in:
Guo Xiang Tan 2016-09-30 14:29:30 +08:00
parent cde18834f8
commit 1c3992e575

View File

@ -10,14 +10,14 @@ class ExtraLocalesController < ApplicationController
locale_str = I18n.locale.to_s
translations = JsLocaleHelper.translations_for(locale_str)
for_key = translations[locale_str]["#{bundle}_js"]
js = ""
if for_key.present?
if plugin_for_key = JsLocaleHelper.plugin_translations(locale_str)["#{bundle}_js"]
for_key.deep_merge!(plugin_for_key)
end
js =
if for_key.present?
<<~JS
js = <<~JS
(function() {
if (window.I18n) {
window.I18n.extras = window.I18n.extras || [];
@ -25,8 +25,6 @@ class ExtraLocalesController < ApplicationController
}
})();
JS
else
""
end
render text: js, content_type: "application/javascript"