Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
318147aa
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
720
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
318147aa
编写于
9月 02, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(i18n): h5 titleText
上级
fd8d558f
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
101 addition
and
7 deletion
+101
-7
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
packages/uni-template-compiler/lib/template/traverse.js
packages/uni-template-compiler/lib/template/traverse.js
+1
-1
packages/webpack-uni-pages-loader/lib/platforms/h5.js
packages/webpack-uni-pages-loader/lib/platforms/h5.js
+4
-1
src/core/helpers/i18n/index.js
src/core/helpers/i18n/index.js
+90
-1
src/platforms/h5/components/page/index.vue
src/platforms/h5/components/page/index.vue
+5
-3
未找到文件。
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
318147aa
此差异已折叠。
点击以展开。
packages/uni-template-compiler/lib/template/traverse.js
浏览文件 @
318147aa
...
...
@@ -431,7 +431,7 @@ function traverseRenderList (callExprNode, state) {
const
isBaidu
=
state
.
options
.
platform
.
name
===
'
mp-baidu
'
let
forValue
=
genCode
(
callExprNode
.
arguments
[
0
],
isBaidu
)
if
(
isBaidu
&&
forKey
)
{
if
(
isBaidu
&&
forKey
)
{
forValue
+=
` trackBy
${
getForKey
(
forKey
,
forIndex
,
state
)}
`
}
...
...
packages/webpack-uni-pages-loader/lib/platforms/h5.js
浏览文件 @
318147aa
...
...
@@ -444,6 +444,7 @@ module.exports = function (pagesJson, manifestJson, loader) {
return
`
import Vue from 'vue'
${
genLayoutComponentsCode
(
pagesJson
)}
const locales =
${
fs
.
existsSync
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
locale
'
))
?
'
require.context(
\'
./locale
\'
, false, /
\
.json$/)
'
:
'
{keys(){return []}}
'
}
global['____
${
h5
.
appid
}
____'] = true;
delete global['____
${
h5
.
appid
}
____'];
global.__uniConfig =
${
JSON
.
stringify
(
pagesJson
)}
;
...
...
@@ -456,10 +457,12 @@ global.__uniConfig.networkTimeout = ${JSON.stringify(networkTimeoutConfig)};
global.__uniConfig.sdkConfigs =
${
JSON
.
stringify
(
sdkConfigs
)}
;
global.__uniConfig.qqMapKey =
${
JSON
.
stringify
(
qqMapKey
)}
;
global.__uniConfig.locale =
${
JSON
.
stringify
(
locale
)}
;
global.__uniConfig.fallbackLocale =
${
JSON
.
stringify
(
manifestJson
.
fallbackLocale
)}
;
global.__uniConfig.locales = locales.keys().reduce((res,key)=>{res[key.replace(/\\.\\/(.*).json/,'$1')]=locales(key);return res},{});
global.__uniConfig.nvue =
${
JSON
.
stringify
({
'
flex-direction
'
:
getFlexDirection
(
manifestJson
[
'
app-plus
'
])
})}
global.__uniConfig.__webpack_chunk_load__ = __webpack_chunk_load__
${
genRegisterPageVueComponentsCode
(
pageComponents
)}
global.__uniRoutes=[
${
genPageRoutes
(
pageComponents
).
concat
(
genSystemRoutes
()).
join
(
'
,
'
)}
]
global.UniApp && new global.UniApp();
`
}
}
src/core/helpers/i18n/index.js
浏览文件 @
318147aa
import
{
initVueI18n
initVueI18n
,
isI18nStr
}
from
'
@dcloudio/uni-i18n
'
import
{
isStr
}
from
'
uni-shared
'
import
en
from
'
./en.json
'
import
es
from
'
./es.json
'
...
...
@@ -65,4 +69,89 @@ export function initAppLocale (Vue, appVm, locale) {
localeWatchers
.
forEach
(
watch
=>
watch
(
v
))
}
})
}
export
const
I18N_JSON_DELIMITERS
=
[
'
%
'
,
'
%
'
]
function
getLocaleMessage
()
{
const
locale
=
uni
.
getLocale
()
const
locales
=
__uniConfig
.
locales
return
(
locales
[
locale
]
||
locales
[
__uniConfig
.
fallbackLocale
]
||
locales
.
en
||
{}
)
}
export
function
formatI18n
(
message
)
{
if
(
isI18nStr
(
message
,
I18N_JSON_DELIMITERS
))
{
return
i18n
.
f
(
message
,
getLocaleMessage
(),
I18N_JSON_DELIMITERS
)
}
return
message
}
function
resolveJsonObj
(
jsonObj
,
names
)
{
if
(
names
.
length
===
1
)
{
if
(
jsonObj
)
{
const
value
=
jsonObj
[
names
[
0
]]
if
(
isStr
(
value
)
&&
isI18nStr
(
value
,
I18N_JSON_DELIMITERS
))
{
return
jsonObj
}
}
return
}
const
name
=
names
.
shift
()
return
resolveJsonObj
(
jsonObj
&&
jsonObj
[
name
],
names
)
}
export
function
defineI18nProperties
(
obj
,
names
)
{
return
names
.
map
((
name
)
=>
defineI18nProperty
(
obj
,
name
))
}
export
function
defineI18nProperty
(
obj
,
names
)
{
const
jsonObj
=
resolveJsonObj
(
obj
,
names
)
if
(
!
jsonObj
)
{
return
false
}
const
prop
=
names
[
names
.
length
-
1
]
let
value
=
jsonObj
[
prop
]
Object
.
defineProperty
(
jsonObj
,
prop
,
{
get
()
{
return
formatI18n
(
value
)
},
set
(
v
)
{
value
=
v
}
})
return
true
}
function
isEnableLocale
()
{
return
__uniConfig
.
locales
&&
!!
Object
.
keys
(
__uniConfig
.
locales
).
length
}
export
function
initNavigationBarI18n
(
navigationBar
)
{
if
(
isEnableLocale
())
{
return
defineI18nProperties
(
navigationBar
,
[
[
'
titleText
'
],
[
'
searchInput
'
,
'
placeholder
'
]
])
}
}
export
function
initPullToRefreshI18n
(
pullToRefresh
)
{
if
(
isEnableLocale
())
{
const
CAPTION
=
'
caption
'
return
defineI18nProperties
(
pullToRefresh
,
[
[
'
contentdown
'
,
CAPTION
],
[
'
contentover
'
,
CAPTION
],
[
'
contentrefresh
'
,
CAPTION
]
])
}
}
src/platforms/h5/components/page/index.vue
浏览文件 @
318147aa
...
...
@@ -7,7 +7,7 @@
<page-refresh
v-if=
"enablePullDownRefresh"
ref=
"refresh"
:color=
"refreshOptions.color"
:color=
"refreshOptions.color"
:offset=
"refreshOptions.offset"
/>
<page-body
...
...
@@ -35,7 +35,9 @@
import
{
upx2px
}
from
'
uni-helpers/index
'
import
{
initNavigationBarI18n
}
from
'
uni-helpers/i18n
'
import
{
NAVBAR_HEIGHT
}
from
'
uni-helpers/constants
'
...
...
@@ -216,7 +218,7 @@ export default {
titlePenetrate
:
yesNoParseList
[
this
.
titlePenetrate
]
},
titleNView
)
navigationBar
.
shadow
=
this
.
navigationBarShadow
initNavigationBarI18n
(
navigationBar
)
const
refreshOptions
=
Object
.
assign
({
support
:
true
,
color
:
'
#2BD009
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录