nocobase/packages/plugins/client/src/antd.ts
chenos cc47041519
feat: load multiple languages dynamically (#1355)
* feat: load multiple languages dynamically

* fix: map locale

* fix: antd

* fix: locale

* fix: th

* fix: cronstrue locales

* fix: improve code

* fix: defaults
2023-01-13 10:55:04 +08:00

10 lines
268 B
TypeScript

export const getAntdLocale = (lang) => {
const lng = lang.replace('-', '_');
try {
require.resolve(`antd/lib/locale/${lng}`);
return require(`antd/lib/locale/${lng}`).default;
} catch (error) {
return require(`antd/lib/locale/en_US`).default;
}
};