diff --git a/app/javascript/mastodon/components/status_content.js b/app/javascript/mastodon/components/status_content.js index 0ed79e65884b9b972e00158fdfd7336349bb6fd9..56e8432b69dfa1fc70794c89f15d7f49ce8a6c09 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 = ( <button className='status__content__read-more-button' onClick={this.handleTranslate}> - {status.get('translation') ? <span><FormattedMessage id='status.translated_from' defaultMessage='Translated from {lang}' values={{ lang: languageName }} /> · <FormattedMessage id='status.show_original' defaultMessage='Show original' /></span> : <FormattedMessage id='status.translate' defaultMessage='Translate' />} + {status.get('translation') ? <span><FormattedMessage id='status.translated_from_with' defaultMessage='Translated from {lang} using {provider}' values={{ lang: languageName, provider: status.getIn(['translation', 'provider']) }} /> · <FormattedMessage id='status.show_original' defaultMessage='Show original' /></span> : <FormattedMessage id='status.translate' defaultMessage='Translate' />} </button> ); diff --git a/app/lib/translation_service/deepl.rb b/app/lib/translation_service/deepl.rb index b75b604a81d949f5ee774ad4bf65dd83bba6fd0c..537fd24c089662c807893b7d8391d95ea0294bad 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 8cf26f8684a31d7bcc705957ee1bcc75ee430652..43576e306274dcbc55f8e5f959e40cc7f2a88795 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 a55b825749d744f695cd60c61bc01d2cd1b06007..19318c7e9e688251e0fe94e84bd1a323cc1e4fba 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 a06f23f32780fef02e0f269988afdd838bcb0b31..05ededc95c97a051a881492fab224e8bfe498eeb 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