diff --git a/app/services/discourse_translator/base.rb b/app/services/discourse_translator/base.rb index 187f8b38..2d0713c5 100644 --- a/app/services/discourse_translator/base.rb +++ b/app/services/discourse_translator/base.rb @@ -78,7 +78,11 @@ def self.access_token end def self.save_translation(translatable, target_locale_sym = I18n.locale) - translation = yield + begin + translation = yield + rescue Timeout::Error + raise TranslatorError.new(I18n.t("translator.api_timeout")) + end translatable.set_translation(target_locale_sym, translation) translation end diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 56cc7548..d381e354 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -27,6 +27,7 @@ en: 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."