Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/services/discourse_translator/amazon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion app/services/discourse_translator/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down
5 changes: 4 additions & 1 deletion config/locales/server.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."

Expand Down
6 changes: 5 additions & 1 deletion spec/services/amazon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@

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: detected_lang,
target_locale: target_locale_sym,
),
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/services/google_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/services/microsoft_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading