-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
export enum LOCALES_KEYS { | ||
EN_US = 'en-US', | ||
ZH_CN = 'zh-CN' | ||
} | ||
|
||
export const SUPPOER_LOCALES = [ | ||
{ | ||
name: 'English', | ||
value: LOCALES_KEYS.EN_US | ||
}, | ||
{ | ||
name: '简体中文', | ||
value: LOCALES_KEYS.ZH_CN | ||
} | ||
] | ||
|
||
export interface LocaleResponse { | ||
localeData: StringObject | ||
antdLocaleData: PlainObject | ||
} | ||
|
||
export function getLocaleLoader(locale: string): Promise<LocaleResponse> { | ||
switch (locale) { | ||
case LOCALES_KEYS.ZH_CN: | ||
return new Promise(async resolve => { | ||
const loc = await import(/* webpackChunkName: "zh-CN" */ './zh_CN.json').then(m => m.default) | ||
const antdLoc = await import(/* webpackChunkName: "antd-zh-CN" */ 'antd/lib/locale-provider/zh_CN').then( | ||
m => m.default | ||
) | ||
resolve({ localeData: loc, antdLocaleData: antdLoc }) | ||
}) | ||
default: | ||
return new Promise(async resolve => { | ||
const loc = await import(/* webpackChunkName: "en-US" */ './en_US.json').then(m => m.default) | ||
const antdLoc = await import(/* webpackChunkName: "antd-en-US" */ 'antd/lib/locale-provider/en_US').then( | ||
m => m.default | ||
) | ||
resolve({ localeData: loc, antdLocaleData: antdLoc }) | ||
}) | ||
} | ||
} |
File renamed without changes.
bdecb14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#23