mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Ensure that translations bundle exists before merging plugin bundle.
This commit is contained in:
@@ -10,25 +10,23 @@ class ExtraLocalesController < ApplicationController
|
|||||||
locale_str = I18n.locale.to_s
|
locale_str = I18n.locale.to_s
|
||||||
translations = JsLocaleHelper.translations_for(locale_str)
|
translations = JsLocaleHelper.translations_for(locale_str)
|
||||||
for_key = translations[locale_str]["#{bundle}_js"]
|
for_key = translations[locale_str]["#{bundle}_js"]
|
||||||
|
js = ""
|
||||||
|
|
||||||
if plugin_for_key = JsLocaleHelper.plugin_translations(locale_str)["#{bundle}_js"]
|
if for_key.present?
|
||||||
for_key.deep_merge!(plugin_for_key)
|
if plugin_for_key = JsLocaleHelper.plugin_translations(locale_str)["#{bundle}_js"]
|
||||||
end
|
for_key.deep_merge!(plugin_for_key)
|
||||||
|
|
||||||
js =
|
|
||||||
if for_key.present?
|
|
||||||
<<~JS
|
|
||||||
(function() {
|
|
||||||
if (window.I18n) {
|
|
||||||
window.I18n.extras = window.I18n.extras || [];
|
|
||||||
window.I18n.extras.push(#{for_key.to_json});
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
JS
|
|
||||||
else
|
|
||||||
""
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
js = <<~JS
|
||||||
|
(function() {
|
||||||
|
if (window.I18n) {
|
||||||
|
window.I18n.extras = window.I18n.extras || [];
|
||||||
|
window.I18n.extras.push(#{for_key.to_json});
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
JS
|
||||||
|
end
|
||||||
|
|
||||||
render text: js, content_type: "application/javascript"
|
render text: js, content_type: "application/javascript"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user