From 8586d58b8498156d19c2e71805f5085357da2f32 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 25 Nov 2022 00:14:16 +0000 Subject: [PATCH] feat: allow translation of statuses (#76) --- components/status/StatusActions.vue | 18 +++++++++++ components/status/StatusBody.vue | 3 +- composables/translate.ts | 47 +++++++++++++++++++++++++++++ nuxt.config.ts | 3 ++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 composables/translate.ts diff --git a/components/status/StatusActions.vue b/components/status/StatusActions.vue index b454748c..9746e9ec 100644 --- a/components/status/StatusActions.vue +++ b/components/status/StatusActions.vue @@ -22,6 +22,7 @@ const isLoading = $ref({ favourited: false, bookmarked: false, pinned: false, + translation: false, }) async function toggleStatusAction(action: 'reblogged' | 'favourited' | 'bookmarked' | 'pinned', newStatus: Promise) { // Optimistic update @@ -59,6 +60,13 @@ const togglePin = async () => toggleStatusAction( masto.statuses[status.pinned ? 'unpin' : 'pin'](status.id), ) +const { toggle: _toggleTranslation, translation, enabled: isTranslationEnabled } = useTranslation(_status) +const toggleTranslation = async () => { + isLoading.translation = true + await _toggleTranslation() + isLoading.translation = false +} + const copyLink = async () => { await clipboard.copy(`${location.origin}${getStatusPath(status)}`) } @@ -160,6 +168,16 @@ function mention() { /> + + + +