Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
anyefeiyu
uni-app
提交
9fa1655b
U
uni-app
项目概览
anyefeiyu
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9fa1655b
编写于
10月 15, 2021
作者:
d-u-a
提交者:
雪洛
10月 20, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: H5 uni.setLocale 持久化存储
上级
32559d1a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
2 deletion
+13
-2
src/core/helpers/constants.js
src/core/helpers/constants.js
+1
-0
src/core/helpers/i18n/index.js
src/core/helpers/i18n/index.js
+6
-2
src/core/service/api/ui/locale.js
src/core/service/api/ui/locale.js
+6
-0
未找到文件。
src/core/helpers/constants.js
浏览文件 @
9fa1655b
...
@@ -2,3 +2,4 @@ export const NAVBAR_HEIGHT = 44
...
@@ -2,3 +2,4 @@ export const NAVBAR_HEIGHT = 44
export
const
TABBAR_HEIGHT
=
50
export
const
TABBAR_HEIGHT
=
50
// 576:landscape phones,768:tablets,992:desktops,1200:large desktops
// 576:landscape phones,768:tablets,992:desktops,1200:large desktops
export
const
RESPONSIVE_MIN_WIDTH
=
768
export
const
RESPONSIVE_MIN_WIDTH
=
768
export
const
DC_LOCALE
=
'
__DC_LOCALE
'
src/core/helpers/i18n/index.js
浏览文件 @
9fa1655b
...
@@ -4,7 +4,11 @@ import {
...
@@ -4,7 +4,11 @@ import {
}
from
'
@dcloudio/uni-i18n
'
}
from
'
@dcloudio/uni-i18n
'
import
{
import
{
isStr
isStr
}
from
'
uni-shared
'
}
from
'
uni-shared
'
import
{
DC_LOCALE
}
from
'
../constants
'
import
en
from
'
./en.json
'
import
en
from
'
./en.json
'
import
es
from
'
./es.json
'
import
es
from
'
./es.json
'
...
@@ -23,7 +27,7 @@ const messages = {
...
@@ -23,7 +27,7 @@ const messages = {
let
locale
let
locale
if
(
__PLATFORM__
===
'
h5
'
)
{
if
(
__PLATFORM__
===
'
h5
'
)
{
locale
=
__uniConfig
.
locale
||
navigator
.
language
locale
=
(
window
.
localStorage
&&
localStorage
[
DC_LOCALE
])
||
__uniConfig
.
locale
||
navigator
.
language
}
else
if
(
__PLATFORM__
===
'
app-plus
'
)
{
}
else
if
(
__PLATFORM__
===
'
app-plus
'
)
{
if
(
typeof
weex
===
'
object
'
)
{
if
(
typeof
weex
===
'
object
'
)
{
locale
=
weex
.
requireModule
(
'
plus
'
).
getLanguage
()
locale
=
weex
.
requireModule
(
'
plus
'
).
getLanguage
()
...
...
src/core/service/api/ui/locale.js
浏览文件 @
9fa1655b
...
@@ -4,6 +4,9 @@ import {
...
@@ -4,6 +4,9 @@ import {
import
{
import
{
i18n
i18n
}
from
'
uni-helpers/i18n
'
}
from
'
uni-helpers/i18n
'
import
{
DC_LOCALE
}
from
'
uni-helpers/constants
'
export
function
getLocale
()
{
export
function
getLocale
()
{
// 优先使用 $locale
// 优先使用 $locale
...
@@ -30,6 +33,9 @@ export function setLocale (locale) {
...
@@ -30,6 +33,9 @@ export function setLocale (locale) {
)
)
})
})
weex
.
requireModule
(
'
plus
'
).
setLanguage
(
locale
)
weex
.
requireModule
(
'
plus
'
).
setLanguage
(
locale
)
}
if
(
__PLATFORM__
===
'
h5
'
)
{
window
.
localStorage
&&
(
localStorage
[
DC_LOCALE
]
=
locale
)
}
}
callbacks
.
forEach
(
callbackId
=>
{
callbacks
.
forEach
(
callbackId
=>
{
invoke
(
callbackId
,
{
locale
})
invoke
(
callbackId
,
{
locale
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录