From 76bad723ab733bbf21e3b1979017e2f4ec472c35 Mon Sep 17 00:00:00 2001 From: Niklas Wolf Date: Sun, 5 Feb 2023 16:14:26 +0100 Subject: [PATCH] feat: prioritize user languages in language picker (#1614) --- components/publish/PublishLanguagePicker.vue | 32 ++++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/components/publish/PublishLanguagePicker.vue b/components/publish/PublishLanguagePicker.vue index 6e58d524..c8827d45 100644 --- a/components/publish/PublishLanguagePicker.vue +++ b/components/publish/PublishLanguagePicker.vue @@ -6,6 +6,7 @@ let { modelValue } = $defineModel<{ }>() const { t } = useI18n() +const userSettings = useUserSettings() const languageKeyword = $ref('') @@ -17,9 +18,22 @@ const fuse = new Fuse(languagesNameList, { const languages = $computed(() => languageKeyword.trim() ? fuse.search(languageKeyword).map(r => r.item) - : [...languagesNameList].sort(({ code: a }, { code: b }) => { - return a === modelValue ? -1 : b === modelValue ? 1 : a.localeCompare(b) - }), + : [...languagesNameList].filter(entry => !userSettings.value.disabledTranslationLanguages.includes(entry.code)) + .sort(({ code: a }, { code: b }) => { + return a === modelValue ? -1 : b === modelValue ? 1 : a.localeCompare(b) + }), +) + +const preferredLanguages = computed(() => { + const result = [] + for (const langCode of userSettings.value.disabledTranslationLanguages) { + const completeLang = languagesNameList.find(listEntry => listEntry.code === langCode) + if (completeLang) + result.push(completeLang) + } + return result +}, + ) function chooseLanguage(language: string) { @@ -38,6 +52,18 @@ function chooseLanguage(language: string) { >
+ +