FIX: Support client locales defined in plugins
This commit is contained in:
parent
fc346d207b
commit
2974faee68
|
@ -38,7 +38,18 @@ module JsLocaleHelper
|
||||||
locale_str = locale.to_s
|
locale_str = locale.to_s
|
||||||
|
|
||||||
# load default translations
|
# load default translations
|
||||||
translations = YAML.load_file("#{Rails.root}/config/locales/client.#{locale_str}.yml")
|
yml_file = "#{Rails.root}/config/locales/client.#{locale_str}.yml"
|
||||||
|
if File.exist?(yml_file)
|
||||||
|
translations = YAML.load_file(yml_file)
|
||||||
|
else
|
||||||
|
# If we can't find a base file in Discourse, it might only exist in a plugin
|
||||||
|
# so let's start with a basic object we can merge into
|
||||||
|
translations = {
|
||||||
|
locale_str => {
|
||||||
|
'js' => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
# merge translations (plugin translations overwrite default translations)
|
# merge translations (plugin translations overwrite default translations)
|
||||||
translations[locale_str]['js'].deep_merge!(plugin_translations(locale_str)['js']) if translations[locale_str] && plugin_translations(locale_str) && plugin_translations(locale_str)['js']
|
translations[locale_str]['js'].deep_merge!(plugin_translations(locale_str)['js']) if translations[locale_str] && plugin_translations(locale_str) && plugin_translations(locale_str)['js']
|
||||||
|
|
Loading…
Reference in New Issue