Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
c54146eb
提交
c54146eb
authored
2月 25, 2023
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 优化 i18n 切换刷新导致默认回退不起作用的问题
上级
97bd02d6
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
9 行增加
和
5 行删除
+9
-5
common.ts
src/locales/lang/en/common.ts
+1
-0
common.ts
src/locales/lang/zh-CN/common.ts
+1
-0
setupI18n.ts
src/locales/setupI18n.ts
+6
-5
useLocale.ts
src/locales/useLocale.ts
+1
-0
没有找到文件。
src/locales/lang/en/common.ts
浏览文件 @
c54146eb
...
@@ -17,4 +17,5 @@ export default {
...
@@ -17,4 +17,5 @@ export default {
light
:
'Light'
,
light
:
'Light'
,
dark
:
'Dark'
,
dark
:
'Dark'
,
comingSoon
:
'Coming soon'
,
}
}
src/locales/lang/zh-CN/common.ts
浏览文件 @
c54146eb
...
@@ -17,4 +17,5 @@ export default {
...
@@ -17,4 +17,5 @@ export default {
light
:
'亮色主题'
,
light
:
'亮色主题'
,
dark
:
'黑暗主题'
,
dark
:
'黑暗主题'
,
comingSoon
:
'敬请期待'
,
}
}
src/locales/setupI18n.ts
浏览文件 @
c54146eb
...
@@ -13,21 +13,22 @@ export let i18n: ReturnType<typeof createI18n>
...
@@ -13,21 +13,22 @@ export let i18n: ReturnType<typeof createI18n>
async
function
createI18nOptions
():
Promise
<
I18nOptions
>
{
async
function
createI18nOptions
():
Promise
<
I18nOptions
>
{
const
localeStore
=
useLocaleStoreWithOut
()
const
localeStore
=
useLocaleStoreWithOut
()
const
locale
=
localeStore
.
getLocale
const
locale
=
localeStore
.
getLocale
const
defaultLocal
=
await
import
(
`./lang/
${
locale
}
.ts`
)
const
message
=
defaultLocal
.
default
?.
message
??
{}
setHtmlPageLang
(
locale
)
setHtmlPageLang
(
locale
)
setLoadLocalePool
((
loadLocalePool
)
=>
{
setLoadLocalePool
((
loadLocalePool
)
=>
{
loadLocalePool
.
push
(
locale
)
loadLocalePool
.
push
(
locale
)
})
})
const
messages
=
{}
for
(
const
lang
of
localeSetting
.
showPicker
?
availableLocales
:
[
locale
])
{
messages
[
lang
]
=
(
await
import
(
`./lang/
${
lang
}
.ts`
)).
default
?.
message
??
{}
}
return
{
return
{
legacy
:
false
,
legacy
:
false
,
locale
,
locale
,
messages
,
fallbackLocale
:
fallback
,
fallbackLocale
:
fallback
,
messages
:
{
[
locale
]:
message
,
},
availableLocales
:
availableLocales
,
availableLocales
:
availableLocales
,
sync
:
true
,
//If you don’t want to inherit locale from global scope, you need to set sync of i18n component option to false.
sync
:
true
,
//If you don’t want to inherit locale from global scope, you need to set sync of i18n component option to false.
silentTranslationWarn
:
true
,
// true - warning off
silentTranslationWarn
:
true
,
// true - warning off
...
...
src/locales/useLocale.ts
浏览文件 @
c54146eb
...
@@ -32,6 +32,7 @@ export function useLocale() {
...
@@ -32,6 +32,7 @@ export function useLocale() {
const
getShowLocalePicker
=
computed
(()
=>
localeStore
.
getShowPicker
)
const
getShowLocalePicker
=
computed
(()
=>
localeStore
.
getShowPicker
)
const
getAntdLocale
=
computed
(():
any
=>
{
const
getAntdLocale
=
computed
(():
any
=>
{
// @ts-ignore
return
i18n
.
global
.
getLocaleMessage
(
unref
(
getLocale
))?.
antdLocale
??
{}
return
i18n
.
global
.
getLocaleMessage
(
unref
(
getLocale
))?.
antdLocale
??
{}
})
})
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论