UNPKG

671 BJavaScriptView Raw
1import {
2 I18N_INIT,
3 setAvailableLocales,
4 localeId,
5 setLocaleId,
6 setLocales,
7 parseLocaleId,
8} from '../index'
9import {
10 actionLocales,
11} from '../redux'
12
13
14/**
15 * 初始化 (非同构项目)
16 *
17 * @param {array|object} arg 可用语言列表(Array) | 语言包内容(object)
18 */
19export default (arg) => {
20 if (Array.isArray(arg)) {
21 setAvailableLocales(arg)
22 setLocaleId(parseLocaleId())
23
24 return {
25 type: I18N_INIT,
26 localeId: '' + localeId
27 }
28 } else if (typeof arg === 'object') {
29 setLocales(localeId, arg)
30 return actionLocales()
31 }
32}