Fix translations not being formatted, other issues in web UI (#19245)
Fix #19237
This commit is contained in:
parent
d86dd067ce
commit
55a2e9b5be
2 changed files with 10 additions and 6 deletions
|
@ -3,13 +3,16 @@
|
|||
class TranslateStatusService < BaseService
|
||||
CACHE_TTL = 1.day.freeze
|
||||
|
||||
include FormattingHelper
|
||||
|
||||
def call(status, target_language)
|
||||
raise Mastodon::NotPermittedError unless status.public_visibility? || status.unlisted_visibility?
|
||||
|
||||
@status = status
|
||||
@content = status_content_format(@status)
|
||||
@target_language = target_language
|
||||
|
||||
Rails.cache.fetch("translations/#{@status.language}/#{@target_language}/#{content_hash}", expires_in: CACHE_TTL) { translation_backend.translate(@status.text, @status.language, @target_language) }
|
||||
Rails.cache.fetch("translations/#{@status.language}/#{@target_language}/#{content_hash}", expires_in: CACHE_TTL) { translation_backend.translate(@content, @status.language, @target_language) }
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -19,6 +22,6 @@ class TranslateStatusService < BaseService
|
|||
end
|
||||
|
||||
def content_hash
|
||||
Digest::SHA256.base64digest(@status.text)
|
||||
Digest::SHA256.base64digest(@content)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue