From dba34fc8fcdd519c6608fe7f2ab17e3d993f1eaa Mon Sep 17 00:00:00 2001 From: donaldkicksyourass Date: Fri, 25 Oct 2024 12:33:59 +0800 Subject: [PATCH] feat: display translations that are not the same as i18n locale (#73) * feat: display translations that are not the same as i18n locale * feat: add separate prop `translationLocale` * feat: display translations that are not the same as i18n locale * chore: lint --------- Co-authored-by: Anthony Fu --- app/components/LyricsLine.vue | 2 +- app/components/SettingsDialog.vue | 7 ++-- app/components/SettingsFloat.vue | 16 ++++----- app/components/SongPlay.vue | 2 +- app/components/TranslationSelector.vue | 49 ++++++++++++++++++++++++++ app/components/atomic/ActionButton.vue | 7 +++- app/components/editors/SongEditor.vue | 3 +- app/composables/settings.ts | 44 +++++++++++++++++++++++ app/locales/en.json | 3 +- app/locales/ja.json | 3 +- app/locales/zh-Hans.json | 3 +- app/locales/zh-Hant.json | 3 +- app/state/local-storage.ts | 1 + app/types/settings.ts | 1 + 14 files changed, 124 insertions(+), 20 deletions(-) create mode 100644 app/components/TranslationSelector.vue diff --git a/app/components/LyricsLine.vue b/app/components/LyricsLine.vue index ba47e4a4..52027a7a 100644 --- a/app/components/LyricsLine.vue +++ b/app/components/LyricsLine.vue @@ -26,7 +26,7 @@ watchEffect(async () => { translation.value = '' return } - const matched = props.line.trans?.[locale.value] + const matched = props.line.trans?.[settings.value.translationLocale || locale.value] if (matched) { translation.value = matched return diff --git a/app/components/SettingsDialog.vue b/app/components/SettingsDialog.vue index 6561ce14..d809e171 100644 --- a/app/components/SettingsDialog.vue +++ b/app/components/SettingsDialog.vue @@ -45,10 +45,9 @@ const { t, locale, locales, setLocale } = useI18n() icon="i-uil-letter-english-a" :title="t('settings.displayRomaji')" /> - +import type { MaruSongDataParsed } from '@marure/schema' import { Menu, Tooltip } from 'floating-vue' import { useSettings } from '~/composables/settings' +defineProps<{ + song: MaruSongDataParsed +}>() const settings = useSettings() @@ -58,14 +62,10 @@ const settings = useSettings() - - - - + {
- +
diff --git a/app/components/TranslationSelector.vue b/app/components/TranslationSelector.vue new file mode 100644 index 00000000..266c7ff0 --- /dev/null +++ b/app/components/TranslationSelector.vue @@ -0,0 +1,49 @@ + + + diff --git a/app/components/atomic/ActionButton.vue b/app/components/atomic/ActionButton.vue index 3d419be9..e67bf293 100644 --- a/app/components/atomic/ActionButton.vue +++ b/app/components/atomic/ActionButton.vue @@ -1,7 +1,7 @@