fix(plugin-client): extract locale files of antd
This commit is contained in:
parent
a0599e0638
commit
cf77ca1792
@ -20,8 +20,22 @@ exports.run = async (log) => {
|
||||
});
|
||||
|
||||
log('coping antd locale');
|
||||
await fs.cp(path.resolve(path.dirname(antd)), path.resolve(localeDir, 'antd'), {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
const files = await fs.readdir(path.resolve(path.dirname(antd), 'locale'));
|
||||
await fs.mkdir(path.resolve(localeDir, 'antd'), { force: true, recursive: true });
|
||||
for (const file of files) {
|
||||
if (path.extname(file) !== '.js') {
|
||||
continue;
|
||||
}
|
||||
const content = require(path.resolve(path.dirname(antd), 'locale', file)).default;
|
||||
try {
|
||||
await fs.writeFile(
|
||||
path.resolve(localeDir, 'antd', file),
|
||||
`module.exports = ${JSON.stringify(content)}`,
|
||||
'utf-8',
|
||||
{},
|
||||
);
|
||||
} catch (error) {
|
||||
log(`skip ${file}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -3,7 +3,7 @@ import { resolve } from 'path';
|
||||
|
||||
export const getAntdLocale = (lang) => {
|
||||
const lng = lang.replace('-', '_');
|
||||
const files = [resolve(__dirname, `./../locale/antd/locale/${lng}`)];
|
||||
const files = [resolve(__dirname, `../locale/antd/${lng}`)];
|
||||
if (process.env.APP_ENV !== 'production') {
|
||||
files.unshift(`antd/lib/locale/${lng}`);
|
||||
files.push(`antd/lib/locale/en_US`);
|
||||
|
Loading…
Reference in New Issue
Block a user