Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
mastodon
Commits
30453fab
Unverified
Commit
30453fab
authored
2 years ago
by
Claire
Committed by
GitHub
2 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Add mention of the translation provider when translating a post (#19433)
parent
8046cf34
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
app/javascript/mastodon/components/status_content.js
+1
-1
app/javascript/mastodon/components/status_content.js
app/lib/translation_service/deepl.rb
+1
-1
app/lib/translation_service/deepl.rb
app/lib/translation_service/libre_translate.rb
+1
-1
app/lib/translation_service/libre_translate.rb
app/lib/translation_service/translation.rb
+1
-1
app/lib/translation_service/translation.rb
app/serializers/rest/translation_serializer.rb
+1
-1
app/serializers/rest/translation_serializer.rb
with
5 additions
and
5 deletions
+5
-5
app/javascript/mastodon/components/status_content.js
+
1
-
1
View file @
30453fab
...
...
@@ -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
>
);
...
...
This diff is collapsed.
Click to expand it.
app/lib/translation_service/deepl.rb
+
1
-
1
View file @
30453fab
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
app/lib/translation_service/libre_translate.rb
+
1
-
1
View file @
30453fab
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
app/lib/translation_service/translation.rb
+
1
-
1
View file @
30453fab
# frozen_string_literal: true
class
TranslationService::Translation
<
ActiveModelSerializers
::
Model
attributes
:text
,
:detected_source_language
attributes
:text
,
:detected_source_language
,
:provider
end
This diff is collapsed.
Click to expand it.
app/serializers/rest/translation_serializer.rb
+
1
-
1
View file @
30453fab
# frozen_string_literal: true
class
REST::TranslationSerializer
<
ActiveModel
::
Serializer
attributes
:content
,
:detected_source_language
attributes
:content
,
:detected_source_language
,
:provider
def
content
object
.
text
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets