allow translating to any other language
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5ee4f76de3
commit
44c1f43bd8
5 changed files with 39 additions and 7 deletions
|
@ -9,6 +9,7 @@ import {
|
|||
faLink,
|
||||
faPollH
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
import Select from 'src/components/select/select.vue'
|
||||
|
||||
library.add(
|
||||
faFile,
|
||||
|
@ -37,7 +38,8 @@ const StatusContent = {
|
|||
data () {
|
||||
return {
|
||||
postLength: this.status.text.length,
|
||||
parseReadyDone: false
|
||||
parseReadyDone: false,
|
||||
translateFrom: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -78,10 +80,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 => {
|
||||
|
@ -124,6 +130,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 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,27 @@
|
|||
:attentions="status.attentions"
|
||||
@parseReady="onParseReady"
|
||||
/>
|
||||
<div>
|
||||
<label class="label">{{ $t('status.override_translation_source_language') }}</label>
|
||||
{{ ' ' }}
|
||||
<Select
|
||||
id="source-language-switcher"
|
||||
v-model="translateFrom"
|
||||
class="preset-switcher"
|
||||
>
|
||||
<option
|
||||
v-for="language in translationLanguages"
|
||||
:key="language.key"
|
||||
:value="language.value"
|
||||
>
|
||||
{{ language.label }}
|
||||
</option>
|
||||
</Select>
|
||||
{{ ' ' }}
|
||||
<button @click="translateStatus" class="btn button-default">
|
||||
{{ $t('status.translate') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
|
|
|
@ -273,7 +273,7 @@ const api = {
|
|||
getSupportedTranslationlanguages (store) {
|
||||
store.state.backendInteractor.getSupportedTranslationlanguages({ store })
|
||||
.then((data) => {
|
||||
store.dispatch('setInstanceOption', { name: 'supportedTranslationLanguages', value: data })
|
||||
store.dispatch('setOption', { name: 'supportedTranslationLanguages', value: data })
|
||||
})
|
||||
},
|
||||
|
||||
|
|
|
@ -655,8 +655,8 @@ const statuses = {
|
|||
rootState.api.backendInteractor.unpinOwnStatus({ id: statusId })
|
||||
.then((status) => dispatch('addNewStatuses', { statuses: [status] }))
|
||||
},
|
||||
translateStatus ({ rootState, commit }, { id, translation, language }) {
|
||||
return rootState.api.backendInteractor.translateStatus({ id, translation, language })
|
||||
translateStatus ({ rootState, commit }, { id, translation, language, from }) {
|
||||
return rootState.api.backendInteractor.translateStatus({ id: id, translation, language, from })
|
||||
.then((translation) => commit('setTranslatedStatus', { id, translation }))
|
||||
},
|
||||
muteConversation ({ rootState, commit }, statusId) {
|
||||
|
|
|
@ -805,8 +805,9 @@ const getSupportedTranslationlanguages = ({ credentials }) => {
|
|||
return promisedRequest({ url: AKKOMA_LANGUAGES_URL, credentials })
|
||||
}
|
||||
|
||||
const translateStatus = ({ id, credentials, language }) => {
|
||||
return promisedRequest({ url: AKKOMA_TRANSLATE_URL(id, language), method: 'GET', credentials })
|
||||
const translateStatus = ({ id, credentials, language, from }) => {
|
||||
const queryString = from ? `?from=${from}` : ''
|
||||
return promisedRequest({ url: AKKOMA_TRANSLATE_URL(id, language) + queryString, method: 'GET', credentials })
|
||||
.then((data) => {
|
||||
return data
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue