Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
d5eda2ca
U
uni-app
项目概览
Velpro187
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d5eda2ca
编写于
4月 14, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: make i18n tree-shakeable
上级
e0a9b59d
变更
43
隐藏空白更改
内联
并排
Showing
43 changed file
with
1563 addition
and
737 deletion
+1563
-737
dist/static/logo.png
dist/static/logo.png
+0
-0
packages/global.d.ts
packages/global.d.ts
+5
-0
packages/uni-api/src/helpers/api/index.ts
packages/uni-api/src/helpers/api/index.ts
+16
-2
packages/uni-api/src/index.ts
packages/uni-api/src/index.ts
+1
-0
packages/uni-api/src/protocols/network/downloadFile.ts
packages/uni-api/src/protocols/network/downloadFile.ts
+1
-1
packages/uni-api/src/protocols/network/request.ts
packages/uni-api/src/protocols/network/request.ts
+7
-19
packages/uni-api/src/protocols/network/uploadFile.ts
packages/uni-api/src/protocols/network/uploadFile.ts
+3
-5
packages/uni-api/src/protocols/ui/popup.js
packages/uni-api/src/protocols/ui/popup.js
+0
-117
packages/uni-api/src/protocols/ui/popup.ts
packages/uni-api/src/protocols/ui/popup.ts
+104
-0
packages/uni-api/src/type.ts
packages/uni-api/src/type.ts
+1
-1
packages/uni-components/src/components/button/index.tsx
packages/uni-components/src/components/button/index.tsx
+5
-1
packages/uni-core/src/helpers/i18n/index.ts
packages/uni-core/src/helpers/i18n/index.ts
+0
-26
packages/uni-core/src/helpers/index.ts
packages/uni-core/src/helpers/index.ts
+0
-1
packages/uni-core/src/i18n/en.json
packages/uni-core/src/i18n/en.json
+0
-0
packages/uni-core/src/i18n/es.json
packages/uni-core/src/i18n/es.json
+0
-0
packages/uni-core/src/i18n/fr.json
packages/uni-core/src/i18n/fr.json
+0
-0
packages/uni-core/src/i18n/index.ts
packages/uni-core/src/i18n/index.ts
+2
-0
packages/uni-core/src/i18n/messages.ts
packages/uni-core/src/i18n/messages.ts
+634
-0
packages/uni-core/src/i18n/useI18n.ts
packages/uni-core/src/i18n/useI18n.ts
+6
-0
packages/uni-core/src/i18n/zh-Hans.json
packages/uni-core/src/i18n/zh-Hans.json
+0
-0
packages/uni-core/src/i18n/zh-Hant.json
packages/uni-core/src/i18n/zh-Hant.json
+0
-0
packages/uni-core/src/index.ts
packages/uni-core/src/index.ts
+1
-0
packages/uni-h5-vue/dist/vue.runtime.esm.js
packages/uni-h5-vue/dist/vue.runtime.esm.js
+1
-2
packages/uni-h5-vue/lib/vue.runtime.esm.js
packages/uni-h5-vue/lib/vue.runtime.esm.js
+1
-2
packages/uni-h5/dist/uni-h5.esm.js
packages/uni-h5/dist/uni-h5.esm.js
+423
-447
packages/uni-h5/src/framework/components/async-error/index.vue
...ges/uni-h5/src/framework/components/async-error/index.vue
+3
-2
packages/uni-h5/src/service/api/index.ts
packages/uni-h5/src/service/api/index.ts
+1
-0
packages/uni-h5/src/service/api/ui/popup.ts
packages/uni-h5/src/service/api/ui/popup.ts
+56
-0
packages/uni-i18n/dist/uni-i18n.cjs.js
packages/uni-i18n/dist/uni-i18n.cjs.js
+23
-25
packages/uni-i18n/dist/uni-i18n.d.ts
packages/uni-i18n/dist/uni-i18n.d.ts
+15
-10
packages/uni-i18n/dist/uni-i18n.esm.js
packages/uni-i18n/dist/uni-i18n.esm.js
+19
-26
packages/uni-i18n/src/I18n.ts
packages/uni-i18n/src/I18n.ts
+22
-11
packages/uni-i18n/src/vue-i18n.ts
packages/uni-i18n/src/vue-i18n.ts
+6
-18
packages/uni-mp-alipay/dist/uni.api.esm.js
packages/uni-mp-alipay/dist/uni.api.esm.js
+11
-2
packages/uni-mp-baidu/dist/uni.api.esm.js
packages/uni-mp-baidu/dist/uni.api.esm.js
+11
-2
packages/uni-mp-qq/dist/uni.api.esm.js
packages/uni-mp-qq/dist/uni.api.esm.js
+11
-2
packages/uni-mp-toutiao/dist/uni.api.esm.js
packages/uni-mp-toutiao/dist/uni.api.esm.js
+11
-2
packages/uni-mp-weixin/dist/uni.api.esm.js
packages/uni-mp-weixin/dist/uni.api.esm.js
+11
-2
packages/uni-quickapp-webview/dist/uni.api.esm.js
packages/uni-quickapp-webview/dist/uni.api.esm.js
+11
-2
packages/vite-plugin-uni/src/utils/define.ts
packages/vite-plugin-uni/src/utils/define.ts
+43
-1
scripts/i18n.js
scripts/i18n.js
+90
-0
scripts/utils.js
scripts/utils.js
+2
-2
yarn.lock
yarn.lock
+6
-6
未找到文件。
dist/static/logo.png
已删除
100644 → 0
浏览文件 @
e0a9b59d
3.9 KB
packages/global.d.ts
浏览文件 @
d5eda2ca
...
...
@@ -32,6 +32,11 @@ declare var __UNI_FEATURE_NAVIGATIONBAR__: boolean
declare
var
__UNI_FEATURE_NAVIGATIONBAR_BUTTONS__
:
boolean
declare
var
__UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__
:
boolean
declare
var
__UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__
:
boolean
declare
var
__UNI_FEATURE_I18N_EN__
:
boolean
declare
var
__UNI_FEATURE_I18N_ES__
:
boolean
declare
var
__UNI_FEATURE_I18N_FR__
:
boolean
declare
var
__UNI_FEATURE_I18N_ZH_HANS__
:
boolean
declare
var
__UNI_FEATURE_I18N_ZH_HANT__
:
boolean
// TODO
declare
var
__uniRoutes
:
UniApp
.
UniRoutes
declare
var
__uniConfig
:
UniApp
.
UniConfig
...
...
packages/uni-api/src/helpers/api/index.ts
浏览文件 @
d5eda2ca
import
{
extend
,
isString
,
isPlainObject
}
from
'
@vue/shared
'
import
{
extend
,
hasOwn
,
isString
,
isFunction
,
isPlainObject
,
}
from
'
@vue/shared
'
import
{
API_TYPE_ON_PROTOCOLS
,
validateProtocols
}
from
'
../protocol
'
import
{
invokeCallback
,
...
...
@@ -24,7 +30,15 @@ function formatApiArgs<T extends ApiLike>(
}
const
formatArgs
=
options
.
formatArgs
!
Object
.
keys
(
formatArgs
).
forEach
((
name
)
=>
{
formatArgs
[
name
]
!
(
args
[
0
][
name
],
params
)
const
formatterOrDefaultValue
=
formatArgs
[
name
]
!
if
(
isFunction
(
formatterOrDefaultValue
))
{
formatterOrDefaultValue
(
args
[
0
][
name
],
params
)
}
else
{
// defaultValue
if
(
!
hasOwn
(
params
,
name
))
{
params
[
name
]
=
formatterOrDefaultValue
}
}
})
return
args
}
...
...
packages/uni-api/src/index.ts
浏览文件 @
d5eda2ca
...
...
@@ -31,6 +31,7 @@ export * from './protocols/network/uploadFile'
export
*
from
'
./protocols/route/route
'
export
*
from
'
./protocols/ui/navigationBar
'
export
*
from
'
./protocols/ui/popup
'
export
*
from
'
./protocols/ui/tabBar
'
// helpers
export
{
...
...
packages/uni-api/src/protocols/network/downloadFile.ts
浏览文件 @
d5eda2ca
...
...
@@ -2,7 +2,7 @@ export const API_DOWNLOAD_FILE = 'downloadFile'
export
type
API_TYPE_DOWNLOAD_FILE
=
typeof
uni
.
downloadFile
export
const
DownloadFileOptions
:
ApiOptions
<
API_TYPE_DOWNLOAD_FILE
>
=
{
formatArgs
:
{
header
(
value
,
params
)
{
header
(
value
:
Record
<
string
,
any
>
,
params
:
Record
<
string
,
any
>
)
{
params
.
header
=
value
||
{}
},
},
...
...
packages/uni-api/src/protocols/network/request.ts
浏览文件 @
d5eda2ca
...
...
@@ -43,28 +43,16 @@ function stringifyQuery(url: string, data: Record<string, any>) {
}
export
const
RequestProtocol
:
ApiProtocol
<
API_TYPE_REQUEST
>
=
{
method
:
{
type
:
String
as
any
,
},
data
:
{
type
:
[
Object
,
String
,
Array
,
ArrayBuffer
],
},
method
:
String
as
any
,
data
:
[
Object
,
String
,
Array
,
ArrayBuffer
],
url
:
{
type
:
String
,
required
:
true
,
},
header
:
{
type
:
Object
,
},
dataType
:
{
type
:
String
,
},
responseType
:
{
type
:
String
,
},
withCredentials
:
{
type
:
Boolean
,
},
header
:
Object
,
dataType
:
String
,
responseType
:
String
,
withCredentials
:
Boolean
,
}
export
const
RequestOptions
:
ApiOptions
<
API_TYPE_REQUEST
>
=
{
...
...
@@ -88,7 +76,7 @@ export const RequestOptions: ApiOptions<API_TYPE_REQUEST> = {
params
.
url
=
stringifyQuery
(
value
,
params
.
data
)
}
},
header
(
value
,
params
)
{
header
(
value
:
Record
<
string
,
any
>
,
params
:
Record
<
string
,
any
>
)
{
const
header
=
(
params
.
header
=
value
||
{})
if
(
params
.
method
!==
HTTP_METHODS
[
0
])
{
if
(
...
...
packages/uni-api/src/protocols/network/uploadFile.ts
浏览文件 @
d5eda2ca
...
...
@@ -2,10 +2,10 @@ export const API_UPLOAD_FILE = 'uploadFile'
export
type
API_TYPE_UPLOAD_FILE
=
typeof
uni
.
uploadFile
export
const
UploadFileOptions
:
ApiOptions
<
API_TYPE_UPLOAD_FILE
>
=
{
formatArgs
:
{
header
(
value
,
params
)
{
header
(
value
:
Record
<
string
,
any
>
,
params
:
Record
<
string
,
any
>
)
{
params
.
header
=
value
||
{}
},
formData
(
value
,
params
)
{
formData
(
value
:
Record
<
string
,
any
>
,
params
:
Record
<
string
,
any
>
)
{
params
.
formData
=
value
||
{}
},
},
...
...
@@ -16,9 +16,7 @@ export const UploadFileProtocol: ApiProtocol<API_TYPE_UPLOAD_FILE> = {
type
:
String
,
required
:
true
,
},
files
:
{
type
:
Array
,
},
files
:
Array
,
filePath
:
String
,
name
:
String
,
header
:
Object
,
...
...
packages/uni-api/src/protocols/ui/popup.js
已删除
100644 → 0
浏览文件 @
e0a9b59d
import
getRealPath
from
'
uni-platform/helpers/get-real-path
'
export
const
showModal
=
{
title
:
{
type
:
String
,
default
:
''
},
content
:
{
type
:
String
,
default
:
''
},
showCancel
:
{
type
:
Boolean
,
default
:
true
},
cancelText
:
{
type
:
String
,
default
:
'
取消
'
},
cancelColor
:
{
type
:
String
,
default
:
'
#000000
'
},
confirmText
:
{
type
:
String
,
default
:
'
确定
'
},
confirmColor
:
{
type
:
String
,
default
:
'
#007aff
'
},
visible
:
{
type
:
Boolean
,
default
:
true
}
}
export
const
showToast
=
{
title
:
{
type
:
String
,
default
:
''
},
icon
:
{
default
:
'
success
'
,
validator
(
icon
,
params
)
{
if
([
'
success
'
,
'
loading
'
,
'
none
'
].
indexOf
(
icon
)
===
-
1
)
{
params
.
icon
=
'
success
'
}
}
},
image
:
{
type
:
String
,
default
:
''
,
validator
(
image
,
params
)
{
if
(
image
)
{
params
.
image
=
getRealPath
(
image
)
}
}
},
duration
:
{
type
:
Number
,
default
:
1500
},
mask
:
{
type
:
Boolean
,
default
:
false
},
visible
:
{
type
:
Boolean
,
default
:
true
}
}
export
const
showLoading
=
{
title
:
{
type
:
String
,
default
:
''
},
icon
:
{
type
:
String
,
default
:
'
loading
'
},
duration
:
{
type
:
Number
,
default
:
100000000
// 简单处理 showLoading,直接设置个大值
},
mask
:
{
type
:
Boolean
,
default
:
false
},
visible
:
{
type
:
Boolean
,
default
:
true
}
}
export
const
showActionSheet
=
{
itemList
:
{
type
:
Array
,
required
:
true
,
validator
(
itemList
,
params
)
{
if
(
!
itemList
.
length
)
{
return
'
parameter.itemList should have at least 1 item
'
}
}
},
itemColor
:
{
type
:
String
,
default
:
'
#000000
'
},
visible
:
{
type
:
Boolean
,
default
:
true
},
popover
:
{
type
:
Object
}
}
packages/uni-api/src/protocols/ui/popup.ts
0 → 100644
浏览文件 @
d5eda2ca
import
{
hasOwn
}
from
'
@vue/shared
'
import
{
useI18n
,
initI18nShowModalMsgs
}
from
'
@dcloudio/uni-core
'
import
{
PRIMARY_COLOR
}
from
'
@dcloudio//uni-shared
'
import
{
getRealPath
}
from
'
@dcloudio/uni-platform
'
export
const
API_SHOW_MODAL
=
'
showModal
'
export
type
API_TYPE_SHOW_MODAL
=
typeof
uni
.
showModal
const
{
t
}
=
useI18n
()
export
const
ShowModalProtocol
:
ApiProtocol
<
API_TYPE_SHOW_MODAL
>
=
{
title
:
String
,
content
:
String
,
showCancel
:
Boolean
,
cancelText
:
String
,
cancelColor
:
String
,
confirmText
:
String
,
confirmColor
:
String
,
}
let
isInitI18nShowModalMsgs
=
false
export
const
ShowModalOptions
:
ApiOptions
<
API_TYPE_SHOW_MODAL
>
=
{
beforeInvoke
()
{
// dynamic init (tree shaking)
if
(
isInitI18nShowModalMsgs
)
{
return
}
isInitI18nShowModalMsgs
=
true
initI18nShowModalMsgs
()
},
formatArgs
:
{
title
:
''
,
content
:
''
,
showCancel
:
true
,
cancelText
(
_value
,
params
)
{
if
(
!
hasOwn
(
params
,
'
cancelText
'
))
{
params
.
cancelText
=
t
(
'
uni.showModal.cancel
'
)
}
},
cancelColor
:
'
#000
'
,
confirmText
(
_value
,
params
)
{
if
(
!
hasOwn
(
params
,
'
confirmText
'
))
{
params
.
confirmText
=
t
(
'
uni.showModal.confirm
'
)
}
},
confirmColor
:
PRIMARY_COLOR
,
},
}
export
const
API_SHOW_TOAST
=
'
showToast
'
export
type
API_TYPE_SHOW_TOAST
=
typeof
uni
.
showToast
export
const
ShowToastProtocol
:
ApiProtocol
<
API_TYPE_SHOW_TOAST
>
=
{
title
:
String
,
icon
:
String
as
any
,
image
:
String
,
duration
:
Number
,
mask
:
Boolean
,
}
export
const
ShowToastOptions
:
ApiOptions
<
API_TYPE_SHOW_TOAST
>
=
{
formatArgs
:
{
title
:
''
,
icon
(
value
,
params
)
{
if
([
'
success
'
,
'
loading
'
,
'
none
'
].
indexOf
(
value
!
)
===
-
1
)
{
params
.
icon
=
'
success
'
}
},
image
(
value
,
params
)
{
if
(
value
)
{
params
.
image
=
getRealPath
(
value
)
}
},
duration
:
1500
,
mask
:
false
,
},
}
export
const
API_SHOW_LOADING
=
'
showLoading
'
export
type
API_TYPE_SHOW_LOADING
=
typeof
uni
.
showLoading
export
const
ShowLoadingProtocol
:
ApiProtocol
<
API_TYPE_SHOW_LOADING
>
=
{
title
:
String
,
mask
:
Boolean
,
}
export
const
ShowLoadingOptions
:
ApiOptions
<
API_TYPE_SHOW_LOADING
>
=
{
formatArgs
:
{
title
:
''
,
mask
:
false
,
},
}
export
const
API_SHOW_ACTION_SHEET
=
'
showActionSheet
'
export
type
API_TYPE_SHOW_ACTION_SHEET
=
typeof
uni
.
showActionSheet
export
const
ShowActionSheetProtocol
:
ApiProtocol
<
API_TYPE_SHOW_ACTION_SHEET
>
=
{
itemList
:
{
type
:
Array
,
required
:
true
,
},
itemColor
:
String
,
}
export
const
ShowActionSheetOptions
:
ApiOptions
<
API_TYPE_SHOW_ACTION_SHEET
>
=
{
formatArgs
:
{
itemColor
:
'
#000
'
,
},
}
export
const
API_HIDE_TOAST
=
'
hideToast
'
export
type
API_TYPE_HIDE_TOAST
=
typeof
uni
.
hideToast
export
const
API_HIDE_LOADING
=
'
hideLoading
'
export
type
API_TYPE_HIDE_LOADING
=
typeof
uni
.
hideLoading
packages/uni-api/src/type.ts
浏览文件 @
d5eda2ca
...
...
@@ -22,7 +22,7 @@ interface ApiOptions<T extends ApiLike, P = AsyncApiOptions<T>> {
beforeAll
?:
(
res
:
unknown
)
=>
void
beforeSuccess
?:
(
res
:
unknown
)
=>
void
formatArgs
?:
{
[
K
in
keyof
P
]?:
ApiArgsValidator
<
P
[
K
],
P
>
[
K
in
keyof
P
]?:
ApiArgsValidator
<
P
[
K
],
P
>
|
P
[
K
]
}
}
...
...
packages/uni-components/src/components/button/index.tsx
浏览文件 @
d5eda2ca
import
{
defineComponent
,
inject
}
from
'
vue
'
import
{
useI18n
}
from
'
@dcloudio/uni-core
'
import
{
useI18n
,
initI18nButtonMsgs
}
from
'
@dcloudio/uni-core
'
import
{
useHover
}
from
'
../../helpers/useHover
'
import
{
useBooleanAttr
}
from
'
../../helpers/useBooleanAttr
'
import
{
UniFormCtx
,
uniFormKey
}
from
'
../form
'
if
(
__PLATFORM__
===
'
app-plus
'
)
{
initI18nButtonMsgs
()
}
export
default
defineComponent
({
name
:
'
Button
'
,
props
:
{
...
...
packages/uni-core/src/helpers/i18n/index.ts
已删除
100644 → 0
浏览文件 @
e0a9b59d
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
import
en
from
'
./en.json
'
import
es
from
'
./es.json
'
import
fr
from
'
./fr.json
'
import
zhHans
from
'
./zh-Hans.json
'
import
zhHant
from
'
./zh-Hant.json
'
const
messages
=
{
en
,
es
,
fr
,
'
zh-Hans
'
:
zhHans
,
'
zh-Hant
'
:
zhHant
,
}
const
fallbackLocale
=
'
en
'
const
i18n
=
/*#__PURE__*/
initVueI18n
(
__PLATFORM__
===
'
app-plus
'
||
__PLATFORM__
===
'
h5
'
?
messages
:
{},
fallbackLocale
)
export
function
useI18n
()
{
return
i18n
}
packages/uni-core/src/helpers/index.ts
浏览文件 @
d5eda2ca
export
*
from
'
./util
'
export
*
from
'
./icon
'
export
*
from
'
./i18n
'
export
*
from
'
./getRealRoute
'
export
*
from
'
./getWindowOffset
'
packages/uni-core/src/
helpers/
i18n/en.json
→
packages/uni-core/src/i18n/en.json
浏览文件 @
d5eda2ca
文件已移动
packages/uni-core/src/
helpers/
i18n/es.json
→
packages/uni-core/src/i18n/es.json
浏览文件 @
d5eda2ca
文件已移动
packages/uni-core/src/
helpers/
i18n/fr.json
→
packages/uni-core/src/i18n/fr.json
浏览文件 @
d5eda2ca
文件已移动
packages/uni-core/src/i18n/index.ts
0 → 100644
浏览文件 @
d5eda2ca
export
*
from
'
./useI18n
'
export
*
from
'
./messages
'
packages/uni-core/src/i18n/messages.ts
0 → 100644
浏览文件 @
d5eda2ca
// This file is created by scripts/i18n.js
// Do not modify this file!!!!!!!!!
import
{
LOCALE_EN
,
LOCALE_ES
,
LOCALE_FR
,
LOCALE_ZH_HANS
,
LOCALE_ZH_HANT
,
}
from
'
@dcloudio/uni-i18n
'
import
{
useI18n
}
from
'
./useI18n
'
const
i18n
=
useI18n
()
function
normalizeMessages
(
namespace
:
string
,
messages
:
Record
<
string
,
string
>
)
{
return
Object
.
keys
(
messages
).
reduce
<
Record
<
string
,
string
>>
((
res
,
name
)
=>
{
res
[
namespace
+
name
]
=
messages
[
name
]
return
res
},
{})
}
export
function
initI18nAppMsgs
()
{
const
name
=
'
uni.app.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
quit
:
'
Press back button again to exit
'
})
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
quit
:
'
Pulse otra vez para salir
'
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
quit
:
"
Appuyez à nouveau pour quitter l'application
"
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
quit
:
'
再按一次退出应用
'
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
quit
:
'
再按一次退出應用
'
})
)
}
}
export
function
initI18nAsyncMsgs
()
{
const
name
=
'
uni.async.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
error
:
'
The connection timed out, click the screen to try again.
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
error
:
'
Se agotó el tiempo de conexión, haga clic en la pantalla para volver a intentarlo.
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
error
:
"
La connexion a expiré, cliquez sur l'écran pour réessayer.
"
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
error
:
'
连接服务器超时,点击屏幕重试
'
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
error
:
'
連接服務器超時,點擊屏幕重試
'
})
)
}
}
export
function
initI18nShowActionSheetMsgs
()
{
const
name
=
'
uni.showActionSheet.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
cancel
:
'
Cancel
'
}))
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
cancel
:
'
Cancelar
'
}))
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
cancel
:
'
Annuler
'
}))
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
cancel
:
'
取消
'
}))
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
cancel
:
'
取消
'
}))
}
}
export
function
initI18nShowToastMsgs
()
{
const
name
=
'
uni.showToast.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
unpaired
:
'
Please note showToast must be paired with hideToast
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
unpaired
:
'
Tenga en cuenta que showToast debe estar emparejado con hideToast
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
unpaired
:
'
Veuillez noter que showToast doit être associé à hideToast
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
unpaired
:
'
请注意 showToast 与 hideToast 必须配对使用
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
unpaired
:
'
請注意 showToast 與 hideToast 必須配對使用
'
,
})
)
}
}
export
function
initI18nShowLoadingMsgs
()
{
const
name
=
'
uni.showLoading.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
unpaired
:
'
Please note showLoading must be paired with hideLoading
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
unpaired
:
'
Tenga en cuenta que showLoading debe estar emparejado con hideLoading
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
unpaired
:
'
Veuillez noter que showLoading doit être associé à hideLoading
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
unpaired
:
'
请注意 showLoading 与 hideLoading 必须配对使用
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
unpaired
:
'
請注意 showLoading 與 hideLoading 必須配對使用
'
,
})
)
}
}
export
function
initI18nShowModalMsgs
()
{
const
name
=
'
uni.showModal.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
cancel
:
'
Cancel
'
,
confirm
:
'
OK
'
})
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
cancel
:
'
Cancelar
'
,
confirm
:
'
OK
'
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
cancel
:
'
Annuler
'
,
confirm
:
'
OK
'
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
cancel
:
'
取消
'
,
confirm
:
'
确定
'
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
cancel
:
'
取消
'
,
confirm
:
'
確定
'
})
)
}
}
export
function
initI18nChooseImageMsgs
()
{
const
name
=
'
uni.chooseImage.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
cancel
:
'
Cancel
'
,
'
sourceType.album
'
:
'
Album
'
,
'
sourceType.camera
'
:
'
Camera
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
cancel
:
'
Cancelar
'
,
'
sourceType.album
'
:
'
Álbum
'
,
'
sourceType.camera
'
:
'
Cámara
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
cancel
:
'
Annuler
'
,
'
sourceType.album
'
:
'
Album
'
,
'
sourceType.camera
'
:
'
Caméra
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
cancel
:
'
取消
'
,
'
sourceType.album
'
:
'
从相册选择
'
,
'
sourceType.camera
'
:
'
拍摄
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
cancel
:
'
取消
'
,
'
sourceType.album
'
:
'
從相冊選擇
'
,
'
sourceType.camera
'
:
'
拍攝
'
,
})
)
}
}
export
function
initI18nChooseVideoMsgs
()
{
const
name
=
'
uni.chooseVideo.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
cancel
:
'
Cancel
'
,
'
sourceType.album
'
:
'
Album
'
,
'
sourceType.camera
'
:
'
Camera
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
cancel
:
'
Cancelar
'
,
'
sourceType.album
'
:
'
Álbum
'
,
'
sourceType.camera
'
:
'
Cámara
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
cancel
:
'
Annuler
'
,
'
sourceType.album
'
:
'
Album
'
,
'
sourceType.camera
'
:
'
Caméra
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
cancel
:
'
取消
'
,
'
sourceType.album
'
:
'
从相册选择
'
,
'
sourceType.camera
'
:
'
拍摄
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
cancel
:
'
取消
'
,
'
sourceType.album
'
:
'
從相冊選擇
'
,
'
sourceType.camera
'
:
'
拍攝
'
,
})
)
}
}
export
function
initI18nPreviewImageMsgs
()
{
const
name
=
'
uni.previewImage.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
cancel
:
'
Cancel
'
,
'
button.save
'
:
'
Save Image
'
,
'
save.success
'
:
'
Saved successfully
'
,
'
save.fail
'
:
'
Save failed
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
cancel
:
'
Cancelar
'
,
'
button.save
'
:
'
Guardar imagen
'
,
'
save.success
'
:
'
Guardado exitosamente
'
,
'
save.fail
'
:
'
Error al guardar
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
cancel
:
'
Annuler
'
,
'
button.save
'
:
'
Guardar imagen
'
,
'
save.success
'
:
'
Enregistré avec succès
'
,
'
save.fail
'
:
'
Échec de la sauvegarde
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
cancel
:
'
取消
'
,
'
button.save
'
:
'
保存图像
'
,
'
save.success
'
:
'
保存图像到相册成功
'
,
'
save.fail
'
:
'
保存图像到相册失败
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
cancel
:
'
取消
'
,
'
button.save
'
:
'
保存圖像
'
,
'
save.success
'
:
'
保存圖像到相冊成功
'
,
'
save.fail
'
:
'
保存圖像到相冊失敗
'
,
})
)
}
}
export
function
initI18nSetClipboardDataMsgs
()
{
const
name
=
'
uni.setClipboardData.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
success
:
'
Content copied
'
}))
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
success
:
'
Contenido copiado
'
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
success
:
'
Contenu copié
'
}))
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
success
:
'
内容已复制
'
}))
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
success
:
'
內容已復制
'
}))
}
}
export
function
initI18nScanCodeMsgs
()
{
const
name
=
'
uni.scanCode.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
title
:
'
Scan code
'
,
album
:
'
Album
'
,
fail
:
'
Recognition failure
'
,
'
flash.on
'
:
'
Tap to turn light on
'
,
'
flash.off
'
:
'
Tap to turn light off
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
title
:
'
Código de escaneo
'
,
album
:
'
Álbum
'
,
fail
:
'
Échec de la reconnaissance
'
,
'
flash.on
'
:
'
Toque para encender la luz
'
,
'
flash.off
'
:
'
Toque para apagar la luz
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
title
:
'
Code d’analyse
'
,
album
:
'
Album
'
,
fail
:
'
Fallo de reconocimiento
'
,
'
flash.on
'
:
"
Appuyez pour activer l'éclairage
"
,
'
flash.off
'
:
"
Appuyez pour désactiver l'éclairage
"
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
title
:
'
扫码
'
,
album
:
'
相册
'
,
fail
:
'
识别失败
'
,
'
flash.on
'
:
'
轻触照亮
'
,
'
flash.off
'
:
'
轻触关闭
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
title
:
'
掃碼
'
,
album
:
'
相冊
'
,
fail
:
'
識別失敗
'
,
'
flash.on
'
:
'
輕觸照亮
'
,
'
flash.off
'
:
'
輕觸關閉
'
,
})
)
}
}
export
function
initI18nStartSoterAuthenticationMsgs
()
{
const
name
=
'
uni.startSoterAuthentication.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
authContent
:
'
Fingerprint recognition
'
})
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
authContent
:
'
Reconocimiento de huellas dactilares
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
authContent
:
"
Reconnaissance de l'empreinte digitale
"
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
authContent
:
'
指纹识别中...
'
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
authContent
:
'
指紋識別中...
'
})
)
}
}
export
function
initI18nPickerMsgs
()
{
const
name
=
'
uni.picker.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
done
:
'
Done
'
,
cancel
:
'
Cancel
'
})
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
done
:
'
OK
'
,
cancel
:
'
Cancelar
'
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
done
:
'
OK
'
,
cancel
:
'
Annuler
'
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
done
:
'
完成
'
,
cancel
:
'
取消
'
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
done
:
'
完成
'
,
cancel
:
'
取消
'
})
)
}
}
export
function
initI18nVideoMsgs
()
{
const
name
=
'
uni.video.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
danmu
:
'
Danmu
'
,
volume
:
'
Volume
'
})
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
danmu
:
'
Danmu
'
,
volume
:
'
Volumen
'
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
danmu
:
'
Danmu
'
,
volume
:
'
Le Volume
'
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
danmu
:
'
弹幕
'
,
volume
:
'
音量
'
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
danmu
:
'
彈幕
'
,
volume
:
'
音量
'
})
)
}
}
export
function
initI18nButtonMsgs
()
{
const
name
=
'
uni.button.
'
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
'
feedback.title
'
:
'
feedback
'
,
'
feedback.send
'
:
'
send
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
'
feedback.title
'
:
'
realimentación
'
,
'
feedback.send
'
:
'
enviar
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
'
feedback.title
'
:
"
retour d'information
"
,
'
feedback.send
'
:
'
envoyer
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
'
feedback.title
'
:
'
问题反馈
'
,
'
feedback.send
'
:
'
发送
'
,
})
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
'
feedback.title
'
:
'
問題反饋
'
,
'
feedback.send
'
:
'
發送
'
,
})
)
}
}
packages/uni-core/src/i18n/useI18n.ts
0 → 100644
浏览文件 @
d5eda2ca
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
const
i18n
=
initVueI18n
()
export
function
useI18n
()
{
return
i18n
}
packages/uni-core/src/
helpers/
i18n/zh-Hans.json
→
packages/uni-core/src/i18n/zh-Hans.json
浏览文件 @
d5eda2ca
文件已移动
packages/uni-core/src/
helpers/
i18n/zh-Hant.json
→
packages/uni-core/src/i18n/zh-Hant.json
浏览文件 @
d5eda2ca
文件已移动
packages/uni-core/src/index.ts
浏览文件 @
d5eda2ca
export
*
from
'
./i18n
'
export
*
from
'
./view
'
export
*
from
'
./service
'
export
*
from
'
./helpers
'
packages/uni-h5-vue/dist/vue.runtime.esm.js
浏览文件 @
d5eda2ca
...
...
@@ -6982,7 +6982,6 @@ function applyOptions$1(instance, options, deferredData = [], deferredWatch = []
}
}
}
// fixed by xxxxxx
function
callSyncHook
(
name
,
type
,
options
,
instance
,
globalMixins
)
{
for
(
let
i
=
0
;
i
<
globalMixins
.
length
;
i
++
)
{
callHookWithMixinAndExtends
(
name
,
type
,
globalMixins
[
i
],
instance
);
...
...
@@ -9491,4 +9490,4 @@ function initApp(app) {
}
}
export
{
BaseTransition
,
Comment
,
Fragment
,
KeepAlive
,
Static
,
Suspense
,
Teleport
,
Text
,
Transition
,
TransitionGroup
,
call
SyncHook
,
call
WithAsyncErrorHandling
,
callWithErrorHandling
,
cloneVNode
,
compile$1
as
compile
,
computed$1
as
computed
,
createApp
,
createBlock
,
createCommentVNode
,
createHook
,
createHydrationRenderer
,
createRenderer
,
createSSRApp
,
createSlots
,
createStaticVNode
,
createTextVNode
,
createVNode
,
createApp
as
createVueApp
,
createSSRApp
as
createVueSSRApp
,
customRef
,
defineAsyncComponent
,
defineComponent
,
defineEmit
,
defineProps
,
devtools
,
getCurrentInstance
,
getTransitionRawChildren
,
h
,
handleError
,
hydrate
,
initApp
,
initCustomFormatter
,
inject
,
injectHook
,
isInSSRComponentSetup
,
isProxy
,
isReactive
,
isReadonly
,
isRef
,
isRuntimeOnly
,
isVNode
,
markRaw
,
mergeProps
,
nextTick
,
onActivated
,
onAddToFavorites
,
onBackPress
,
onBeforeActivate
,
onBeforeDeactivate
,
onBeforeMount
,
onBeforeUnmount
,
onBeforeUpdate
,
onDeactivated
,
onError
,
onErrorCaptured
,
onHide
,
onLaunch
,
onMounted
,
onNavigationBarButtonTap
,
onNavigationBarSearchInputChanged
,
onNavigationBarSearchInputClicked
,
onNavigationBarSearchInputConfirmed
,
onNavigationBarSearchInputFocusChanged
,
onPageNotFound
,
onPageScroll
,
onPullDownRefresh
,
onReachBottom
,
onReady
,
onRenderTracked
,
onRenderTriggered
,
onResize
,
onShareAppMessage
,
onShareTimeline
,
onShow
,
onTabItemTap
,
onThemeChange
,
onUnhandledRejection
,
onUnload
,
onUnmounted
,
onUpdated
,
openBlock
,
popScopeId
,
provide
,
proxyRefs
,
pushScopeId
,
queuePostFlushCb
,
reactive
,
readonly
,
ref
,
registerRuntimeCompiler
,
render
,
renderList
,
renderSlot
,
resolveComponent
,
resolveDirective
,
resolveDynamicComponent
,
resolveTransitionHooks
,
setBlockTracking
,
setDevtoolsHook
,
setTransitionHooks
,
shallowReactive
,
shallowReadonly
,
shallowRef
,
ssrContextKey
,
ssrUtils
,
toHandlers
,
toRaw
,
toRef
,
toRefs
,
transformVNodeArgs
,
triggerRef
,
unref
,
useContext
,
useCssModule
,
useCssVars
,
useSSRContext
,
useTransitionState
,
vModelCheckbox
,
vModelDynamic
,
vModelRadio
,
vModelSelect
,
vModelText
,
vShow
,
version
,
warn
,
watch
,
watchEffect
,
withCtx
,
withDirectives
,
withKeys
,
withModifiers
,
withScopeId
};
export
{
BaseTransition
,
Comment
,
Fragment
,
KeepAlive
,
Static
,
Suspense
,
Teleport
,
Text
,
Transition
,
TransitionGroup
,
callWithAsyncErrorHandling
,
callWithErrorHandling
,
cloneVNode
,
compile$1
as
compile
,
computed$1
as
computed
,
createApp
,
createBlock
,
createCommentVNode
,
createHook
,
createHydrationRenderer
,
createRenderer
,
createSSRApp
,
createSlots
,
createStaticVNode
,
createTextVNode
,
createVNode
,
createApp
as
createVueApp
,
createSSRApp
as
createVueSSRApp
,
customRef
,
defineAsyncComponent
,
defineComponent
,
defineEmit
,
defineProps
,
devtools
,
getCurrentInstance
,
getTransitionRawChildren
,
h
,
handleError
,
hydrate
,
initApp
,
initCustomFormatter
,
inject
,
injectHook
,
isInSSRComponentSetup
,
isProxy
,
isReactive
,
isReadonly
,
isRef
,
isRuntimeOnly
,
isVNode
,
markRaw
,
mergeProps
,
nextTick
,
onActivated
,
onAddToFavorites
,
onBackPress
,
onBeforeActivate
,
onBeforeDeactivate
,
onBeforeMount
,
onBeforeUnmount
,
onBeforeUpdate
,
onDeactivated
,
onError
,
onErrorCaptured
,
onHide
,
onLaunch
,
onMounted
,
onNavigationBarButtonTap
,
onNavigationBarSearchInputChanged
,
onNavigationBarSearchInputClicked
,
onNavigationBarSearchInputConfirmed
,
onNavigationBarSearchInputFocusChanged
,
onPageNotFound
,
onPageScroll
,
onPullDownRefresh
,
onReachBottom
,
onReady
,
onRenderTracked
,
onRenderTriggered
,
onResize
,
onShareAppMessage
,
onShareTimeline
,
onShow
,
onTabItemTap
,
onThemeChange
,
onUnhandledRejection
,
onUnload
,
onUnmounted
,
onUpdated
,
openBlock
,
popScopeId
,
provide
,
proxyRefs
,
pushScopeId
,
queuePostFlushCb
,
reactive
,
readonly
,
ref
,
registerRuntimeCompiler
,
render
,
renderList
,
renderSlot
,
resolveComponent
,
resolveDirective
,
resolveDynamicComponent
,
resolveTransitionHooks
,
setBlockTracking
,
setDevtoolsHook
,
setTransitionHooks
,
shallowReactive
,
shallowReadonly
,
shallowRef
,
ssrContextKey
,
ssrUtils
,
toHandlers
,
toRaw
,
toRef
,
toRefs
,
transformVNodeArgs
,
triggerRef
,
unref
,
useContext
,
useCssModule
,
useCssVars
,
useSSRContext
,
useTransitionState
,
vModelCheckbox
,
vModelDynamic
,
vModelRadio
,
vModelSelect
,
vModelText
,
vShow
,
version
,
warn
,
watch
,
watchEffect
,
withCtx
,
withDirectives
,
withKeys
,
withModifiers
,
withScopeId
};
packages/uni-h5-vue/lib/vue.runtime.esm.js
浏览文件 @
d5eda2ca
...
...
@@ -6982,7 +6982,6 @@ function applyOptions(instance, options, deferredData = [], deferredWatch = [],
}
}
}
// fixed by xxxxxx
function
callSyncHook
(
name
,
type
,
options
,
instance
,
globalMixins
)
{
for
(
let
i
=
0
;
i
<
globalMixins
.
length
;
i
++
)
{
callHookWithMixinAndExtends
(
name
,
type
,
globalMixins
[
i
],
instance
);
...
...
@@ -9405,4 +9404,4 @@ const compile$1 = () => {
}
};
export
{
BaseTransition
,
Comment
,
Fragment
,
KeepAlive
,
Static
,
Suspense
,
Teleport
,
Text
,
Transition
,
TransitionGroup
,
call
SyncHook
,
call
WithAsyncErrorHandling
,
callWithErrorHandling
,
cloneVNode
,
compile$1
as
compile
,
computed$1
as
computed
,
createApp
,
createBlock
,
createCommentVNode
,
createHydrationRenderer
,
createRenderer
,
createSSRApp
,
createSlots
,
createStaticVNode
,
createTextVNode
,
createVNode
,
createApp
as
createVueApp
,
createSSRApp
as
createVueSSRApp
,
customRef
,
defineAsyncComponent
,
defineComponent
,
defineEmit
,
defineProps
,
devtools
,
getCurrentInstance
,
getTransitionRawChildren
,
h
,
handleError
,
hydrate
,
initCustomFormatter
,
inject
,
injectHook
,
isInSSRComponentSetup
,
isProxy
,
isReactive
,
isReadonly
,
isRef
,
isRuntimeOnly
,
isVNode
,
markRaw
,
mergeProps
,
nextTick
,
onActivated
,
onBeforeActivate
,
onBeforeDeactivate
,
onBeforeMount
,
onBeforeUnmount
,
onBeforeUpdate
,
onDeactivated
,
onErrorCaptured
,
onMounted
,
onRenderTracked
,
onRenderTriggered
,
onUnmounted
,
onUpdated
,
openBlock
,
popScopeId
,
provide
,
proxyRefs
,
pushScopeId
,
queuePostFlushCb
,
reactive
,
readonly
,
ref
,
registerRuntimeCompiler
,
render
,
renderList
,
renderSlot
,
resolveComponent
,
resolveDirective
,
resolveDynamicComponent
,
resolveTransitionHooks
,
setBlockTracking
,
setDevtoolsHook
,
setTransitionHooks
,
shallowReactive
,
shallowReadonly
,
shallowRef
,
ssrContextKey
,
ssrUtils
,
toHandlers
,
toRaw
,
toRef
,
toRefs
,
transformVNodeArgs
,
triggerRef
,
unref
,
useContext
,
useCssModule
,
useCssVars
,
useSSRContext
,
useTransitionState
,
vModelCheckbox
,
vModelDynamic
,
vModelRadio
,
vModelSelect
,
vModelText
,
vShow
,
version
,
warn
,
watch
,
watchEffect
,
withCtx
,
withDirectives
,
withKeys
,
withModifiers
,
withScopeId
};
export
{
BaseTransition
,
Comment
,
Fragment
,
KeepAlive
,
Static
,
Suspense
,
Teleport
,
Text
,
Transition
,
TransitionGroup
,
callWithAsyncErrorHandling
,
callWithErrorHandling
,
cloneVNode
,
compile$1
as
compile
,
computed$1
as
computed
,
createApp
,
createBlock
,
createCommentVNode
,
createHydrationRenderer
,
createRenderer
,
createSSRApp
,
createSlots
,
createStaticVNode
,
createTextVNode
,
createVNode
,
createApp
as
createVueApp
,
createSSRApp
as
createVueSSRApp
,
customRef
,
defineAsyncComponent
,
defineComponent
,
defineEmit
,
defineProps
,
devtools
,
getCurrentInstance
,
getTransitionRawChildren
,
h
,
handleError
,
hydrate
,
initCustomFormatter
,
inject
,
injectHook
,
isInSSRComponentSetup
,
isProxy
,
isReactive
,
isReadonly
,
isRef
,
isRuntimeOnly
,
isVNode
,
markRaw
,
mergeProps
,
nextTick
,
onActivated
,
onBeforeActivate
,
onBeforeDeactivate
,
onBeforeMount
,
onBeforeUnmount
,
onBeforeUpdate
,
onDeactivated
,
onErrorCaptured
,
onMounted
,
onRenderTracked
,
onRenderTriggered
,
onUnmounted
,
onUpdated
,
openBlock
,
popScopeId
,
provide
,
proxyRefs
,
pushScopeId
,
queuePostFlushCb
,
reactive
,
readonly
,
ref
,
registerRuntimeCompiler
,
render
,
renderList
,
renderSlot
,
resolveComponent
,
resolveDirective
,
resolveDynamicComponent
,
resolveTransitionHooks
,
setBlockTracking
,
setDevtoolsHook
,
setTransitionHooks
,
shallowReactive
,
shallowReadonly
,
shallowRef
,
ssrContextKey
,
ssrUtils
,
toHandlers
,
toRaw
,
toRef
,
toRefs
,
transformVNodeArgs
,
triggerRef
,
unref
,
useContext
,
useCssModule
,
useCssVars
,
useSSRContext
,
useTransitionState
,
vModelCheckbox
,
vModelDynamic
,
vModelRadio
,
vModelSelect
,
vModelText
,
vShow
,
version
,
warn
,
watch
,
watchEffect
,
withCtx
,
withDirectives
,
withKeys
,
withModifiers
,
withScopeId
};
packages/uni-h5/dist/uni-h5.esm.js
浏览文件 @
d5eda2ca
import
{
isFunction
,
extend
,
isPlainObject
,
invokeArrayFns
,
isString
,
hasOwn
as
hasOwn$1
,
hyphenate
,
isArray
,
isObject
as
isObject$1
,
capitalize
,
toRawType
,
makeMap
as
makeMap$1
,
isPromise
}
from
"
@vue/shared
"
;
import
{
injectHook
,
isInSSRComponentSetup
,
createVNode
,
inject
,
provide
,
reactive
,
computed
,
nextTick
,
getCurrentInstance
,
onBeforeMount
,
onMounted
,
onBeforeActivate
,
onBeforeDeactivate
,
openBlock
,
createBlock
,
mergeProps
,
toDisplayString
,
ref
,
defineComponent
,
resolveComponent
,
toHandlers
,
renderSlot
,
createCommentVNode
,
onBeforeUnmount
,
withModifiers
,
withDirectives
,
vShow
,
vModelDynamic
,
createTextVNode
,
Fragment
,
renderList
,
vModelText
,
watch
,
withCtx
,
KeepAlive
,
resolveDynamicComponent
}
from
"
vue
"
;
import
{
passive
,
NAVBAR_HEIGHT
,
removeLeadingSlash
,
plusReady
,
debounce
,
PRIMARY_COLOR
,
getLen
}
from
"
@dcloudio/uni-shared
"
;
import
{
passive
,
NAVBAR_HEIGHT
,
removeLeadingSlash
,
plusReady
,
debounce
,
PRIMARY_COLOR
as
PRIMARY_COLOR$1
,
getLen
}
from
"
@dcloudio/uni-shared
"
;
import
{
useRoute
,
createRouter
,
createWebHistory
,
createWebHashHistory
,
isNavigationFailure
,
RouterView
}
from
"
vue-router
"
;
function
applyOptions
(
options
,
instance2
,
publicThis
)
{
Object
.
keys
(
options
).
forEach
((
name
)
=>
{
...
...
@@ -106,6 +106,300 @@ function initApp$1(app) {
globalProperties
.
$applyOptions
=
applyOptions
;
}
}
const
isObject
=
(
val
)
=>
val
!==
null
&&
typeof
val
===
"
object
"
;
class
BaseFormatter
{
constructor
()
{
this
.
_caches
=
Object
.
create
(
null
);
}
interpolate
(
message
,
values
)
{
if
(
!
values
)
{
return
[
message
];
}
let
tokens
=
this
.
_caches
[
message
];
if
(
!
tokens
)
{
tokens
=
parse
(
message
);
this
.
_caches
[
message
]
=
tokens
;
}
return
compile
(
tokens
,
values
);
}
}
const
RE_TOKEN_LIST_VALUE
=
/^
(?:\d)
+/
;
const
RE_TOKEN_NAMED_VALUE
=
/^
(?:\w)
+/
;
function
parse
(
format
)
{
const
tokens
=
[];
let
position
=
0
;
let
text2
=
""
;
while
(
position
<
format
.
length
)
{
let
char
=
format
[
position
++
];
if
(
char
===
"
{
"
)
{
if
(
text2
)
{
tokens
.
push
({
type
:
"
text
"
,
value
:
text2
});
}
text2
=
""
;
let
sub
=
""
;
char
=
format
[
position
++
];
while
(
char
!==
void
0
&&
char
!==
"
}
"
)
{
sub
+=
char
;
char
=
format
[
position
++
];
}
const
isClosed
=
char
===
"
}
"
;
const
type
=
RE_TOKEN_LIST_VALUE
.
test
(
sub
)
?
"
list
"
:
isClosed
&&
RE_TOKEN_NAMED_VALUE
.
test
(
sub
)
?
"
named
"
:
"
unknown
"
;
tokens
.
push
({
value
:
sub
,
type
});
}
else
if
(
char
===
"
%
"
)
{
if
(
format
[
position
]
!==
"
{
"
)
{
text2
+=
char
;
}
}
else
{
text2
+=
char
;
}
}
text2
&&
tokens
.
push
({
type
:
"
text
"
,
value
:
text2
});
return
tokens
;
}
function
compile
(
tokens
,
values
)
{
const
compiled
=
[];
let
index2
=
0
;
const
mode
=
Array
.
isArray
(
values
)
?
"
list
"
:
isObject
(
values
)
?
"
named
"
:
"
unknown
"
;
if
(
mode
===
"
unknown
"
)
{
return
compiled
;
}
while
(
index2
<
tokens
.
length
)
{
const
token
=
tokens
[
index2
];
switch
(
token
.
type
)
{
case
"
text
"
:
compiled
.
push
(
token
.
value
);
break
;
case
"
list
"
:
compiled
.
push
(
values
[
parseInt
(
token
.
value
,
10
)]);
break
;
case
"
named
"
:
if
(
mode
===
"
named
"
)
{
compiled
.
push
(
values
[
token
.
value
]);
}
break
;
}
index2
++
;
}
return
compiled
;
}
const
LOCALE_ZH_HANS
=
"
zh-Hans
"
;
const
LOCALE_ZH_HANT
=
"
zh-Hant
"
;
const
LOCALE_EN
=
"
en
"
;
const
LOCALE_FR
=
"
fr
"
;
const
LOCALE_ES
=
"
es
"
;
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
;
const
hasOwn
=
(
val
,
key
)
=>
hasOwnProperty
.
call
(
val
,
key
);
const
defaultFormatter
=
new
BaseFormatter
();
function
include
(
str
,
parts
)
{
return
!!
parts
.
find
((
part
)
=>
str
.
indexOf
(
part
)
!==
-
1
);
}
function
startsWith
(
str
,
parts
)
{
return
parts
.
find
((
part
)
=>
str
.
indexOf
(
part
)
===
0
);
}
function
normalizeLocale
(
locale
,
messages
)
{
if
(
!
locale
)
{
return
;
}
locale
=
locale
.
trim
().
replace
(
/_/g
,
"
-
"
);
if
(
messages
[
locale
])
{
return
locale
;
}
locale
=
locale
.
toLowerCase
();
if
(
locale
.
indexOf
(
"
zh
"
)
===
0
)
{
if
(
locale
.
indexOf
(
"
-hans
"
)
!==
-
1
)
{
return
LOCALE_ZH_HANS
;
}
if
(
locale
.
indexOf
(
"
-hant
"
)
!==
-
1
)
{
return
LOCALE_ZH_HANT
;
}
if
(
include
(
locale
,
[
"
-tw
"
,
"
-hk
"
,
"
-mo
"
,
"
-cht
"
]))
{
return
LOCALE_ZH_HANT
;
}
return
LOCALE_ZH_HANS
;
}
const
lang
=
startsWith
(
locale
,
[
LOCALE_EN
,
LOCALE_FR
,
LOCALE_ES
]);
if
(
lang
)
{
return
lang
;
}
}
class
I18n
{
constructor
({
locale
,
fallbackLocale
,
messages
,
watcher
,
formater
})
{
this
.
locale
=
LOCALE_EN
;
this
.
fallbackLocale
=
LOCALE_EN
;
this
.
message
=
{};
this
.
messages
=
{};
this
.
watchers
=
[];
if
(
fallbackLocale
)
{
this
.
fallbackLocale
=
fallbackLocale
;
}
this
.
formater
=
formater
||
defaultFormatter
;
this
.
messages
=
messages
||
{};
this
.
setLocale
(
locale
);
if
(
watcher
)
{
this
.
watchLocale
(
watcher
);
}
}
setLocale
(
locale
)
{
const
oldLocale
=
this
.
locale
;
this
.
locale
=
normalizeLocale
(
locale
,
this
.
messages
)
||
this
.
fallbackLocale
;
this
.
message
=
this
.
messages
[
this
.
locale
];
this
.
watchers
.
forEach
((
watcher
)
=>
{
watcher
(
this
.
locale
,
oldLocale
);
});
}
getLocale
()
{
return
this
.
locale
;
}
watchLocale
(
fn
)
{
const
index2
=
this
.
watchers
.
push
(
fn
)
-
1
;
return
()
=>
{
this
.
watchers
.
splice
(
index2
,
1
);
};
}
add
(
locale
,
message
)
{
if
(
this
.
messages
[
locale
])
{
Object
.
assign
(
this
.
messages
[
locale
],
message
);
}
else
{
this
.
messages
[
locale
]
=
message
;
}
}
t
(
key
,
locale
,
values
)
{
let
message
=
this
.
message
;
if
(
typeof
locale
===
"
string
"
)
{
locale
=
normalizeLocale
(
locale
,
this
.
messages
);
locale
&&
(
message
=
this
.
messages
[
locale
]);
}
else
{
values
=
locale
;
}
if
(
!
hasOwn
(
message
,
key
))
{
console
.
warn
(
`Cannot translate the value of keypath
${
key
}
. Use the value of keypath as default.`
);
return
key
;
}
return
this
.
formater
.
interpolate
(
message
[
key
],
values
).
join
(
""
);
}
}
function
initLocaleWatcher
(
appVm2
,
i18n2
)
{
appVm2
.
$i18n
&&
appVm2
.
$i18n
.
vm
.
$watch
(
"
locale
"
,
(
newLocale
)
=>
{
i18n2
.
setLocale
(
newLocale
);
},
{
immediate
:
true
});
}
function
getDefaultLocale
()
{
if
(
typeof
navigator
!==
"
undefined
"
)
{
return
navigator
.
userLanguage
||
navigator
.
language
;
}
if
(
typeof
plus
!==
"
undefined
"
)
{
return
plus
.
os
.
language
;
}
return
uni
.
getSystemInfoSync
().
language
;
}
function
initVueI18n
(
messages
=
{},
fallbackLocale
=
LOCALE_EN
,
locale
)
{
const
i18n2
=
new
I18n
({
locale
:
locale
||
fallbackLocale
,
fallbackLocale
,
messages
});
let
t2
=
(
key
,
values
)
=>
{
if
(
typeof
getApp
!==
"
function
"
)
{
t2
=
function
(
key2
,
values2
)
{
return
i18n2
.
t
(
key2
,
values2
);
};
}
else
{
const
appVm2
=
getApp
().
$vm
;
if
(
!
appVm2
.
$t
||
!
appVm2
.
$i18n
)
{
if
(
!
locale
)
{
i18n2
.
setLocale
(
getDefaultLocale
());
}
t2
=
function
(
key2
,
values2
)
{
return
i18n2
.
t
(
key2
,
values2
);
};
}
else
{
initLocaleWatcher
(
appVm2
,
i18n2
);
t2
=
function
(
key2
,
values2
)
{
const
$i18n
=
appVm2
.
$i18n
;
const
silentTranslationWarn
=
$i18n
.
silentTranslationWarn
;
$i18n
.
silentTranslationWarn
=
true
;
const
msg
=
appVm2
.
$t
(
key2
,
values2
);
$i18n
.
silentTranslationWarn
=
silentTranslationWarn
;
if
(
msg
!==
key2
)
{
return
msg
;
}
return
i18n2
.
t
(
key2
,
$i18n
.
locale
,
values2
);
};
}
}
return
t2
(
key
,
values
);
};
return
{
i18n
:
i18n2
,
t
(
key
,
values
)
{
return
t2
(
key
,
values
);
},
add
(
locale2
,
message
)
{
return
i18n2
.
add
(
locale2
,
message
);
},
getLocale
()
{
return
i18n2
.
getLocale
();
},
setLocale
(
newLocale
)
{
return
i18n2
.
setLocale
(
newLocale
);
}
};
}
const
i18n$1
=
initVueI18n
();
function
useI18n
()
{
return
i18n$1
;
}
const
i18n
=
useI18n
();
function
normalizeMessages
(
namespace
,
messages
)
{
return
Object
.
keys
(
messages
).
reduce
((
res
,
name
)
=>
{
res
[
namespace
+
name
]
=
messages
[
name
];
return
res
;
},
{});
}
function
initI18nAsyncMsgs
()
{
const
name
=
"
uni.async.
"
;
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
error
:
"
The connection timed out, click the screen to try again.
"
}));
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
error
:
"
Se agot
\
xF3 el tiempo de conexi
\
xF3n, haga clic en la pantalla para volver a intentarlo.
"
}));
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
error
:
"
La connexion a expir
\
xE9, cliquez sur l'
\
xE9cran pour r
\
xE9essayer.
"
}));
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
error
:
"
\
u8FDE
\
u63A5
\
u670D
\
u52A1
\
u5668
\
u8D85
\
u65F6
\
uFF0C
\
u70B9
\
u51FB
\
u5C4F
\
u5E55
\
u91CD
\
u8BD5
"
}));
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
error
:
"
\
u9023
\
u63A5
\
u670D
\
u52D9
\
u5668
\
u8D85
\
u6642
\
uFF0C
\
u9EDE
\
u64CA
\
u5C4F
\
u5E55
\
u91CD
\
u8A66
"
}));
}
}
function
initI18nShowModalMsgs
()
{
const
name
=
"
uni.showModal.
"
;
if
(
__UNI_FEATURE_I18N_EN__
)
{
i18n
.
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
{
cancel
:
"
Cancel
"
,
confirm
:
"
OK
"
}));
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
i18n
.
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
{
cancel
:
"
Cancelar
"
,
confirm
:
"
OK
"
}));
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
i18n
.
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
{
cancel
:
"
Annuler
"
,
confirm
:
"
OK
"
}));
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
i18n
.
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
{
cancel
:
"
\
u53D6
\
u6D88
"
,
confirm
:
"
\
u786E
\
u5B9A
"
}));
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
i18n
.
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
{
cancel
:
"
\
u53D6
\
u6D88
"
,
confirm
:
"
\
u78BA
\
u5B9A
"
}));
}
}
function
E
()
{
}
E
.
prototype
=
{
...
...
@@ -823,426 +1117,6 @@ function createSvgIconVNode(path, color = "#000", size = 27) {
},
null
,
8
,
[
"
d
"
,
"
fill
"
])
],
8
,
[
"
width
"
,
"
height
"
]);
}
const
isObject
=
(
val
)
=>
val
!==
null
&&
typeof
val
===
"
object
"
;
class
BaseFormatter
{
constructor
()
{
this
.
_caches
=
Object
.
create
(
null
);
}
interpolate
(
message
,
values
)
{
if
(
!
values
)
{
return
[
message
];
}
let
tokens
=
this
.
_caches
[
message
];
if
(
!
tokens
)
{
tokens
=
parse
(
message
);
this
.
_caches
[
message
]
=
tokens
;
}
return
compile
(
tokens
,
values
);
}
}
const
RE_TOKEN_LIST_VALUE
=
/^
(?:\d)
+/
;
const
RE_TOKEN_NAMED_VALUE
=
/^
(?:\w)
+/
;
function
parse
(
format
)
{
const
tokens
=
[];
let
position
=
0
;
let
text2
=
""
;
while
(
position
<
format
.
length
)
{
let
char
=
format
[
position
++
];
if
(
char
===
"
{
"
)
{
if
(
text2
)
{
tokens
.
push
({
type
:
"
text
"
,
value
:
text2
});
}
text2
=
""
;
let
sub
=
""
;
char
=
format
[
position
++
];
while
(
char
!==
void
0
&&
char
!==
"
}
"
)
{
sub
+=
char
;
char
=
format
[
position
++
];
}
const
isClosed
=
char
===
"
}
"
;
const
type
=
RE_TOKEN_LIST_VALUE
.
test
(
sub
)
?
"
list
"
:
isClosed
&&
RE_TOKEN_NAMED_VALUE
.
test
(
sub
)
?
"
named
"
:
"
unknown
"
;
tokens
.
push
({
value
:
sub
,
type
});
}
else
if
(
char
===
"
%
"
)
{
if
(
format
[
position
]
!==
"
{
"
)
{
text2
+=
char
;
}
}
else
{
text2
+=
char
;
}
}
text2
&&
tokens
.
push
({
type
:
"
text
"
,
value
:
text2
});
return
tokens
;
}
function
compile
(
tokens
,
values
)
{
const
compiled
=
[];
let
index2
=
0
;
const
mode
=
Array
.
isArray
(
values
)
?
"
list
"
:
isObject
(
values
)
?
"
named
"
:
"
unknown
"
;
if
(
mode
===
"
unknown
"
)
{
return
compiled
;
}
while
(
index2
<
tokens
.
length
)
{
const
token
=
tokens
[
index2
];
switch
(
token
.
type
)
{
case
"
text
"
:
compiled
.
push
(
token
.
value
);
break
;
case
"
list
"
:
compiled
.
push
(
values
[
parseInt
(
token
.
value
,
10
)]);
break
;
case
"
named
"
:
if
(
mode
===
"
named
"
)
{
compiled
.
push
(
values
[
token
.
value
]);
}
break
;
}
index2
++
;
}
return
compiled
;
}
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
;
const
hasOwn
=
(
val
,
key
)
=>
hasOwnProperty
.
call
(
val
,
key
);
const
defaultFormatter
=
new
BaseFormatter
();
function
include
(
str
,
parts
)
{
return
!!
parts
.
find
((
part
)
=>
str
.
indexOf
(
part
)
!==
-
1
);
}
function
startsWith
(
str
,
parts
)
{
return
parts
.
find
((
part
)
=>
str
.
indexOf
(
part
)
===
0
);
}
function
normalizeLocale
(
locale
,
messages2
)
{
if
(
!
locale
)
{
return
;
}
locale
=
locale
.
trim
().
replace
(
/_/g
,
"
-
"
);
if
(
messages2
[
locale
])
{
return
locale
;
}
locale
=
locale
.
toLowerCase
();
if
(
locale
.
indexOf
(
"
zh
"
)
===
0
)
{
if
(
locale
.
indexOf
(
"
-hans
"
)
!==
-
1
)
{
return
"
zh-Hans
"
;
}
if
(
locale
.
indexOf
(
"
-hant
"
)
!==
-
1
)
{
return
"
zh-Hant
"
;
}
if
(
include
(
locale
,
[
"
-tw
"
,
"
-hk
"
,
"
-mo
"
,
"
-cht
"
]))
{
return
"
zh-Hant
"
;
}
return
"
zh-Hans
"
;
}
const
lang
=
startsWith
(
locale
,
[
"
en
"
,
"
fr
"
,
"
es
"
]);
if
(
lang
)
{
return
lang
;
}
}
class
I18n
{
constructor
({
locale
,
fallbackLocale
:
fallbackLocale2
,
messages
:
messages2
,
watcher
,
formater
})
{
this
.
locale
=
"
en
"
;
this
.
fallbackLocale
=
"
en
"
;
this
.
message
=
{};
this
.
messages
=
{};
this
.
watchers
=
[];
if
(
fallbackLocale2
)
{
this
.
fallbackLocale
=
fallbackLocale2
;
}
this
.
formater
=
formater
||
defaultFormatter
;
this
.
messages
=
messages2
;
this
.
setLocale
(
locale
);
if
(
watcher
)
{
this
.
watchLocale
(
watcher
);
}
}
setLocale
(
locale
)
{
const
oldLocale
=
this
.
locale
;
this
.
locale
=
normalizeLocale
(
locale
,
this
.
messages
)
||
this
.
fallbackLocale
;
this
.
message
=
this
.
messages
[
this
.
locale
];
this
.
watchers
.
forEach
((
watcher
)
=>
{
watcher
(
this
.
locale
,
oldLocale
);
});
}
getLocale
()
{
return
this
.
locale
;
}
watchLocale
(
fn
)
{
const
index2
=
this
.
watchers
.
push
(
fn
)
-
1
;
return
()
=>
{
this
.
watchers
.
splice
(
index2
,
1
);
};
}
mergeLocaleMessage
(
locale
,
message
)
{
if
(
this
.
messages
[
locale
])
{
Object
.
assign
(
this
.
messages
[
locale
],
message
);
}
else
{
this
.
messages
[
locale
]
=
message
;
}
}
t
(
key
,
locale
,
values
)
{
let
message
=
this
.
message
;
if
(
typeof
locale
===
"
string
"
)
{
locale
=
normalizeLocale
(
locale
,
this
.
messages
);
locale
&&
(
message
=
this
.
messages
[
locale
]);
}
else
{
values
=
locale
;
}
if
(
!
hasOwn
(
message
,
key
))
{
console
.
warn
(
`Cannot translate the value of keypath
${
key
}
. Use the value of keypath as default.`
);
return
key
;
}
return
this
.
formater
.
interpolate
(
message
[
key
],
values
).
join
(
""
);
}
}
function
initLocaleWatcher
(
appVm2
,
i18n2
)
{
appVm2
.
$i18n
&&
appVm2
.
$i18n
.
vm
.
$watch
(
"
locale
"
,
(
newLocale
)
=>
{
i18n2
.
setLocale
(
newLocale
);
},
{
immediate
:
true
});
}
function
getDefaultLocale
()
{
if
(
typeof
navigator
!==
"
undefined
"
)
{
return
navigator
.
userLanguage
||
navigator
.
language
;
}
if
(
typeof
plus
!==
"
undefined
"
)
{
return
plus
.
os
.
language
;
}
return
uni
.
getSystemInfoSync
().
language
;
}
function
initVueI18n
(
messages2
,
fallbackLocale2
=
"
en
"
,
locale
)
{
const
i18n2
=
new
I18n
({
locale
:
locale
||
fallbackLocale2
,
fallbackLocale
:
fallbackLocale2
,
messages
:
messages2
});
let
t2
=
(
key
,
values
)
=>
{
if
(
typeof
getApp
!==
"
function
"
)
{
t2
=
function
(
key2
,
values2
)
{
return
i18n2
.
t
(
key2
,
values2
);
};
}
else
{
const
appVm2
=
getApp
().
$vm
;
if
(
!
appVm2
.
$t
||
!
appVm2
.
$i18n
)
{
if
(
!
locale
)
{
i18n2
.
setLocale
(
getDefaultLocale
());
}
t2
=
function
(
key2
,
values2
)
{
return
i18n2
.
t
(
key2
,
values2
);
};
}
else
{
initLocaleWatcher
(
appVm2
,
i18n2
);
t2
=
function
(
key2
,
values2
)
{
const
$i18n
=
appVm2
.
$i18n
;
const
silentTranslationWarn
=
$i18n
.
silentTranslationWarn
;
$i18n
.
silentTranslationWarn
=
true
;
const
msg
=
appVm2
.
$t
(
key2
,
values2
);
$i18n
.
silentTranslationWarn
=
silentTranslationWarn
;
if
(
msg
!==
key2
)
{
return
msg
;
}
return
i18n2
.
t
(
key2
,
$i18n
.
locale
,
values2
);
};
}
}
return
t2
(
key
,
values
);
};
return
{
i18n
:
i18n2
,
t
(
key
,
values
)
{
return
t2
(
key
,
values
);
},
getLocale
()
{
return
i18n2
.
getLocale
();
},
setLocale
(
newLocale
)
{
return
i18n2
.
setLocale
(
newLocale
);
},
mixin
:
{
beforeCreate
()
{
const
unwatch
=
i18n2
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
});
this
.
$once
(
"
hook:beforeDestroy
"
,
function
()
{
unwatch
();
});
},
methods
:
{
$$t
(
key
,
values
)
{
return
t2
(
key
,
values
);
}
}
}
};
}
var
en
=
{
"
uni.app.quit
"
:
"
Press back button again to exit
"
,
"
uni.async.error
"
:
"
The connection timed out, click the screen to try again.
"
,
"
uni.showActionSheet.cancel
"
:
"
Cancel
"
,
"
uni.showToast.unpaired
"
:
"
Please note showToast must be paired with hideToast
"
,
"
uni.showLoading.unpaired
"
:
"
Please note showLoading must be paired with hideLoading
"
,
"
uni.showModal.cancel
"
:
"
Cancel
"
,
"
uni.showModal.confirm
"
:
"
OK
"
,
"
uni.chooseImage.cancel
"
:
"
Cancel
"
,
"
uni.chooseImage.sourceType.album
"
:
"
Album
"
,
"
uni.chooseImage.sourceType.camera
"
:
"
Camera
"
,
"
uni.chooseVideo.cancel
"
:
"
Cancel
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
Album
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
Camera
"
,
"
uni.previewImage.cancel
"
:
"
Cancel
"
,
"
uni.previewImage.button.save
"
:
"
Save Image
"
,
"
uni.previewImage.save.success
"
:
"
Saved successfully
"
,
"
uni.previewImage.save.fail
"
:
"
Save failed
"
,
"
uni.setClipboardData.success
"
:
"
Content copied
"
,
"
uni.scanCode.title
"
:
"
Scan code
"
,
"
uni.scanCode.album
"
:
"
Album
"
,
"
uni.scanCode.fail
"
:
"
Recognition failure
"
,
"
uni.scanCode.flash.on
"
:
"
Tap to turn light on
"
,
"
uni.scanCode.flash.off
"
:
"
Tap to turn light off
"
,
"
uni.startSoterAuthentication.authContent
"
:
"
Fingerprint recognition
"
,
"
uni.picker.done
"
:
"
Done
"
,
"
uni.picker.cancel
"
:
"
Cancel
"
,
"
uni.video.danmu
"
:
"
Danmu
"
,
"
uni.video.volume
"
:
"
Volume
"
,
"
uni.button.feedback.title
"
:
"
feedback
"
,
"
uni.button.feedback.send
"
:
"
send
"
};
var
es
=
{
"
uni.app.quit
"
:
"
Pulse otra vez para salir
"
,
"
uni.async.error
"
:
"
Se agot
\
xF3 el tiempo de conexi
\
xF3n, haga clic en la pantalla para volver a intentarlo.
"
,
"
uni.showActionSheet.cancel
"
:
"
Cancelar
"
,
"
uni.showToast.unpaired
"
:
"
Tenga en cuenta que showToast debe estar emparejado con hideToast
"
,
"
uni.showLoading.unpaired
"
:
"
Tenga en cuenta que showLoading debe estar emparejado con hideLoading
"
,
"
uni.showModal.cancel
"
:
"
Cancelar
"
,
"
uni.showModal.confirm
"
:
"
OK
"
,
"
uni.chooseImage.cancel
"
:
"
Cancelar
"
,
"
uni.chooseImage.sourceType.album
"
:
"
\
xC1lbum
"
,
"
uni.chooseImage.sourceType.camera
"
:
"
C
\
xE1mara
"
,
"
uni.chooseVideo.cancel
"
:
"
Cancelar
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
\
xC1lbum
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
C
\
xE1mara
"
,
"
uni.previewImage.cancel
"
:
"
Cancelar
"
,
"
uni.previewImage.button.save
"
:
"
Guardar imagen
"
,
"
uni.previewImage.save.success
"
:
"
Guardado exitosamente
"
,
"
uni.previewImage.save.fail
"
:
"
Error al guardar
"
,
"
uni.setClipboardData.success
"
:
"
Contenido copiado
"
,
"
uni.scanCode.title
"
:
"
C
\
xF3digo de escaneo
"
,
"
uni.scanCode.album
"
:
"
\
xC1lbum
"
,
"
uni.scanCode.fail
"
:
"
\
xC9chec de la reconnaissance
"
,
"
uni.scanCode.flash.on
"
:
"
Toque para encender la luz
"
,
"
uni.scanCode.flash.off
"
:
"
Toque para apagar la luz
"
,
"
uni.startSoterAuthentication.authContent
"
:
"
Reconocimiento de huellas dactilares
"
,
"
uni.picker.done
"
:
"
OK
"
,
"
uni.picker.cancel
"
:
"
Cancelar
"
,
"
uni.video.danmu
"
:
"
Danmu
"
,
"
uni.video.volume
"
:
"
Volumen
"
,
"
uni.button.feedback.title
"
:
"
realimentaci
\
xF3n
"
,
"
uni.button.feedback.send
"
:
"
enviar
"
};
var
fr
=
{
"
uni.app.quit
"
:
"
Appuyez
\
xE0 nouveau pour quitter l'application
"
,
"
uni.async.error
"
:
"
La connexion a expir
\
xE9, cliquez sur l'
\
xE9cran pour r
\
xE9essayer.
"
,
"
uni.showActionSheet.cancel
"
:
"
Annuler
"
,
"
uni.showToast.unpaired
"
:
"
Veuillez noter que showToast doit
\
xEAtre associ
\
xE9
\
xE0 hideToast
"
,
"
uni.showLoading.unpaired
"
:
"
Veuillez noter que showLoading doit
\
xEAtre associ
\
xE9
\
xE0 hideLoading
"
,
"
uni.showModal.cancel
"
:
"
Annuler
"
,
"
uni.showModal.confirm
"
:
"
OK
"
,
"
uni.chooseImage.cancel
"
:
"
Annuler
"
,
"
uni.chooseImage.sourceType.album
"
:
"
Album
"
,
"
uni.chooseImage.sourceType.camera
"
:
"
Cam
\
xE9ra
"
,
"
uni.chooseVideo.cancel
"
:
"
Annuler
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
Album
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
Cam
\
xE9ra
"
,
"
uni.previewImage.cancel
"
:
"
Annuler
"
,
"
uni.previewImage.button.save
"
:
"
Guardar imagen
"
,
"
uni.previewImage.save.success
"
:
"
Enregistr
\
xE9 avec succ
\
xE8s
"
,
"
uni.previewImage.save.fail
"
:
"
\
xC9chec de la sauvegarde
"
,
"
uni.setClipboardData.success
"
:
"
Contenu copi
\
xE9
"
,
"
uni.scanCode.title
"
:
"
Code d
\
u2019analyse
"
,
"
uni.scanCode.album
"
:
"
Album
"
,
"
uni.scanCode.fail
"
:
"
Fallo de reconocimiento
"
,
"
uni.scanCode.flash.on
"
:
"
Appuyez pour activer l'
\
xE9clairage
"
,
"
uni.scanCode.flash.off
"
:
"
Appuyez pour d
\
xE9sactiver l'
\
xE9clairage
"
,
"
uni.startSoterAuthentication.authContent
"
:
"
Reconnaissance de l'empreinte digitale
"
,
"
uni.picker.done
"
:
"
OK
"
,
"
uni.picker.cancel
"
:
"
Annuler
"
,
"
uni.video.danmu
"
:
"
Danmu
"
,
"
uni.video.volume
"
:
"
Le Volume
"
,
"
uni.button.feedback.title
"
:
"
retour d'information
"
,
"
uni.button.feedback.send
"
:
"
envoyer
"
};
var
zhHans
=
{
"
uni.app.quit
"
:
"
\
u518D
\
u6309
\
u4E00
\
u6B21
\
u9000
\
u51FA
\
u5E94
\
u7528
"
,
"
uni.async.error
"
:
"
\
u8FDE
\
u63A5
\
u670D
\
u52A1
\
u5668
\
u8D85
\
u65F6
\
uFF0C
\
u70B9
\
u51FB
\
u5C4F
\
u5E55
\
u91CD
\
u8BD5
"
,
"
uni.showActionSheet.cancel
"
:
"
\
u53D6
\
u6D88
"
,
"
uni.showToast.unpaired
"
:
"
\
u8BF7
\
u6CE8
\
u610F showToast
\
u4E0E hideToast
\
u5FC5
\
u987B
\
u914D
\
u5BF9
\
u4F7F
\
u7528
"
,
"
uni.showLoading.unpaired
"
:
"
\
u8BF7
\
u6CE8
\
u610F showLoading
\
u4E0E hideLoading
\
u5FC5
\
u987B
\
u914D
\
u5BF9
\
u4F7F
\
u7528
"
,
"
uni.showModal.cancel
"
:
"
\
u53D6
\
u6D88
"
,
"
uni.showModal.confirm
"
:
"
\
u786E
\
u5B9A
"
,
"
uni.chooseImage.cancel
"
:
"
\
u53D6
\
u6D88
"
,
"
uni.chooseImage.sourceType.album
"
:
"
\
u4ECE
\
u76F8
\
u518C
\
u9009
\
u62E9
"
,
"
uni.chooseImage.sourceType.camera
"
:
"
\
u62CD
\
u6444
"
,
"
uni.chooseVideo.cancel
"
:
"
\
u53D6
\
u6D88
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
\
u4ECE
\
u76F8
\
u518C
\
u9009
\
u62E9
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
\
u62CD
\
u6444
"
,
"
uni.previewImage.cancel
"
:
"
\
u53D6
\
u6D88
"
,
"
uni.previewImage.button.save
"
:
"
\
u4FDD
\
u5B58
\
u56FE
\
u50CF
"
,
"
uni.previewImage.save.success
"
:
"
\
u4FDD
\
u5B58
\
u56FE
\
u50CF
\
u5230
\
u76F8
\
u518C
\
u6210
\
u529F
"
,
"
uni.previewImage.save.fail
"
:
"
\
u4FDD
\
u5B58
\
u56FE
\
u50CF
\
u5230
\
u76F8
\
u518C
\
u5931
\
u8D25
"
,
"
uni.setClipboardData.success
"
:
"
\
u5185
\
u5BB9
\
u5DF2
\
u590D
\
u5236
"
,
"
uni.scanCode.title
"
:
"
\
u626B
\
u7801
"
,
"
uni.scanCode.album
"
:
"
\
u76F8
\
u518C
"
,
"
uni.scanCode.fail
"
:
"
\
u8BC6
\
u522B
\
u5931
\
u8D25
"
,
"
uni.scanCode.flash.on
"
:
"
\
u8F7B
\
u89E6
\
u7167
\
u4EAE
"
,
"
uni.scanCode.flash.off
"
:
"
\
u8F7B
\
u89E6
\
u5173
\
u95ED
"
,
"
uni.startSoterAuthentication.authContent
"
:
"
\
u6307
\
u7EB9
\
u8BC6
\
u522B
\
u4E2D...
"
,
"
uni.picker.done
"
:
"
\
u5B8C
\
u6210
"
,
"
uni.picker.cancel
"
:
"
\
u53D6
\
u6D88
"
,
"
uni.video.danmu
"
:
"
\
u5F39
\
u5E55
"
,
"
uni.video.volume
"
:
"
\
u97F3
\
u91CF
"
,
"
uni.button.feedback.title
"
:
"
\
u95EE
\
u9898
\
u53CD
\
u9988
"
,
"
uni.button.feedback.send
"
:
"
\
u53D1
\
u9001
"
};
var
zhHant
=
{
"
uni.app.quit
"
:
"
\
u518D
\
u6309
\
u4E00
\
u6B21
\
u9000
\
u51FA
\
u61C9
\
u7528
"
,
"
uni.async.error
"
:
"
\
u9023
\
u63A5
\
u670D
\
u52D9
\
u5668
\
u8D85
\
u6642
\
uFF0C
\
u9EDE
\
u64CA
\
u5C4F
\
u5E55
\
u91CD
\
u8A66
"
,
"
uni.showActionSheet.cancel
"
:
"
\
u53D6
\
u6D88
"
,
"
uni.showToast.unpaired
"
:
"
\
u8ACB
\
u6CE8
\
u610F showToast
\
u8207 hideToast
\
u5FC5
\
u9808
\
u914D
\
u5C0D
\
u4F7F
\
u7528
"
,
"
uni.showLoading.unpaired
"
:
"
\
u8ACB
\
u6CE8
\
u610F showLoading
\
u8207 hideLoading
\
u5FC5
\
u9808
\
u914D
\
u5C0D
\
u4F7F
\
u7528
"
,
"
uni.showModal.cancel
"
:
"
\
u53D6
\
u6D88
"
,
"
uni.showModal.confirm
"
:
"
\
u78BA
\
u5B9A
"
,
"
uni.chooseImage.cancel
"
:
"
\
u53D6
\
u6D88
"
,
"
uni.chooseImage.sourceType.album
"
:
"
\
u5F9E
\
u76F8
\
u518A
\
u9078
\
u64C7
"
,
"
uni.chooseImage.sourceType.camera
"
:
"
\
u62CD
\
u651D
"
,
"
uni.chooseVideo.cancel
"
:
"
\
u53D6
\
u6D88
"
,
"
uni.chooseVideo.sourceType.album
"
:
"
\
u5F9E
\
u76F8
\
u518A
\
u9078
\
u64C7
"
,
"
uni.chooseVideo.sourceType.camera
"
:
"
\
u62CD
\
u651D
"
,
"
uni.previewImage.cancel
"
:
"
\
u53D6
\
u6D88
"
,
"
uni.previewImage.button.save
"
:
"
\
u4FDD
\
u5B58
\
u5716
\
u50CF
"
,
"
uni.previewImage.save.success
"
:
"
\
u4FDD
\
u5B58
\
u5716
\
u50CF
\
u5230
\
u76F8
\
u518A
\
u6210
\
u529F
"
,
"
uni.previewImage.save.fail
"
:
"
\
u4FDD
\
u5B58
\
u5716
\
u50CF
\
u5230
\
u76F8
\
u518A
\
u5931
\
u6557
"
,
"
uni.setClipboardData.success
"
:
"
\
u5167
\
u5BB9
\
u5DF2
\
u5FA9
\
u5236
"
,
"
uni.scanCode.title
"
:
"
\
u6383
\
u78BC
"
,
"
uni.scanCode.album
"
:
"
\
u76F8
\
u518A
"
,
"
uni.scanCode.fail
"
:
"
\
u8B58
\
u5225
\
u5931
\
u6557
"
,
"
uni.scanCode.flash.on
"
:
"
\
u8F15
\
u89F8
\
u7167
\
u4EAE
"
,
"
uni.scanCode.flash.off
"
:
"
\
u8F15
\
u89F8
\
u95DC
\
u9589
"
,
"
uni.startSoterAuthentication.authContent
"
:
"
\
u6307
\
u7D0B
\
u8B58
\
u5225
\
u4E2D...
"
,
"
uni.picker.done
"
:
"
\
u5B8C
\
u6210
"
,
"
uni.picker.cancel
"
:
"
\
u53D6
\
u6D88
"
,
"
uni.video.danmu
"
:
"
\
u5F48
\
u5E55
"
,
"
uni.video.volume
"
:
"
\
u97F3
\
u91CF
"
,
"
uni.button.feedback.title
"
:
"
\
u554F
\
u984C
\
u53CD
\
u994B
"
,
"
uni.button.feedback.send
"
:
"
\
u767C
\
u9001
"
};
const
messages
=
{
en
,
es
,
fr
,
"
zh-Hans
"
:
zhHans
,
"
zh-Hant
"
:
zhHant
};
const
fallbackLocale
=
"
en
"
;
const
i18n
=
/* @__PURE__ */
initVueI18n
(
messages
,
fallbackLocale
);
function
useI18n
()
{
return
i18n
;
}
function
getRealRoute
(
fromRoute
,
toRoute
)
{
if
(
!
toRoute
)
{
toRoute
=
fromRoute
;
...
...
@@ -3850,11 +3724,11 @@ const CANCEL_COLOR = "#f43530";
const
ICONS
=
{
success
:
{
d
:
ICON_PATH_SUCCESS
,
c
:
PRIMARY_COLOR
c
:
PRIMARY_COLOR
$1
},
success_no_circle
:
{
d
:
ICON_PATH_SUCCESS_NO_CIRCLE
,
c
:
PRIMARY_COLOR
c
:
PRIMARY_COLOR
$1
},
info
:
{
d
:
ICON_PATH_INFO
,
...
...
@@ -3874,7 +3748,7 @@ const ICONS = {
},
download
:
{
d
:
ICON_PATH_DOWNLOAD
,
c
:
PRIMARY_COLOR
c
:
PRIMARY_COLOR
$1
},
search
:
{
d
:
ICON_PATH_SEARCH
,
...
...
@@ -4372,7 +4246,14 @@ function formatApiArgs(args, options) {
}
const
formatArgs
=
options
.
formatArgs
;
Object
.
keys
(
formatArgs
).
forEach
((
name
)
=>
{
formatArgs
[
name
](
args
[
0
][
name
],
params
);
const
formatterOrDefaultValue
=
formatArgs
[
name
];
if
(
isFunction
(
formatterOrDefaultValue
))
{
formatterOrDefaultValue
(
args
[
0
][
name
],
params
);
}
else
{
if
(
!
hasOwn$1
(
params
,
name
))
{
params
[
name
]
=
formatterOrDefaultValue
;
}
}
});
return
args
;
}
...
...
@@ -4776,28 +4657,16 @@ function stringifyQuery(url, data) {
return
url
+
(
query
?
"
?
"
+
query
:
""
)
+
(
hash
?
"
#
"
+
hash
:
""
);
}
const
RequestProtocol
=
{
method
:
{
type
:
String
},
data
:
{
type
:
[
Object
,
String
,
Array
,
ArrayBuffer
]
},
method
:
String
,
data
:
[
Object
,
String
,
Array
,
ArrayBuffer
],
url
:
{
type
:
String
,
required
:
true
},
header
:
{
type
:
Object
},
dataType
:
{
type
:
String
},
responseType
:
{
type
:
String
},
withCredentials
:
{
type
:
Boolean
}
header
:
Object
,
dataType
:
String
,
responseType
:
String
,
withCredentials
:
Boolean
};
const
RequestOptions
=
{
formatArgs
:
{
...
...
@@ -4863,9 +4732,7 @@ const UploadFileProtocol = {
type
:
String
,
required
:
true
},
files
:
{
type
:
Array
},
files
:
Array
,
filePath
:
String
,
name
:
String
,
header
:
Object
,
...
...
@@ -5064,6 +4931,96 @@ const SetNavigationBarTitleProtocol = {
};
const
API_SHOW_NAVIGATION_BAR_LOADING
=
"
showNavigationBarLoading
"
;
const
API_HIDE_NAVIGATION_BAR_LOADING
=
"
hideNavigationBarLoading
"
;
const
PRIMARY_COLOR
=
"
#007aff
"
;
const
API_SHOW_MODAL
=
"
showModal
"
;
const
{
t
:
t$1
}
=
useI18n
();
const
ShowModalProtocol
=
{
title
:
String
,
content
:
String
,
showCancel
:
Boolean
,
cancelText
:
String
,
cancelColor
:
String
,
confirmText
:
String
,
confirmColor
:
String
};
let
isInitI18nShowModalMsgs
=
false
;
const
ShowModalOptions
=
{
beforeInvoke
()
{
if
(
isInitI18nShowModalMsgs
)
{
return
;
}
isInitI18nShowModalMsgs
=
true
;
initI18nShowModalMsgs
();
},
formatArgs
:
{
title
:
""
,
content
:
""
,
showCancel
:
true
,
cancelText
(
_value
,
params
)
{
if
(
!
hasOwn$1
(
params
,
"
cancelText
"
))
{
params
.
cancelText
=
t$1
(
"
uni.showModal.cancel
"
);
}
},
cancelColor
:
"
#000
"
,
confirmText
(
_value
,
params
)
{
if
(
!
hasOwn$1
(
params
,
"
confirmText
"
))
{
params
.
confirmText
=
t$1
(
"
uni.showModal.confirm
"
);
}
},
confirmColor
:
PRIMARY_COLOR
}
};
const
API_SHOW_TOAST
=
"
showToast
"
;
const
ShowToastProtocol
=
{
title
:
String
,
icon
:
String
,
image
:
String
,
duration
:
Number
,
mask
:
Boolean
};
const
ShowToastOptions
=
{
formatArgs
:
{
title
:
""
,
icon
(
value
,
params
)
{
if
([
"
success
"
,
"
loading
"
,
"
none
"
].
indexOf
(
value
)
===
-
1
)
{
params
.
icon
=
"
success
"
;
}
},
image
(
value
,
params
)
{
if
(
value
)
{
params
.
image
=
getRealPath
(
value
);
}
},
duration
:
1500
,
mask
:
false
}
};
const
API_SHOW_LOADING
=
"
showLoading
"
;
const
ShowLoadingProtocol
=
{
title
:
String
,
mask
:
Boolean
};
const
ShowLoadingOptions
=
{
formatArgs
:
{
title
:
""
,
mask
:
false
}
};
const
API_SHOW_ACTION_SHEET
=
"
showActionSheet
"
;
const
ShowActionSheetProtocol
=
{
itemList
:
{
type
:
Array
,
required
:
true
},
itemColor
:
String
};
const
ShowActionSheetOptions
=
{
formatArgs
:
{
itemColor
:
"
#000
"
}
};
const
API_HIDE_TOAST
=
"
hideToast
"
;
const
API_HIDE_LOADING
=
"
hideLoading
"
;
const
IndexProtocol
=
{
index
:
{
type
:
Number
,
...
...
@@ -11186,6 +11143,18 @@ const hideNavigationBarLoading = /* @__PURE__ */ defineAsyncApi(API_HIDE_NAVIGAT
const
setNavigationBarTitle
=
/* @__PURE__ */
defineAsyncApi
(
API_SET_NAVIGATION_BAR_TITLE
,
(
args
,
{
resolve
,
reject
})
=>
{
setNavigationBar
(
getCurrentPageMeta
(),
API_SET_NAVIGATION_BAR_TITLE
,
args
,
resolve
,
reject
);
},
SetNavigationBarTitleProtocol
);
const
showModal
=
/* @__PURE__ */
defineAsyncApi
(
API_SHOW_MODAL
,
()
=>
{
},
ShowModalProtocol
,
ShowModalOptions
);
const
showToast
=
/* @__PURE__ */
defineAsyncApi
(
API_SHOW_TOAST
,
()
=>
{
},
ShowToastProtocol
,
ShowToastOptions
);
const
hideToast
=
/* @__PURE__ */
defineAsyncApi
(
API_HIDE_TOAST
,
()
=>
{
});
const
showLoading
=
/* @__PURE__ */
defineAsyncApi
(
API_SHOW_LOADING
,
()
=>
{
},
ShowLoadingProtocol
,
ShowLoadingOptions
);
const
hideLoading
=
/* @__PURE__ */
defineAsyncApi
(
API_HIDE_LOADING
,
()
=>
{
});
const
showActionSheet
=
/* @__PURE__ */
defineAsyncApi
(
API_SHOW_ACTION_SHEET
,
()
=>
{
},
ShowActionSheetProtocol
,
ShowActionSheetOptions
);
let
tabBar
;
function
useTabBar
()
{
if
(
!
tabBar
)
{
...
...
@@ -11328,6 +11297,12 @@ var api = /* @__PURE__ */ Object.freeze({
showNavigationBarLoading
,
hideNavigationBarLoading
,
setNavigationBarTitle
,
showModal
,
showToast
,
hideToast
,
showLoading
,
hideLoading
,
showActionSheet
,
setTabBarItem
,
setTabBarStyle
,
hideTabBar
,
...
...
@@ -12345,6 +12320,7 @@ function createPageBodyVNode(ctx) {
});
}
var
index_vue_vue_type_style_index_0_lang$1
=
"
\n
.uni-async-error {
\r\n
position: absolute;
\r\n
left: 0;
\r\n
right: 0;
\r\n
top: 0;
\r\n
bottom: 0;
\r\n
color: #999;
\r\n
padding: 100px 10px;
\r\n
text-align: center;
\n
}
\r\n
"
;
initI18nAsyncMsgs
();
const
_sfc_main$1
=
{
name
:
"
AsyncError
"
,
setup
()
{
...
...
@@ -12376,4 +12352,4 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
]);
}
_sfc_main
.
render
=
_sfc_render
;
export
{
_sfc_main$1
as
AsyncErrorComponent
,
_sfc_main
as
AsyncLoadingComponent
,
_sfc_main$n
as
Audio
,
index$4
as
Button
,
_sfc_main$m
as
Canvas
,
_sfc_main$l
as
Checkbox
,
_sfc_main$k
as
CheckboxGroup
,
_sfc_main$j
as
Editor
,
index$5
as
Form
,
index$3
as
Icon
,
_sfc_main$h
as
Image
,
_sfc_main$g
as
Input
,
_sfc_main$f
as
Label
,
LayoutComponent
,
_sfc_main$e
as
MovableView
,
_sfc_main$d
as
Navigator
,
index
as
PageComponent
,
_sfc_main$c
as
Progress
,
_sfc_main$b
as
Radio
,
_sfc_main$a
as
RadioGroup
,
_sfc_main$i
as
ResizeSensor
,
_sfc_main$9
as
RichText
,
_sfc_main$8
as
ScrollView
,
_sfc_main$7
as
Slider
,
_sfc_main$6
as
SwiperItem
,
_sfc_main$5
as
Switch
,
index$2
as
Text
,
_sfc_main$4
as
Textarea
,
UniServiceJSBridge$1
as
UniServiceJSBridge
,
UniViewJSBridge$1
as
UniViewJSBridge
,
_sfc_main$3
as
Video
,
index$1
as
View
,
addInterceptor
,
arrayBufferToBase64
,
base64ToArrayBuffer
,
canIUse
,
createIntersectionObserver
,
createSelectorQuery
,
createVideoContext
,
cssBackdropFilter
,
cssConstant
,
cssEnv
,
cssVar
,
downloadFile
,
getApp$1
as
getApp
,
getCurrentPages$1
as
getCurrentPages
,
getImageInfo
,
getNetworkType
,
getSystemInfo
,
getSystemInfoSync
,
hide
NavigationBarLoading
,
hideTabBar
,
hideTabBarRedDot
,
makePhoneCall
,
navigateBack
,
navigateTo
,
offNetworkStatusChange
,
onNetworkStatusChange
,
onTabBarMidButtonTap
,
openDocument
,
index$6
as
plugin
,
promiseInterceptor
,
reLaunch
,
redirectTo
,
removeInterceptor
,
removeTabBarBadge
,
request
,
setNavigationBarColor
,
setNavigationBarTitle
,
setTabBarBadge
,
setTabBarItem
,
setTabBarStyle
,
setupApp
,
setupPage
,
showNavigationBarLoading
,
showTabBar
,
showTabBarRedDo
t
,
switchTab
,
uni$1
as
uni
,
uploadFile
,
upx2px
,
useSubscribe
};
export
{
_sfc_main$1
as
AsyncErrorComponent
,
_sfc_main
as
AsyncLoadingComponent
,
_sfc_main$n
as
Audio
,
index$4
as
Button
,
_sfc_main$m
as
Canvas
,
_sfc_main$l
as
Checkbox
,
_sfc_main$k
as
CheckboxGroup
,
_sfc_main$j
as
Editor
,
index$5
as
Form
,
index$3
as
Icon
,
_sfc_main$h
as
Image
,
_sfc_main$g
as
Input
,
_sfc_main$f
as
Label
,
LayoutComponent
,
_sfc_main$e
as
MovableView
,
_sfc_main$d
as
Navigator
,
index
as
PageComponent
,
_sfc_main$c
as
Progress
,
_sfc_main$b
as
Radio
,
_sfc_main$a
as
RadioGroup
,
_sfc_main$i
as
ResizeSensor
,
_sfc_main$9
as
RichText
,
_sfc_main$8
as
ScrollView
,
_sfc_main$7
as
Slider
,
_sfc_main$6
as
SwiperItem
,
_sfc_main$5
as
Switch
,
index$2
as
Text
,
_sfc_main$4
as
Textarea
,
UniServiceJSBridge$1
as
UniServiceJSBridge
,
UniViewJSBridge$1
as
UniViewJSBridge
,
_sfc_main$3
as
Video
,
index$1
as
View
,
addInterceptor
,
arrayBufferToBase64
,
base64ToArrayBuffer
,
canIUse
,
createIntersectionObserver
,
createSelectorQuery
,
createVideoContext
,
cssBackdropFilter
,
cssConstant
,
cssEnv
,
cssVar
,
downloadFile
,
getApp$1
as
getApp
,
getCurrentPages$1
as
getCurrentPages
,
getImageInfo
,
getNetworkType
,
getSystemInfo
,
getSystemInfoSync
,
hide
Loading
,
hideNavigationBarLoading
,
hideTabBar
,
hideTabBarRedDot
,
hideToast
,
makePhoneCall
,
navigateBack
,
navigateTo
,
offNetworkStatusChange
,
onNetworkStatusChange
,
onTabBarMidButtonTap
,
openDocument
,
index$6
as
plugin
,
promiseInterceptor
,
reLaunch
,
redirectTo
,
removeInterceptor
,
removeTabBarBadge
,
request
,
setNavigationBarColor
,
setNavigationBarTitle
,
setTabBarBadge
,
setTabBarItem
,
setTabBarStyle
,
setupApp
,
setupPage
,
showActionSheet
,
showLoading
,
showModal
,
showNavigationBarLoading
,
showTabBar
,
showTabBarRedDot
,
showToas
t
,
switchTab
,
uni$1
as
uni
,
uploadFile
,
upx2px
,
useSubscribe
};
packages/uni-h5/src/framework/components/async-error/index.vue
浏览文件 @
d5eda2ca
...
...
@@ -15,9 +15,10 @@
</
style
>
<
script
>
import
{
useI18n
useI18n
,
initI18nAsyncMsgs
}
from
'
@dcloudio/uni-core
'
initI18nAsyncMsgs
()
export
default
{
name
:
'
AsyncError
'
,
setup
()
{
...
...
packages/uni-h5/src/service/api/index.ts
浏览文件 @
d5eda2ca
...
...
@@ -20,6 +20,7 @@ export * from './route/reLaunch'
export
*
from
'
./route/switchTab
'
export
*
from
'
./ui/navigationBar
'
export
*
from
'
./ui/popup
'
export
*
from
'
./ui/tabBar
'
export
{
...
...
packages/uni-h5/src/service/api/ui/popup.ts
0 → 100644
浏览文件 @
d5eda2ca
import
{
defineAsyncApi
,
API_TYPE_SHOW_MODAL
,
API_SHOW_MODAL
,
ShowModalProtocol
,
ShowModalOptions
,
API_TYPE_SHOW_TOAST
,
API_SHOW_TOAST
,
ShowToastProtocol
,
ShowToastOptions
,
API_TYPE_HIDE_TOAST
,
API_HIDE_TOAST
,
API_HIDE_LOADING
,
API_SHOW_ACTION_SHEET
,
API_SHOW_LOADING
,
API_TYPE_HIDE_LOADING
,
API_TYPE_SHOW_ACTION_SHEET
,
API_TYPE_SHOW_LOADING
,
ShowActionSheetOptions
,
ShowActionSheetProtocol
,
ShowLoadingOptions
,
ShowLoadingProtocol
,
}
from
'
@dcloudio/uni-api
'
export
const
showModal
=
defineAsyncApi
<
API_TYPE_SHOW_MODAL
>
(
API_SHOW_MODAL
,
()
=>
{},
ShowModalProtocol
,
ShowModalOptions
)
export
const
showToast
=
defineAsyncApi
<
API_TYPE_SHOW_TOAST
>
(
API_SHOW_TOAST
,
()
=>
{},
ShowToastProtocol
,
ShowToastOptions
)
export
const
hideToast
=
defineAsyncApi
<
API_TYPE_HIDE_TOAST
>
(
API_HIDE_TOAST
,
()
=>
{}
)
export
const
showLoading
=
defineAsyncApi
<
API_TYPE_SHOW_LOADING
>
(
API_SHOW_LOADING
,
()
=>
{},
ShowLoadingProtocol
,
ShowLoadingOptions
)
export
const
hideLoading
=
defineAsyncApi
<
API_TYPE_HIDE_LOADING
>
(
API_HIDE_LOADING
,
()
=>
{}
)
export
const
showActionSheet
=
defineAsyncApi
<
API_TYPE_SHOW_ACTION_SHEET
>
(
API_SHOW_ACTION_SHEET
,
()
=>
{},
ShowActionSheetProtocol
,
ShowActionSheetOptions
)
packages/uni-i18n/dist/uni-i18n.cjs.js
浏览文件 @
d5eda2ca
...
...
@@ -100,6 +100,11 @@ function compile(tokens, values) {
return
compiled
;
}
const
LOCALE_ZH_HANS
=
'
zh-Hans
'
;
const
LOCALE_ZH_HANT
=
'
zh-Hant
'
;
const
LOCALE_EN
=
'
en
'
;
const
LOCALE_FR
=
'
fr
'
;
const
LOCALE_ES
=
'
es
'
;
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
;
const
hasOwn
=
(
val
,
key
)
=>
hasOwnProperty
.
call
(
val
,
key
);
const
defaultFormatter
=
new
BaseFormatter
();
...
...
@@ -120,25 +125,25 @@ function normalizeLocale(locale, messages) {
locale
=
locale
.
toLowerCase
();
if
(
locale
.
indexOf
(
'
zh
'
)
===
0
)
{
if
(
locale
.
indexOf
(
'
-hans
'
)
!==
-
1
)
{
return
'
zh-Hans
'
;
return
LOCALE_ZH_HANS
;
}
if
(
locale
.
indexOf
(
'
-hant
'
)
!==
-
1
)
{
return
'
zh-Hant
'
;
return
LOCALE_ZH_HANT
;
}
if
(
include
(
locale
,
[
'
-tw
'
,
'
-hk
'
,
'
-mo
'
,
'
-cht
'
]))
{
return
'
zh-Hant
'
;
return
LOCALE_ZH_HANT
;
}
return
'
zh-Hans
'
;
return
LOCALE_ZH_HANS
;
}
const
lang
=
startsWith
(
locale
,
[
'
en
'
,
'
fr
'
,
'
es
'
]);
const
lang
=
startsWith
(
locale
,
[
LOCALE_EN
,
LOCALE_FR
,
LOCALE_ES
]);
if
(
lang
)
{
return
lang
;
}
}
class
I18n
{
constructor
({
locale
,
fallbackLocale
,
messages
,
watcher
,
formater
,
})
{
this
.
locale
=
'
en
'
;
this
.
fallbackLocale
=
'
en
'
;
this
.
locale
=
LOCALE_EN
;
this
.
fallbackLocale
=
LOCALE_EN
;
this
.
message
=
{};
this
.
messages
=
{};
this
.
watchers
=
[];
...
...
@@ -146,7 +151,7 @@ class I18n {
this
.
fallbackLocale
=
fallbackLocale
;
}
this
.
formater
=
formater
||
defaultFormatter
;
this
.
messages
=
messages
;
this
.
messages
=
messages
||
{}
;
this
.
setLocale
(
locale
);
if
(
watcher
)
{
this
.
watchLocale
(
watcher
);
...
...
@@ -169,7 +174,7 @@ class I18n {
this
.
watchers
.
splice
(
index
,
1
);
};
}
mergeLocaleMessage
(
locale
,
message
)
{
add
(
locale
,
message
)
{
if
(
this
.
messages
[
locale
])
{
Object
.
assign
(
this
.
messages
[
locale
],
message
);
}
...
...
@@ -212,7 +217,7 @@ function getDefaultLocale() {
}
return
uni
.
getSystemInfoSync
().
language
;
}
function
initVueI18n
(
messages
,
fallbackLocale
=
'
en
'
,
locale
)
{
function
initVueI18n
(
messages
=
{},
fallbackLocale
=
LOCALE_EN
,
locale
)
{
const
i18n
=
new
I18n
({
locale
:
locale
||
fallbackLocale
,
fallbackLocale
,
...
...
@@ -260,29 +265,22 @@ function initVueI18n(messages, fallbackLocale = 'en', locale) {
t
(
key
,
values
)
{
return
t
(
key
,
values
);
},
add
(
locale
,
message
)
{
return
i18n
.
add
(
locale
,
message
);
},
getLocale
()
{
return
i18n
.
getLocale
();
},
setLocale
(
newLocale
)
{
return
i18n
.
setLocale
(
newLocale
);
},
mixin
:
{
beforeCreate
()
{
const
unwatch
=
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
});
this
.
$once
(
'
hook:beforeDestroy
'
,
function
()
{
unwatch
();
});
},
methods
:
{
$$t
(
key
,
values
)
{
return
t
(
key
,
values
);
},
},
},
};
}
exports
.
I18n
=
I18n
;
exports
.
LOCALE_EN
=
LOCALE_EN
;
exports
.
LOCALE_ES
=
LOCALE_ES
;
exports
.
LOCALE_FR
=
LOCALE_FR
;
exports
.
LOCALE_ZH_HANS
=
LOCALE_ZH_HANS
;
exports
.
LOCALE_ZH_HANT
=
LOCALE_ZH_HANT
;
exports
.
initVueI18n
=
initVueI18n
;
packages/uni-i18n/dist/uni-i18n.d.ts
浏览文件 @
d5eda2ca
export
declare
type
BuiltInLocale
=
'
zh-Hans
'
|
'
zh-Hant
'
|
'
en
'
|
'
fr
'
|
'
es
'
;
export
declare
type
BuiltInLocale
=
typeof
LOCALE_ZH_HANS
|
typeof
LOCALE_ZH_HANT
|
typeof
LOCALE_EN
|
typeof
LOCALE_FR
|
typeof
LOCALE_ES
;
export
declare
interface
Formatter
{
interpolate
:
(
message
:
string
,
values
?:
Record
<
string
,
unknown
>
|
Array
<
unknown
>
)
=>
Array
<
unknown
>
;
...
...
@@ -16,7 +16,7 @@ export declare class I18n {
setLocale
(
locale
:
string
):
void
;
getLocale
():
BuiltInLocale
;
watchLocale
(
fn
:
LocaleWatcher
):
()
=>
void
;
mergeLocaleMessage
(
locale
:
BuiltInLocale
,
message
:
Record
<
string
,
string
>
):
void
;
add
(
locale
:
BuiltInLocale
,
message
:
Record
<
string
,
string
>
):
void
;
t
(
key
:
string
,
values
?:
Record
<
string
,
unknown
>
|
Array
<
unknown
>
|
BuiltInLocale
):
string
;
t
(
key
:
string
,
locale
?:
BuiltInLocale
,
values
?:
Record
<
string
,
unknown
>
|
Array
<
unknown
>
):
string
;
}
...
...
@@ -24,24 +24,29 @@ export declare class I18n {
export
declare
interface
I18nOptions
{
locale
:
BuiltInLocale
;
fallbackLocale
?:
BuiltInLocale
;
messages
:
LocaleMessages
;
messages
?
:
LocaleMessages
;
formater
?:
Formatter
;
watcher
?:
LocaleWatcher
;
}
export
declare
function
initVueI18n
(
messages
:
LocaleMessages
,
fallbackLocale
?:
BuiltInLocale
,
locale
?:
BuiltInLocale
):
{
export
declare
function
initVueI18n
(
messages
?
:
LocaleMessages
,
fallbackLocale
?:
BuiltInLocale
,
locale
?:
BuiltInLocale
):
{
i18n
:
I18n
;
t
(
key
:
string
,
values
?:
Record
<
string
,
unknown
>
|
unknown
[]
|
undefined
):
string
;
add
(
locale
:
BuiltInLocale
,
message
:
Record
<
string
,
string
>
):
void
;
getLocale
():
BuiltInLocale
;
setLocale
(
newLocale
:
BuiltInLocale
):
void
;
mixin
:
{
beforeCreate
():
void
;
methods
:
{
$$t
(
key
:
string
,
values
?:
any
):
string
;
};
};
};
export
declare
const
LOCALE_EN
=
"
en
"
;
export
declare
const
LOCALE_ES
=
"
es
"
;
export
declare
const
LOCALE_FR
=
"
fr
"
;
export
declare
const
LOCALE_ZH_HANS
=
"
zh-Hans
"
;
export
declare
const
LOCALE_ZH_HANT
=
"
zh-Hant
"
;
export
declare
type
LocaleMessages
=
{
[
name
in
BuiltInLocale
]?:
Record
<
string
,
string
>
;
};
...
...
packages/uni-i18n/dist/uni-i18n.esm.js
浏览文件 @
d5eda2ca
...
...
@@ -96,6 +96,11 @@ function compile(tokens, values) {
return
compiled
;
}
const
LOCALE_ZH_HANS
=
'
zh-Hans
'
;
const
LOCALE_ZH_HANT
=
'
zh-Hant
'
;
const
LOCALE_EN
=
'
en
'
;
const
LOCALE_FR
=
'
fr
'
;
const
LOCALE_ES
=
'
es
'
;
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
;
const
hasOwn
=
(
val
,
key
)
=>
hasOwnProperty
.
call
(
val
,
key
);
const
defaultFormatter
=
new
BaseFormatter
();
...
...
@@ -116,25 +121,25 @@ function normalizeLocale(locale, messages) {
locale
=
locale
.
toLowerCase
();
if
(
locale
.
indexOf
(
'
zh
'
)
===
0
)
{
if
(
locale
.
indexOf
(
'
-hans
'
)
!==
-
1
)
{
return
'
zh-Hans
'
;
return
LOCALE_ZH_HANS
;
}
if
(
locale
.
indexOf
(
'
-hant
'
)
!==
-
1
)
{
return
'
zh-Hant
'
;
return
LOCALE_ZH_HANT
;
}
if
(
include
(
locale
,
[
'
-tw
'
,
'
-hk
'
,
'
-mo
'
,
'
-cht
'
]))
{
return
'
zh-Hant
'
;
return
LOCALE_ZH_HANT
;
}
return
'
zh-Hans
'
;
return
LOCALE_ZH_HANS
;
}
const
lang
=
startsWith
(
locale
,
[
'
en
'
,
'
fr
'
,
'
es
'
]);
const
lang
=
startsWith
(
locale
,
[
LOCALE_EN
,
LOCALE_FR
,
LOCALE_ES
]);
if
(
lang
)
{
return
lang
;
}
}
class
I18n
{
constructor
({
locale
,
fallbackLocale
,
messages
,
watcher
,
formater
,
})
{
this
.
locale
=
'
en
'
;
this
.
fallbackLocale
=
'
en
'
;
this
.
locale
=
LOCALE_EN
;
this
.
fallbackLocale
=
LOCALE_EN
;
this
.
message
=
{};
this
.
messages
=
{};
this
.
watchers
=
[];
...
...
@@ -142,7 +147,7 @@ class I18n {
this
.
fallbackLocale
=
fallbackLocale
;
}
this
.
formater
=
formater
||
defaultFormatter
;
this
.
messages
=
messages
;
this
.
messages
=
messages
||
{}
;
this
.
setLocale
(
locale
);
if
(
watcher
)
{
this
.
watchLocale
(
watcher
);
...
...
@@ -165,7 +170,7 @@ class I18n {
this
.
watchers
.
splice
(
index
,
1
);
};
}
mergeLocaleMessage
(
locale
,
message
)
{
add
(
locale
,
message
)
{
if
(
this
.
messages
[
locale
])
{
Object
.
assign
(
this
.
messages
[
locale
],
message
);
}
...
...
@@ -208,7 +213,7 @@ function getDefaultLocale() {
}
return
uni
.
getSystemInfoSync
().
language
;
}
function
initVueI18n
(
messages
,
fallbackLocale
=
'
en
'
,
locale
)
{
function
initVueI18n
(
messages
=
{},
fallbackLocale
=
LOCALE_EN
,
locale
)
{
const
i18n
=
new
I18n
({
locale
:
locale
||
fallbackLocale
,
fallbackLocale
,
...
...
@@ -256,28 +261,16 @@ function initVueI18n(messages, fallbackLocale = 'en', locale) {
t
(
key
,
values
)
{
return
t
(
key
,
values
);
},
add
(
locale
,
message
)
{
return
i18n
.
add
(
locale
,
message
);
},
getLocale
()
{
return
i18n
.
getLocale
();
},
setLocale
(
newLocale
)
{
return
i18n
.
setLocale
(
newLocale
);
},
mixin
:
{
beforeCreate
()
{
const
unwatch
=
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
();
});
this
.
$once
(
'
hook:beforeDestroy
'
,
function
()
{
unwatch
();
});
},
methods
:
{
$$t
(
key
,
values
)
{
return
t
(
key
,
values
);
},
},
},
};
}
export
{
I18n
,
initVueI18n
};
export
{
I18n
,
LOCALE_EN
,
LOCALE_ES
,
LOCALE_FR
,
LOCALE_ZH_HANS
,
LOCALE_ZH_HANT
,
initVueI18n
};
packages/uni-i18n/src/I18n.ts
浏览文件 @
d5eda2ca
import
BaseFormatter
from
'
./format
'
export
const
LOCALE_ZH_HANS
=
'
zh-Hans
'
export
const
LOCALE_ZH_HANT
=
'
zh-Hant
'
export
const
LOCALE_EN
=
'
en
'
export
const
LOCALE_FR
=
'
fr
'
export
const
LOCALE_ES
=
'
es
'
// 中文 (简体),中文 (繁體),英语,法语,西班牙语
export
type
BuiltInLocale
=
'
zh-Hans
'
|
'
zh-Hant
'
|
'
en
'
|
'
fr
'
|
'
es
'
export
type
BuiltInLocale
=
|
typeof
LOCALE_ZH_HANS
|
typeof
LOCALE_ZH_HANT
|
typeof
LOCALE_EN
|
typeof
LOCALE_FR
|
typeof
LOCALE_ES
export
type
LocaleMessages
=
{
[
name
in
BuiltInLocale
]?:
Record
<
string
,
string
>
...
...
@@ -22,7 +33,7 @@ export type LocaleWatcher = (
export
interface
I18nOptions
{
locale
:
BuiltInLocale
fallbackLocale
?:
BuiltInLocale
messages
:
LocaleMessages
messages
?
:
LocaleMessages
formater
?:
Formatter
watcher
?:
LocaleWatcher
}
...
...
@@ -54,25 +65,25 @@ function normalizeLocale(
locale
=
locale
.
toLowerCase
()
if
(
locale
.
indexOf
(
'
zh
'
)
===
0
)
{
if
(
locale
.
indexOf
(
'
-hans
'
)
!==
-
1
)
{
return
'
zh-Hans
'
return
LOCALE_ZH_HANS
}
if
(
locale
.
indexOf
(
'
-hant
'
)
!==
-
1
)
{
return
'
zh-Hant
'
return
LOCALE_ZH_HANT
}
if
(
include
(
locale
,
[
'
-tw
'
,
'
-hk
'
,
'
-mo
'
,
'
-cht
'
]))
{
return
'
zh-Hant
'
return
LOCALE_ZH_HANT
}
return
'
zh-Hans
'
return
LOCALE_ZH_HANS
}
const
lang
=
startsWith
(
locale
,
[
'
en
'
,
'
fr
'
,
'
es
'
])
const
lang
=
startsWith
(
locale
,
[
LOCALE_EN
,
LOCALE_FR
,
LOCALE_ES
])
if
(
lang
)
{
return
lang
as
BuiltInLocale
}
}
export
class
I18n
{
private
locale
:
BuiltInLocale
=
'
en
'
private
fallbackLocale
:
BuiltInLocale
=
'
en
'
private
locale
:
BuiltInLocale
=
LOCALE_EN
private
fallbackLocale
:
BuiltInLocale
=
LOCALE_EN
private
message
:
Record
<
string
,
string
>
=
{}
private
messages
:
LocaleMessages
=
{}
private
watchers
:
LocaleWatcher
[]
=
[]
...
...
@@ -88,7 +99,7 @@ export class I18n {
this
.
fallbackLocale
=
fallbackLocale
}
this
.
formater
=
formater
||
defaultFormatter
this
.
messages
=
messages
this
.
messages
=
messages
||
{}
this
.
setLocale
(
locale
)
if
(
watcher
)
{
this
.
watchLocale
(
watcher
)
...
...
@@ -111,7 +122,7 @@ export class I18n {
this
.
watchers
.
splice
(
index
,
1
)
}
}
mergeLocaleMessage
(
locale
:
BuiltInLocale
,
message
:
Record
<
string
,
string
>
)
{
add
(
locale
:
BuiltInLocale
,
message
:
Record
<
string
,
string
>
)
{
if
(
this
.
messages
[
locale
])
{
Object
.
assign
(
this
.
messages
[
locale
],
message
)
}
else
{
...
...
packages/uni-i18n/src/vue-i18n.ts
浏览文件 @
d5eda2ca
import
{
I18n
,
BuiltInLocale
,
LocaleMessages
}
from
'
./I18n
'
import
{
I18n
,
BuiltInLocale
,
LocaleMessages
,
LOCALE_EN
}
from
'
./I18n
'
type
Interpolate
=
(
key
:
string
,
...
...
@@ -30,8 +30,8 @@ function getDefaultLocale() {
}
export
function
initVueI18n
(
messages
:
LocaleMessages
,
fallbackLocale
:
BuiltInLocale
=
'
en
'
,
messages
:
LocaleMessages
=
{}
,
fallbackLocale
:
BuiltInLocale
=
LOCALE_EN
,
locale
?:
BuiltInLocale
)
{
const
i18n
=
new
I18n
({
...
...
@@ -79,26 +79,14 @@ export function initVueI18n(
t
(
key
:
string
,
values
?:
Record
<
string
,
unknown
>
|
Array
<
unknown
>
)
{
return
t
(
key
,
values
)
},
add
(
locale
:
BuiltInLocale
,
message
:
Record
<
string
,
string
>
)
{
return
i18n
.
add
(
locale
,
message
)
},
getLocale
()
{
return
i18n
.
getLocale
()
},
setLocale
(
newLocale
:
BuiltInLocale
)
{
return
i18n
.
setLocale
(
newLocale
)
},
mixin
:
{
beforeCreate
()
{
const
unwatch
=
i18n
.
watchLocale
(()
=>
{
;(
this
as
any
).
$forceUpdate
()
})
;(
this
as
any
).
$once
(
'
hook:beforeDestroy
'
,
function
()
{
unwatch
()
})
},
methods
:
{
$$t
(
key
:
string
,
values
?:
any
)
{
return
t
(
key
,
values
)
},
},
},
}
}
packages/uni-mp-alipay/dist/uni.api.esm.js
浏览文件 @
d5eda2ca
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
is
Promise
,
isFunction
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
is
Function
,
isPromise
}
from
'
@vue/shared
'
;
function
validateProtocolFail
(
name
,
msg
)
{
console
.
warn
(
`
${
name
}
:
${
msg
}
`
);
...
...
@@ -152,7 +152,16 @@ function formatApiArgs(args, options) {
}
const
formatArgs
=
options
.
formatArgs
;
Object
.
keys
(
formatArgs
).
forEach
((
name
)
=>
{
formatArgs
[
name
](
args
[
0
][
name
],
params
);
const
formatterOrDefaultValue
=
formatArgs
[
name
];
if
(
isFunction
(
formatterOrDefaultValue
))
{
formatterOrDefaultValue
(
args
[
0
][
name
],
params
);
}
else
{
// defaultValue
if
(
!
hasOwn
(
params
,
name
))
{
params
[
name
]
=
formatterOrDefaultValue
;
}
}
});
return
args
;
}
...
...
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
d5eda2ca
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
is
Promise
,
isFunction
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
is
Function
,
isPromise
}
from
'
@vue/shared
'
;
function
validateProtocolFail
(
name
,
msg
)
{
console
.
warn
(
`
${
name
}
:
${
msg
}
`
);
...
...
@@ -152,7 +152,16 @@ function formatApiArgs(args, options) {
}
const
formatArgs
=
options
.
formatArgs
;
Object
.
keys
(
formatArgs
).
forEach
((
name
)
=>
{
formatArgs
[
name
](
args
[
0
][
name
],
params
);
const
formatterOrDefaultValue
=
formatArgs
[
name
];
if
(
isFunction
(
formatterOrDefaultValue
))
{
formatterOrDefaultValue
(
args
[
0
][
name
],
params
);
}
else
{
// defaultValue
if
(
!
hasOwn
(
params
,
name
))
{
params
[
name
]
=
formatterOrDefaultValue
;
}
}
});
return
args
;
}
...
...
packages/uni-mp-qq/dist/uni.api.esm.js
浏览文件 @
d5eda2ca
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
is
Promise
,
isFunction
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
is
Function
,
isPromise
}
from
'
@vue/shared
'
;
function
validateProtocolFail
(
name
,
msg
)
{
console
.
warn
(
`
${
name
}
:
${
msg
}
`
);
...
...
@@ -152,7 +152,16 @@ function formatApiArgs(args, options) {
}
const
formatArgs
=
options
.
formatArgs
;
Object
.
keys
(
formatArgs
).
forEach
((
name
)
=>
{
formatArgs
[
name
](
args
[
0
][
name
],
params
);
const
formatterOrDefaultValue
=
formatArgs
[
name
];
if
(
isFunction
(
formatterOrDefaultValue
))
{
formatterOrDefaultValue
(
args
[
0
][
name
],
params
);
}
else
{
// defaultValue
if
(
!
hasOwn
(
params
,
name
))
{
params
[
name
]
=
formatterOrDefaultValue
;
}
}
});
return
args
;
}
...
...
packages/uni-mp-toutiao/dist/uni.api.esm.js
浏览文件 @
d5eda2ca
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
is
Promise
,
isFunction
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
is
Function
,
isPromise
}
from
'
@vue/shared
'
;
function
validateProtocolFail
(
name
,
msg
)
{
console
.
warn
(
`
${
name
}
:
${
msg
}
`
);
...
...
@@ -152,7 +152,16 @@ function formatApiArgs(args, options) {
}
const
formatArgs
=
options
.
formatArgs
;
Object
.
keys
(
formatArgs
).
forEach
((
name
)
=>
{
formatArgs
[
name
](
args
[
0
][
name
],
params
);
const
formatterOrDefaultValue
=
formatArgs
[
name
];
if
(
isFunction
(
formatterOrDefaultValue
))
{
formatterOrDefaultValue
(
args
[
0
][
name
],
params
);
}
else
{
// defaultValue
if
(
!
hasOwn
(
params
,
name
))
{
params
[
name
]
=
formatterOrDefaultValue
;
}
}
});
return
args
;
}
...
...
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
d5eda2ca
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
is
Promise
,
isFunction
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
is
Function
,
isPromise
}
from
'
@vue/shared
'
;
function
validateProtocolFail
(
name
,
msg
)
{
console
.
warn
(
`
${
name
}
:
${
msg
}
`
);
...
...
@@ -152,7 +152,16 @@ function formatApiArgs(args, options) {
}
const
formatArgs
=
options
.
formatArgs
;
Object
.
keys
(
formatArgs
).
forEach
((
name
)
=>
{
formatArgs
[
name
](
args
[
0
][
name
],
params
);
const
formatterOrDefaultValue
=
formatArgs
[
name
];
if
(
isFunction
(
formatterOrDefaultValue
))
{
formatterOrDefaultValue
(
args
[
0
][
name
],
params
);
}
else
{
// defaultValue
if
(
!
hasOwn
(
params
,
name
))
{
params
[
name
]
=
formatterOrDefaultValue
;
}
}
});
return
args
;
}
...
...
packages/uni-quickapp-webview/dist/uni.api.esm.js
浏览文件 @
d5eda2ca
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
is
Promise
,
isFunction
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
is
Function
,
isPromise
}
from
'
@vue/shared
'
;
function
validateProtocolFail
(
name
,
msg
)
{
console
.
warn
(
`
${
name
}
:
${
msg
}
`
);
...
...
@@ -152,7 +152,16 @@ function formatApiArgs(args, options) {
}
const
formatArgs
=
options
.
formatArgs
;
Object
.
keys
(
formatArgs
).
forEach
((
name
)
=>
{
formatArgs
[
name
](
args
[
0
][
name
],
params
);
const
formatterOrDefaultValue
=
formatArgs
[
name
];
if
(
isFunction
(
formatterOrDefaultValue
))
{
formatterOrDefaultValue
(
args
[
0
][
name
],
params
);
}
else
{
// defaultValue
if
(
!
hasOwn
(
params
,
name
))
{
params
[
name
]
=
formatterOrDefaultValue
;
}
}
});
return
args
;
}
...
...
packages/vite-plugin-uni/src/utils/define.ts
浏览文件 @
d5eda2ca
...
...
@@ -27,6 +27,11 @@ interface ManifestFeatures {
promise
:
boolean
longpress
:
boolean
routerMode
:
'
"hash"
'
|
'
"history"
'
i18nEn
:
boolean
i18nEs
:
boolean
i18nFr
:
boolean
i18nZhHans
:
boolean
i18nZhHant
:
boolean
}
function
resolveProjectFeature
(
...
...
@@ -156,6 +161,11 @@ function resolveManifestFeature(
promise
:
false
,
longpress
:
true
,
routerMode
:
'
"hash"
'
,
i18nEn
:
true
,
i18nEs
:
true
,
i18nFr
:
true
,
i18nZhHans
:
true
,
i18nZhHant
:
true
,
}
const
manifest
=
parse
(
fs
.
readFileSync
(
path
.
join
(
options
.
inputDir
,
'
manifest.json
'
),
'
utf8
'
)
...
...
@@ -167,7 +177,29 @@ function resolveManifestFeature(
)
{
features
.
routerMode
=
'
"history"
'
}
// TODO manifest.json features
const
platform
=
manifest
[
options
.
platform
]
||
{}
const
manifestFeatures
=
platform
.
features
if
(
manifestFeatures
)
{
const
{
i18n
}
=
manifestFeatures
if
(
isArray
(
i18n
))
{
if
(
!
i18n
.
includes
(
'
en
'
))
{
features
.
i18nEn
=
false
}
if
(
!
i18n
.
includes
(
'
es
'
))
{
features
.
i18nEs
=
false
}
if
(
!
i18n
.
includes
(
'
fr
'
))
{
features
.
i18nFr
=
false
}
if
(
!
i18n
.
includes
(
'
zh-Hans
'
))
{
features
.
i18nZhHans
=
false
}
if
(
!
i18n
.
includes
(
'
zh-Hant
'
))
{
features
.
i18nZhHant
=
false
}
}
}
// TODO other features
return
features
}
...
...
@@ -181,6 +213,11 @@ export function getFeatures(
wx
,
wxs
,
nvue
,
i18nEn
,
i18nEs
,
i18nFr
,
i18nZhHans
,
i18nZhHant
,
pages
,
tabBar
,
tabBarMidButton
,
...
...
@@ -205,6 +242,11 @@ export function getFeatures(
__UNI_FEATURE_WXS__
:
wxs
,
// 是否启用 wxs 支持,如:getComponentDescriptor 等(uni-core/src/view/plugin/appConfig)
__UNI_FEATURE_PROMISE__
:
promise
,
// 是否启用旧版本的 promise 支持(即返回[err,res]的格式),默认返回标准
__UNI_FEATURE_LONGPRESS__
:
longpress
,
// 是否启用longpress
__UNI_FEATURE_I18N_EN__
:
i18nEn
,
// 是否启用en
__UNI_FEATURE_I18N_ES__
:
i18nEs
,
// 是否启用es
__UNI_FEATURE_I18N_FR__
:
i18nFr
,
// 是否启用fr
__UNI_FEATURE_I18N_ZH_HANS__
:
i18nZhHans
,
// 是否启用zh_Hans
__UNI_FEATURE_I18N_ZH_HANT__
:
i18nZhHant
,
// 是否启用zh_Hant
// 以下特性,编译器已自动识别是否需要启用
__UNI_FEATURE_NVUE__
:
nvue
,
// 是否启用nvue
__UNI_FEATURE_ROUTER_MODE__
:
routerMode
,
// 路由模式
...
...
scripts/i18n.js
0 → 100644
浏览文件 @
d5eda2ca
const
fs
=
require
(
'
fs
'
)
const
path
=
require
(
'
path
'
)
const
locales
=
[
'
en
'
,
'
es
'
,
'
fr
'
,
'
zh-Hans
'
,
'
zh-Hant
'
]
function
buildI18n
(
namespace
,
dir
)
{
const
modules
=
{}
locales
.
forEach
((
locale
)
=>
{
const
messages
=
buildI18nLocale
(
locale
,
namespace
,
dir
)
Object
.
keys
(
messages
).
forEach
((
moduleName
)
=>
{
;(
modules
[
moduleName
]
||
(
modules
[
moduleName
]
=
{}))[
locale
]
=
messages
[
moduleName
]
})
})
// modules
// {app: {en: { quit: '' },es: { quit: '' },fr: { quit: "" },'zh-Hans': { quit: '' },'zh-Hant': { quit: '' }}}
const
messagesFile
=
path
.
resolve
(
dir
,
'
messages.ts
'
)
fs
.
writeFileSync
(
messagesFile
,
generateI18nCode
(
namespace
,
modules
))
console
.
log
(
'
write:
'
+
messagesFile
)
}
function
buildI18nLocale
(
locale
,
namespace
,
dir
)
{
return
buildI18nModuleMessages
(
require
(
path
.
resolve
(
dir
,
locale
+
'
.json
'
)),
namespace
)
}
function
buildI18nModuleMessages
(
messages
,
namespace
)
{
const
modules
=
{}
Object
.
keys
(
messages
).
forEach
((
name
)
=>
{
const
[
module
,
...
part
]
=
name
.
replace
(
namespace
+
'
.
'
,
''
).
split
(
'
.
'
)
;(
modules
[
module
]
||
(
modules
[
module
]
=
{}))[
part
.
join
(
'
.
'
)]
=
messages
[
name
]
})
return
modules
}
function
capitalize
(
str
)
{
return
str
.
charAt
(
0
).
toUpperCase
()
+
str
.
slice
(
1
)
}
function
generateI18nCode
(
namespace
,
modules
)
{
return
(
`
// This file is created by scripts/i18n.js
// Do not modify this file!!!!!!!!!
import {
LOCALE_EN,
LOCALE_ES,
LOCALE_FR,
LOCALE_ZH_HANS,
LOCALE_ZH_HANT,
} from '@dcloudio/uni-i18n'
import { useI18n } from './useI18n'
const i18n = useI18n()
function normalizeMessages(
namespace: string,
messages: Record<string, string>
) {
return Object.keys(messages).reduce<Record<string, string>>((res, name) => {
res[namespace + name] = messages[name]
return res
}, {})
}
`
+
Object
.
keys
(
modules
)
.
map
((
name
)
=>
generateI18nModuleCode
(
namespace
,
name
,
modules
[
name
]))
.
join
(
''
)
)
}
function
generateI18nModuleCode
(
namespace
,
name
,
localeMessages
)
{
return
`export function initI18n
${
capitalize
(
name
)}
Msgs() {
const name = '
${
namespace
}
.
${
name
}
.'
${
Object
.
keys
(
localeMessages
)
.
map
((
locale
)
=>
generateI18nModuleLocaleCode
(
locale
,
localeMessages
[
locale
]))
.
join
(
''
)}
}
`
}
function
generateI18nModuleLocaleCode
(
locale
,
messages
)
{
locale
=
locale
.
toUpperCase
().
replace
(
'
-
'
,
'
_
'
)
return
` if (__UNI_FEATURE_I18N_
${
locale
}
__) {
i18n.add(LOCALE_
${
locale
}
, normalizeMessages(name,
${
JSON
.
stringify
(
messages
)}
))
}
`
}
buildI18n
(
'
uni
'
,
path
.
resolve
(
__dirname
,
'
../packages/uni-core/src/i18n
'
))
scripts/utils.js
浏览文件 @
d5eda2ca
...
...
@@ -12,8 +12,8 @@ const priority = {
'
uni-mp-toutiao
'
:
70
,
'
uni-mp-weixin
'
:
70
,
'
uni-quickapp-webview
'
:
70
,
'
uni-h5
-vue
'
:
60
,
'
uni-h5
'
:
50
,
'
uni-h5
'
:
60
,
'
uni-h5
-vue
'
:
50
,
'
uni-cli-shared
'
:
40
,
'
vite-plugin-uni
'
:
30
,
'
size-check
'
:
1
,
...
...
yarn.lock
浏览文件 @
d5eda2ca
...
...
@@ -2192,9 +2192,9 @@ ecc-jsbn@~0.1.1:
safer-buffer "^2.1.0"
electron-to-chromium@^1.3.712:
version "1.3.71
3
"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.71
3.tgz#4583efb17f2d1e9ec07a44c8004ea73c013ad146
"
integrity sha512-
HWgkyX4xTHmxcWWlvv7a87RHSINEcpKYZmDMxkUlHcY+CJcfx7xEfBHuXVsO1rzyYs1WQJ7EgDp2CoErakBIow
==
version "1.3.71
5
"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.71
5.tgz#8fd002e79c13d711133565600f40cd80abfe5d55
"
integrity sha512-
VCWxo9RqTYhcCsHtG+l0TEOS6H5QmO1JyVCQB9nv8fllmAzj1VcCYH3qBCXP75/En6FeoepefnogLPE+5W7OiQ
==
elliptic@^6.5.3:
version "6.5.4"
...
...
@@ -5812,9 +5812,9 @@ symbol-tree@^3.2.4:
integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==
table@^6.0.4:
version "6.
0.9
"
resolved "https://registry.yarnpkg.com/table/-/table-6.
0.9.tgz#790a12bf1e09b87b30e60419bafd6a1fd85536fb
"
integrity sha512-
F3cLs9a3hL1Z7N4+EkSscsel3z55XT950AvB05bwayrNg5T1/gykXtigioTAjbltvbMSJvvhFCbnf6mX+ntnJ
Q==
version "6.
1.0
"
resolved "https://registry.yarnpkg.com/table/-/table-6.
1.0.tgz#676a0cfb206008b59e783fcd94ef8ba7d67d966c
"
integrity sha512-
T4G5KMmqIk6X87gLKWyU5exPpTjLjY5KyrFWaIjv3SvgaIUGXV7UEzGEnZJdTA38/yUS6f9PlKezQ0bYXG3iI
Q==
dependencies:
ajv "^8.0.1"
is-boolean-object "^1.1.0"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录