Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ChenYFan_OHHH
uni-app
提交
fda337c6
U
uni-app
项目概览
ChenYFan_OHHH
/
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,发现更多精彩内容 >>
提交
fda337c6
编写于
9月 03, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(i18n): tabBar
上级
8a88f513
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
42 addition
and
19 deletion
+42
-19
packages/uni-app-vite/src/plugin/uni/index.ts
packages/uni-app-vite/src/plugin/uni/index.ts
+1
-1
packages/uni-cli-shared/src/i18n.ts
packages/uni-cli-shared/src/i18n.ts
+4
-10
packages/uni-cli-shared/src/json/app/pages/uniConfig.ts
packages/uni-cli-shared/src/json/app/pages/uniConfig.ts
+3
-2
packages/uni-cli-shared/src/messages/index.ts
packages/uni-cli-shared/src/messages/index.ts
+2
-2
packages/uni-core/src/i18n/index.ts
packages/uni-core/src/i18n/index.ts
+1
-1
packages/uni-core/src/i18n/utils.ts
packages/uni-core/src/i18n/utils.ts
+10
-0
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+9
-1
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+9
-1
packages/uni-h5/src/framework/setup/state.ts
packages/uni-h5/src/framework/setup/state.ts
+3
-1
未找到文件。
packages/uni-app-vite/src/plugin/uni/index.ts
浏览文件 @
fda337c6
...
...
@@ -18,7 +18,7 @@ export function uniOptions(): UniVitePlugin['uni'] {
src
:
'
androidPrivacy.json
'
,
dest
:
outputDir
,
transform
(
source
)
{
const
options
=
initI18nOptions
(
platfrom
,
inputDir
)
const
options
=
initI18nOptions
(
platfrom
,
inputDir
,
false
,
true
)
if
(
!
options
)
{
return
}
...
...
packages/uni-cli-shared/src/i18n.ts
浏览文件 @
fda337c6
...
...
@@ -23,10 +23,10 @@ export function initI18nOptions(
)
if
(
warning
)
{
if
(
!
fallbackLocale
)
{
console
.
warn
(
M
[
'
i18n.fallbackLocale.
missing
'
].
replace
(
'
{locale}
'
,
locale
))
console
.
warn
(
M
[
'
i18n.fallbackLocale.
default
'
].
replace
(
'
{locale}
'
,
locale
))
}
else
if
(
locale
!==
fallbackLocale
)
{
console
.
warn
(
M
[
'
i18n.fallbackLocale.
unmatch
'
].
replace
(
'
{locale}
'
,
fallbackLocale
)
M
[
'
i18n.fallbackLocale.
missing
'
].
replace
(
'
{locale}
'
,
fallbackLocale
)
)
}
}
...
...
@@ -39,7 +39,7 @@ export function initI18nOptions(
export
const
initI18nOptionsOnce
=
once
(
initI18nOptions
)
function
initLocales
(
dir
:
string
,
withMessages
:
boolean
=
true
)
{
export
function
initLocales
(
dir
:
string
,
withMessages
:
boolean
=
true
)
{
if
(
!
fs
.
existsSync
(
dir
))
{
return
{}
}
...
...
@@ -63,18 +63,12 @@ function resolveI18nLocale(
if
(
locale
&&
locales
.
includes
(
locale
))
{
return
locale
}
let
defaultFallbackLocale
=
'
en
'
const
defaultLocales
=
[
'
zh-Hans
'
,
'
zh-Hant
'
]
if
(
platfrom
===
'
app
'
||
platfrom
===
'
h5
'
)
{
defaultLocales
.
unshift
(
'
en
'
)
}
else
{
// 小程序
defaultLocales
.
push
(
'
en
'
)
defaultFallbackLocale
=
'
zh-Hans
'
}
return
(
defaultLocales
.
find
((
locale
)
=>
locales
.
includes
(
locale
))
||
locales
[
0
]
||
defaultFallbackLocale
)
return
defaultLocales
.
find
((
locale
)
=>
locales
.
includes
(
locale
))
||
locales
[
0
]
}
packages/uni-cli-shared/src/json/app/pages/uniConfig.ts
浏览文件 @
fda337c6
import
path
from
'
path
'
import
{
initLocales
}
from
'
../../../i18n
'
import
{
normalizeNetworkTimeout
}
from
'
../../manifest
'
import
{
getNVueCompiler
,
getNVueFlexDirection
,
getNVueStyleCompiler
,
}
from
'
../manifest
'
import
{
getLocales
}
from
'
./locale
'
interface
AppUniConfig
{
pages
:
string
[]
...
...
@@ -60,7 +61,7 @@ export function normalizeAppUniConfig(
entryPagePath
:
pagesJson
.
pages
[
0
].
path
,
networkTimeout
:
normalizeNetworkTimeout
(
manifestJson
.
networkTimeout
),
tabBar
:
pagesJson
.
tabBar
,
locales
:
getLocales
(
process
.
env
.
UNI_INPUT_DIR
),
locales
:
initLocales
(
path
.
join
(
process
.
env
.
UNI_INPUT_DIR
,
'
locale
'
)
),
}
// TODO 待支持分包
return
JSON
.
stringify
(
config
)
...
...
packages/uni-cli-shared/src/messages/index.ts
浏览文件 @
fda337c6
...
...
@@ -13,8 +13,8 @@ export const M = {
'
dev.watching.end.files
'
:
'
DONE Build complete. FILES:{files}
'
,
'
stat.warn.appid
'
:
'
当前应用未配置 appid,无法使用 uni 统计,详情参考:https://ask.dcloud.net.cn/article/36303
'
,
'
i18n.fallbackLocale.
missing
'
:
'
i18n.fallbackLocale.
default
'
:
'
当前应用未在 manifest.json 配置 fallbackLocale,默认使用:{locale}
'
,
'
i18n.fallbackLocale.
unmatch
'
:
'
i18n.fallbackLocale.
missing
'
:
'
当前应用配置的 fallbackLocale 或 locale 为:{locale},但 locale 目录缺少该语言文件
'
,
}
packages/uni-core/src/i18n/index.ts
浏览文件 @
fda337c6
export
*
from
'
./useI18n
'
export
*
from
'
./messages
'
export
*
from
'
./
pageMeta
'
export
*
from
'
./
utils
'
packages/uni-core/src/i18n/
pageMeta
.ts
→
packages/uni-core/src/i18n/
utils
.ts
浏览文件 @
fda337c6
import
{
once
}
from
'
@dcloudio/uni-shared
'
import
{
defineI18nProperty
}
from
'
.
'
import
{
defineI18nProperties
}
from
'
./useI18n
'
...
...
@@ -31,3 +32,12 @@ export function initPullToRefreshI18n(
])
as
[
boolean
,
boolean
,
boolean
]
}
}
export
function
initTabBarI18n
(
tabBar
:
UniApp
.
TabBarOptions
)
{
if
(
isEnableLocale
())
{
tabBar
.
list
.
forEach
((
item
)
=>
{
defineI18nProperty
(
item
,
[
'
text
'
])
})
}
return
tabBar
}
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
fda337c6
...
...
@@ -141,6 +141,14 @@ function initNavigationBarI18n(navigationBar) {
]);
}
}
function
initTabBarI18n
(
tabBar2
)
{
if
(
isEnableLocale
())
{
tabBar2
.
list
.
forEach
((
item
)
=>
{
defineI18nProperty
(
item
,
[
"
text
"
]);
});
}
return
tabBar2
;
}
const
E
=
function
()
{
};
E
.
prototype
=
{
...
...
@@ -6697,7 +6705,7 @@ PolySymbol(process.env.NODE_ENV !== "production" ? "layout" : "l");
let
tabBar
;
function
useTabBar
()
{
if
(
!
tabBar
)
{
tabBar
=
__uniConfig
.
tabBar
&&
vue
.
reactive
(
__uniConfig
.
tabBar
);
tabBar
=
__uniConfig
.
tabBar
&&
vue
.
reactive
(
initTabBarI18n
(
__uniConfig
.
tabBar
)
);
}
return
tabBar
;
}
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
fda337c6
...
...
@@ -234,6 +234,14 @@ function initNavigationBarI18n(navigationBar) {
]);
}
}
function initTabBarI18n(tabBar2) {
if (isEnableLocale()) {
tabBar2.list.forEach((item) => {
defineI18nProperty(item, ["text"]);
});
}
return tabBar2;
}
const E = function() {
};
E.prototype = {
...
...
@@ -13414,7 +13422,7 @@ PolySymbol(process.env.NODE_ENV !== "production" ? "layout" : "l");
let tabBar;
function useTabBar() {
if (!tabBar) {
tabBar = __uniConfig.tabBar && reactive(
__uniConfig.tabBar
);
tabBar = __uniConfig.tabBar && reactive(
initTabBarI18n(__uniConfig.tabBar)
);
}
return tabBar;
}
...
...
packages/uni-h5/src/framework/setup/state.ts
浏览文件 @
fda337c6
import
{
reactive
}
from
'
vue
'
import
{
initTabBarI18n
}
from
'
@dcloudio/uni-core
'
let
tabBar
:
UniApp
.
TabBarOptions
|
undefined
export
function
useTabBar
()
{
if
(
!
tabBar
)
{
tabBar
=
__uniConfig
.
tabBar
&&
reactive
<
UniApp
.
TabBarOptions
>
(
__uniConfig
.
tabBar
)
__uniConfig
.
tabBar
&&
reactive
<
UniApp
.
TabBarOptions
>
(
initTabBarI18n
(
__uniConfig
.
tabBar
))
}
return
tabBar
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录