mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 12:40:25 +08:00
fix: 菜单翻译无法被自动读取
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { translateTitle } from '@/utils'
|
||||
import { translateTitle } from '@/locales/menu'
|
||||
|
||||
interface Props {
|
||||
showFooter?: boolean
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<script lang="ts" setup>
|
||||
import { translateTitle } from '@/locales/menu'
|
||||
import { usePermissionStore, useTabStore, useThemeStore } from '@/store'
|
||||
import { isUrl, renderIcon, translateTitle } from '@/utils'
|
||||
import { isUrl, renderIcon } from '@/utils'
|
||||
|
||||
import type { MenuInst, MenuOption } from 'naive-ui'
|
||||
import type { VNodeChild } from 'vue'
|
||||
import type { Meta, RouteType } from '~/types/router'
|
||||
|
||||
@@ -4,8 +4,8 @@ import { useGettext } from 'vue3-gettext'
|
||||
|
||||
import TheIcon from '@/components/custom/TheIcon.vue'
|
||||
import MenuCollapse from '@/layout/header/components/MenuCollapse.vue'
|
||||
import { translateTitle } from '@/locales/menu'
|
||||
import { usePermissionStore, useThemeStore } from '@/store'
|
||||
import { translateTitle } from '@/utils'
|
||||
import type { RouteType } from '~/types/router'
|
||||
|
||||
const { $gettext } = useGettext()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { translateTitle } from '@/locales/menu'
|
||||
import type { TabItem } from '@/store'
|
||||
import { useTabStore } from '@/store'
|
||||
import { translateTitle } from '@/utils'
|
||||
import ContextMenu from './components/ContextMenu.vue'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
27
web/src/locales/menu.ts
Normal file
27
web/src/locales/menu.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { $gettext } from '@/utils'
|
||||
|
||||
// 变通方法,由于 gettext 不能直接对动态标题进行翻译
|
||||
export function translateTitle(key: string): string {
|
||||
const titles: { [key: string]: string } = {
|
||||
// 主菜单标题
|
||||
Apps: $gettext('Apps'),
|
||||
Backup: $gettext('Backup'),
|
||||
Certificate: $gettext('Certificate'),
|
||||
Container: $gettext('Container'),
|
||||
Dashboard: $gettext('Dashboard'),
|
||||
Update: $gettext('Update'),
|
||||
Database: $gettext('Database'),
|
||||
Files: $gettext('Files'),
|
||||
Firewall: $gettext('Firewall'),
|
||||
Monitoring: $gettext('Monitoring'),
|
||||
Settings: $gettext('Settings'),
|
||||
Terminal: $gettext('Terminal'),
|
||||
Tasks: $gettext('Tasks'),
|
||||
Website: $gettext('Website'),
|
||||
// 应用标题
|
||||
'Rat Benchmark': $gettext('Rat Benchmark'),
|
||||
Toolbox: $gettext('Toolbox')
|
||||
}
|
||||
|
||||
return titles[key] || key
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Router } from 'vue-router'
|
||||
|
||||
import { translateTitle } from '@/locales/menu'
|
||||
import { useThemeStore } from '@/store'
|
||||
import { translateTitle } from '@/utils'
|
||||
|
||||
export function createPageTitleGuard(router: Router) {
|
||||
const themeStore = useThemeStore()
|
||||
|
||||
@@ -31,29 +31,3 @@ export function $ngettext(
|
||||
export function setCurrent(language: string) {
|
||||
gettext.current = language
|
||||
}
|
||||
|
||||
// 变通方法,由于 gettext 不能直接对动态标题进行翻译
|
||||
export function translateTitle(key: string): string {
|
||||
const titles: { [key: string]: string } = {
|
||||
// 主菜单标题
|
||||
Apps: $gettext('Apps'),
|
||||
Backup: $gettext('Backup'),
|
||||
Certificate: $gettext('Certificate'),
|
||||
Container: $gettext('Container'),
|
||||
Dashboard: $gettext('Dashboard'),
|
||||
Update: $gettext('Update'),
|
||||
Database: $gettext('Database'),
|
||||
Files: $gettext('Files'),
|
||||
Firewall: $gettext('Firewall'),
|
||||
Monitoring: $gettext('Monitoring'),
|
||||
Settings: $gettext('Settings'),
|
||||
Terminal: $gettext('Terminal'),
|
||||
Tasks: $gettext('Tasks'),
|
||||
Website: $gettext('Website'),
|
||||
// 应用标题
|
||||
'Rat Benchmark': $gettext('Rat Benchmark'),
|
||||
Toolbox: $gettext('Toolbox')
|
||||
}
|
||||
|
||||
return titles[key] || key
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export { translateTitle } from '@/locales/menu'
|
||||
export * from './auth'
|
||||
export * from './common'
|
||||
export * from './file'
|
||||
|
||||
Reference in New Issue
Block a user