From 0b77ad3f439935115fd0177b27abc4d025614b42 Mon Sep 17 00:00:00 2001 From: Alex <49969959+alexzhang1030@users.noreply.github.com> Date: Wed, 18 Jan 2023 05:41:26 +0800 Subject: [PATCH] fix: translate posts target language is not current selected language (#1263) --- components/status/StatusActionsMore.vue | 12 ---------- components/status/StatusBody.vue | 2 +- components/status/StatusTranslation.vue | 4 ++-- composables/masto/translate.ts | 31 ++++++++++++++++++++----- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/components/status/StatusActionsMore.vue b/components/status/StatusActionsMore.vue index 5a95fdff..e116073c 100644 --- a/components/status/StatusActionsMore.vue +++ b/components/status/StatusActionsMore.vue @@ -27,18 +27,6 @@ const userSettings = useUserSettings() const isAuthor = $computed(() => status.account.id === currentUser.value?.account.id) -const { - toggle: _toggleTranslation, - translation, - enabled: isTranslationEnabled, -} = useTranslation(props.status) - -const toggleTranslation = async () => { - isLoading.translation = true - await _toggleTranslation() - isLoading.translation = false -} - const { client } = $(useMasto()) const getPermalinkUrl = (status: mastodon.v1.Status) => { diff --git a/components/status/StatusBody.vue b/components/status/StatusBody.vue index 19db607f..ef51dead 100644 --- a/components/status/StatusBody.vue +++ b/components/status/StatusBody.vue @@ -9,7 +9,7 @@ const { withAction?: boolean }>() -const { translation } = useTranslation(status) +const { translation } = useTranslation(status, getLanguageCode()) const emojisObject = useEmojisFallback(() => status.emojis) const vnode = $computed(() => { diff --git a/components/status/StatusTranslation.vue b/components/status/StatusTranslation.vue index 55c367fc..eb090018 100644 --- a/components/status/StatusTranslation.vue +++ b/components/status/StatusTranslation.vue @@ -9,7 +9,7 @@ const { toggle: _toggleTranslation, translation, enabled: isTranslationEnabled, -} = useTranslation(status) +} = useTranslation(status, getLanguageCode()) let translating = $ref(false) const toggleTranslation = async () => { @@ -26,7 +26,7 @@ const toggleTranslation = async () => {