diff --git a/lib/js_locale_helper.rb b/lib/js_locale_helper.rb index 7444e393874..172c4c0ac57 100644 --- a/lib/js_locale_helper.rb +++ b/lib/js_locale_helper.rb @@ -38,7 +38,18 @@ module JsLocaleHelper locale_str = locale.to_s # 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) translations[locale_str]['js'].deep_merge!(plugin_translations(locale_str)['js']) if translations[locale_str] && plugin_translations(locale_str) && plugin_translations(locale_str)['js']