Commit b695e195 authored by guxukai's avatar guxukai

chore: 国际化planA实现

parent f1f8a6eb
// 按钮配置 // 按钮配置
export default { export default {
baas: { login: {
button: { zh: '登录',
login: { en: 'login',
zh: '登录',
en: 'login',
},
},
}, },
} }
export default { export default {
baas: { lookup: {
menu: { zh: '开发参考',
lookup: { en: 'lookup',
zh: '开发参考', },
en: 'lookup', icons: {
}, zh: '图标库',
icons: { en: 'icons',
zh: '图标库', },
en: 'icons', i18n: {
}, zh: '国际化',
i18n: { en: 'i18n',
zh: '国际化', },
en: 'i18n', home: {
}, zh: '首页',
home: { en: 'home',
zh: '首页', },
en: 'home', chain: {
}, zh: '链管理',
chain: { en: 'chain',
zh: '链管理', },
en: 'chain', 'announce-list': {
}, zh: '公告列表',
'announce-list': { en: 'announce list',
zh: '公告列表', },
en: 'announce list', notice: {
}, zh: '站内信',
notice: { en: 'notice',
zh: '站内信', },
en: 'notice', 'alliance-chain': {
}, zh: '联盟链',
'alliance-chain': { en: 'alliance chain',
zh: '联盟链', },
en: 'alliance chain', 'parallel-chain': {
}, zh: '平行链',
'parallel-chain': { en: 'parallel chain',
zh: '平行链', },
en: 'parallel chain', 'chain-log': {
}, zh: '链日志',
'chain-log': { en: 'chain log',
zh: '链日志', },
en: 'chain log', 'address-management': {
}, zh: '地址管理',
'address-management': { en: 'address management',
zh: '地址管理', },
en: 'address management', 'key-management': {
}, zh: '密钥管理',
'key-management': { en: 'key management',
zh: '密钥管理', },
en: 'key management', openapi: {
}, zh: 'OpenApi',
openapi: { en: 'OpenApi',
zh: 'OpenApi', },
en: 'OpenApi', 'app-management': {
}, zh: '授权管理',
'app-management': { en: 'app management',
zh: '授权管理', },
en: 'app management', 'app-openapi': {
}, zh: '接口文档',
'app-openapi': { en: 'app openapi',
zh: '接口文档',
en: 'app openapi',
},
},
}, },
} }
...@@ -8,6 +8,7 @@ import zhLocale from 'element-plus/lib/locale/lang/zh-cn' ...@@ -8,6 +8,7 @@ import zhLocale from 'element-plus/lib/locale/lang/zh-cn'
import { camelCase, isPlainObject, upperFirst } from 'lodash' import { camelCase, isPlainObject, upperFirst } from 'lodash'
import path from 'path' import path from 'path'
import { modules } from '@/pages/account/views/cropped/home/components' import { modules } from '@/pages/account/views/cropped/home/components'
import { getFilename } from '@shared/utils/filename.utils'
/** /**
* 返回拆分的国际化配置 * 返回拆分的国际化配置
...@@ -35,10 +36,15 @@ function func( ...@@ -35,10 +36,15 @@ function func(
Object.entries(v).map(([key, value]) => func(value, [...parentKeys, key], config)) Object.entries(v).map(([key, value]) => func(value, [...parentKeys, key], config))
return config return config
} }
const requireModules = require.context('./config', false, /config\.ts$/iu) // e.g. $t('baas.button.login')
const requireModules = require.context('./config', false, /\.ts$/iu)
const localesList = requireModules.keys().map(filePath => { const localesList = requireModules.keys().map(filePath => {
const component = requireModules(filePath) const component = requireModules(filePath)
return component.default return {
baas: {
[getFilename(filePath)]: component.default,
},
}
}) })
export const i18n = createI18n({ export const i18n = createI18n({
locale: sessionStorage.getItem('layout') locale: sessionStorage.getItem('layout')
......
// 获取文件名(不含后缀)
export function getFilename(params: string) {
return params.replace(/(.*\/)*([^.]+).*/gi, '$2')
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment