From 6440e51b7e2d3dfb381a0bcac568033e16cd9e1e Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Tue, 30 Aug 2022 15:43:57 +0100 Subject: [PATCH] allow translating to any other language --- src/components/status_body/status_body.js | 14 ++++++++++++-- src/components/status_body/status_body.vue | 21 +++++++++++++++++++++ src/i18n/en.json | 1 + src/modules/api.js | 2 +- src/modules/statuses.js | 4 ++-- src/services/api/api.service.js | 5 +++-- 6 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/components/status_body/status_body.js b/src/components/status_body/status_body.js index 91d795f1..f2f0fa2d 100644 --- a/src/components/status_body/status_body.js +++ b/src/components/status_body/status_body.js @@ -9,6 +9,7 @@ import { faLink, faPollH } from '@fortawesome/free-solid-svg-icons' +import Select from 'src/components/select/select.vue' library.add( faFile, @@ -39,7 +40,8 @@ const StatusContent = { return { postLength: this.status.text.length, parseReadyDone: false, - renderMisskeyMarkdown + renderMisskeyMarkdown, + translateFrom: null } }, computed: { @@ -80,10 +82,14 @@ const StatusContent = { attachmentTypes () { return this.status.attachments.map(file => fileType.fileType(file.mimetype)) }, + translationLanguages () { + return (this.$store.getters.mergedConfig.supportedTranslationLanguages || []).map(lang => ({ key: lang.code, value: lang.code, label: lang.name })) + }, ...mapGetters(['mergedConfig']) }, components: { - RichContent + RichContent, + Select }, mounted () { this.status.attentions && this.status.attentions.forEach(attn => { @@ -126,6 +132,10 @@ const StatusContent = { }, generateTagLink (tag) { return `/tag/${tag}` + }, + translateStatus () { + const translateTo = this.$store.getters.mergedConfig.translationLanguage || this.$store.state.instance.interfaceLanguage + this.$store.dispatch('translateStatus', { id: this.status.id, language: translateTo, from: this.translateFrom }) } } } diff --git a/src/components/status_body/status_body.vue b/src/components/status_body/status_body.vue index c1a3d9e7..ed19261d 100644 --- a/src/components/status_body/status_body.vue +++ b/src/components/status_body/status_body.vue @@ -72,6 +72,27 @@ :attentions="status.attentions" @parseReady="onParseReady" /> +
+ + {{ ' ' }} + + {{ ' ' }} + +