From 1fe598f5545fd47ae95c31b1cc47e3168056b968 Mon Sep 17 00:00:00 2001 From: Sma11X <540351143@qq.com> Date: Fri, 13 Oct 2023 15:13:37 +0800 Subject: [PATCH] fix: some keyboard shortcuts not working in non-english (#2324) --- plugins/magic-keys.client.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/magic-keys.client.ts b/plugins/magic-keys.client.ts index a2e3b39d..a790bf64 100644 --- a/plugins/magic-keys.client.ts +++ b/plugins/magic-keys.client.ts @@ -4,6 +4,7 @@ import { useMagicSequence } from '~/composables/magickeys' export default defineNuxtPlugin(({ $scrollToTop }) => { const keys = useMagicKeys() const router = useRouter() + const i18n = useNuxtApp().$i18n // disable shortcuts when focused on inputs (https://vueuse.org/core/usemagickeys/#conditionally-disable) const activeElement = useActiveElement() @@ -41,7 +42,7 @@ export default defineNuxtPlugin(({ $scrollToTop }) => { // TODO: find a better solution than clicking buttons... document .querySelector('[aria-roledescription=status-details]') - ?.querySelector('button[aria-label=Favourite]') + ?.querySelector(`button[aria-label=${i18n.t('action.favourite')}]`) ?.click() } whenever(logicAnd(isAuthenticated, notUsingInput, keys.f), toggleFavouriteActiveStatus) @@ -50,7 +51,7 @@ export default defineNuxtPlugin(({ $scrollToTop }) => { // TODO: find a better solution than clicking buttons... document .querySelector('[aria-roledescription=status-details]') - ?.querySelector('button[aria-label=Boost]') + ?.querySelector(`button[aria-label=${i18n.t('action.boost')}]`) ?.click() } whenever(logicAnd(isAuthenticated, notUsingInput, keys.b), toggleBoostActiveStatus)