From 30453fab80d55fc10766f0e067c31d96753ccfda Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 24 Oct 2022 18:37:57 +0200 Subject: [PATCH] Add mention of the translation provider when translating a post (#19433) --- app/javascript/mastodon/components/status_content.js | 2 +- app/lib/translation_service/deepl.rb | 2 +- app/lib/translation_service/libre_translate.rb | 2 +- app/lib/translation_service/translation.rb | 2 +- app/serializers/rest/translation_serializer.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/javascript/mastodon/components/status_content.js b/app/javascript/mastodon/components/status_content.js index 0ed79e6588..56e8432b69 100644 --- a/app/javascript/mastodon/components/status_content.js +++ b/app/javascript/mastodon/components/status_content.js @@ -208,7 +208,7 @@ class StatusContent extends React.PureComponent { const translateButton = ( ); diff --git a/app/lib/translation_service/deepl.rb b/app/lib/translation_service/deepl.rb index b75b604a81..537fd24c08 100644 --- a/app/lib/translation_service/deepl.rb +++ b/app/lib/translation_service/deepl.rb @@ -46,7 +46,7 @@ class TranslationService::DeepL < TranslationService raise UnexpectedResponseError unless json.is_a?(Hash) - Translation.new(text: json.dig('translations', 0, 'text'), detected_source_language: json.dig('translations', 0, 'detected_source_language')&.downcase) + Translation.new(text: json.dig('translations', 0, 'text'), detected_source_language: json.dig('translations', 0, 'detected_source_language')&.downcase, provider: 'DeepL.com') rescue Oj::ParseError raise UnexpectedResponseError end diff --git a/app/lib/translation_service/libre_translate.rb b/app/lib/translation_service/libre_translate.rb index 8cf26f8684..43576e3062 100644 --- a/app/lib/translation_service/libre_translate.rb +++ b/app/lib/translation_service/libre_translate.rb @@ -37,7 +37,7 @@ class TranslationService::LibreTranslate < TranslationService raise UnexpectedResponseError unless json.is_a?(Hash) - Translation.new(text: json['translatedText'], detected_source_language: source_language) + Translation.new(text: json['translatedText'], detected_source_language: source_language, provider: 'LibreTranslate') rescue Oj::ParseError raise UnexpectedResponseError end diff --git a/app/lib/translation_service/translation.rb b/app/lib/translation_service/translation.rb index a55b825749..19318c7e9e 100644 --- a/app/lib/translation_service/translation.rb +++ b/app/lib/translation_service/translation.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true class TranslationService::Translation < ActiveModelSerializers::Model - attributes :text, :detected_source_language + attributes :text, :detected_source_language, :provider end diff --git a/app/serializers/rest/translation_serializer.rb b/app/serializers/rest/translation_serializer.rb index a06f23f327..05ededc95c 100644 --- a/app/serializers/rest/translation_serializer.rb +++ b/app/serializers/rest/translation_serializer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class REST::TranslationSerializer < ActiveModel::Serializer - attributes :content, :detected_source_language + attributes :content, :detected_source_language, :provider def content object.text