diff --git a/app/services/discourse_translator/amazon.rb b/app/services/discourse_translator/amazon.rb index 98252a1a..3694f5f3 100644 --- a/app/services/discourse_translator/amazon.rb +++ b/app/services/discourse_translator/amazon.rb @@ -134,7 +134,7 @@ def self.translate!(translatable, target_locale_sym = I18n.locale) ) rescue Aws::Translate::Errors::UnsupportedLanguagePairException raise I18n.t( - "translator.failed", + "translator.failed.#{translatable.class.name.downcase}", source_locale: detected_lang, target_locale: target_locale_sym, ) diff --git a/app/services/discourse_translator/base.rb b/app/services/discourse_translator/base.rb index 7a46b99c..f43c7f15 100644 --- a/app/services/discourse_translator/base.rb +++ b/app/services/discourse_translator/base.rb @@ -42,7 +42,7 @@ def self.translate(translatable, target_locale_sym = I18n.locale) unless translate_supported?(detected_lang, target_locale_sym) raise TranslatorError.new( I18n.t( - "translator.failed", + "translator.failed.#{translatable.class.name.downcase}", source_locale: detected_lang, target_locale: target_locale_sym, ), diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index da4ced5b..2bba77c8 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -24,11 +24,14 @@ en: experimental_inline_translation: "Enable experimental inline translation feature. This replaces existing parallel translation, allowing site visitors with a non-default locale to view content in their language." automatic_translation_target_languages: "The languages to automatically translate user content (posts, topics) to. If empty, no languages will be automatically translated." translator: - failed: "The translator is unable to translate this content (%{source_locale}) to the default language of this site (%{target_locale})." + failed: + topic: "The translator is unable to translate this topic's title (%{source_locale}) to your language (%{target_locale})." + post: "The translator is unable to translate this post's content (%{source_locale}) to your language (%{target_locale})." not_supported: "This language is not supported by the translator." too_long: "This post is too long to be translated by the translator." not_available: "The translator service is currently not available." api_timeout: "The translator service took too long to respond. Please try again later." + amazon: invalid_credentials: "The provided credentials for AWS translate are invalid." diff --git a/spec/services/amazon_spec.rb b/spec/services/amazon_spec.rb index 101b9d9f..2182e231 100644 --- a/spec/services/amazon_spec.rb +++ b/spec/services/amazon_spec.rb @@ -67,7 +67,7 @@ it "raises an error when trying to translate an unsupported language" do expect { described_class.translate(post) }.to raise_error( - I18n.t("translator.failed", source_locale: "en", target_locale: "es"), + I18n.t("translator.failed.post", source_locale: "en", target_locale: "es"), ) end end diff --git a/spec/services/google_spec.rb b/spec/services/google_spec.rb index a5929803..6f6cddbf 100644 --- a/spec/services/google_spec.rb +++ b/spec/services/google_spec.rb @@ -143,7 +143,7 @@ ) expect { described_class.translate(post) }.to raise_error( - I18n.t("translator.failed", source_locale: "cat", target_locale: "dog"), + I18n.t("translator.failed.post", source_locale: "cat", target_locale: "dog"), ) end diff --git a/spec/services/microsoft_spec.rb b/spec/services/microsoft_spec.rb index 7c2cfb80..463b5f5d 100644 --- a/spec/services/microsoft_spec.rb +++ b/spec/services/microsoft_spec.rb @@ -169,7 +169,7 @@ def translate_endpoint expect { described_class.translate(post) }.to raise_error( DiscourseTranslator::TranslatorError, - I18n.t("translator.failed", source_locale: "donkey", target_locale: I18n.locale), + I18n.t("translator.failed.post", source_locale: "donkey", target_locale: I18n.locale), ) end