mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-22 04:25:06 +01:00
Add mention of the translation provider when translating a post (#19433)
This commit is contained in:
parent
8046cf34d6
commit
30453fab80
@ -208,7 +208,7 @@ class StatusContent extends React.PureComponent {
|
|||||||
|
|
||||||
const translateButton = (
|
const translateButton = (
|
||||||
<button className='status__content__read-more-button' onClick={this.handleTranslate}>
|
<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>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class TranslationService::DeepL < TranslationService
|
|||||||
|
|
||||||
raise UnexpectedResponseError unless json.is_a?(Hash)
|
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
|
rescue Oj::ParseError
|
||||||
raise UnexpectedResponseError
|
raise UnexpectedResponseError
|
||||||
end
|
end
|
||||||
|
@ -37,7 +37,7 @@ class TranslationService::LibreTranslate < TranslationService
|
|||||||
|
|
||||||
raise UnexpectedResponseError unless json.is_a?(Hash)
|
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
|
rescue Oj::ParseError
|
||||||
raise UnexpectedResponseError
|
raise UnexpectedResponseError
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class TranslationService::Translation < ActiveModelSerializers::Model
|
class TranslationService::Translation < ActiveModelSerializers::Model
|
||||||
attributes :text, :detected_source_language
|
attributes :text, :detected_source_language, :provider
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class REST::TranslationSerializer < ActiveModel::Serializer
|
class REST::TranslationSerializer < ActiveModel::Serializer
|
||||||
attributes :content, :detected_source_language
|
attributes :content, :detected_source_language, :provider
|
||||||
|
|
||||||
def content
|
def content
|
||||||
object.text
|
object.text
|
||||||
|
Loading…
Reference in New Issue
Block a user