Translate command label on top command dropdown menu (#1792)

* collect i18n with playwright

* Add command label translation

* Normalize i18n object key
This commit is contained in:
Chenlei Hu
2024-12-04 10:19:53 -08:00
committed by GitHub
parent 2caa87d35d
commit 7986aebf27
12 changed files with 317 additions and 24 deletions

View File

@@ -31,6 +31,7 @@
<script setup lang="ts">
import { useMenuItemStore } from '@/stores/menuItemStore'
import { useSettingStore } from '@/stores/settingStore'
import { normalizeI18nKey } from '@/utils/formatUtil'
import Menubar from 'primevue/menubar'
import type { MenuItem } from 'primevue/menuitem'
import { computed } from 'vue'
@@ -44,11 +45,9 @@ const dropdownDirection = computed(() =>
const menuItemsStore = useMenuItemStore()
const { t } = useI18n()
const translateMenuItem = (item: MenuItem): MenuItem => {
const translatedLabel = item.label
? t(
`menuLabels.${item.label}`,
typeof item.label === 'function' ? item.label() : item.label
)
const label = typeof item.label === 'function' ? item.label() : item.label
const translatedLabel = label
? t(`menuLabels.${normalizeI18nKey(label)}`, label)
: undefined
return {