mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
81d8eb8afe
* ConfigProvider support locale * update docs * update category * clean up * moving locale * update check script * update related code * add test case * demo link * update doc * hide one rule of md with eslint * update error link
26 lines
733 B
JavaScript
26 lines
733 B
JavaScript
/* eslint-disable no-console */
|
|
/**
|
|
* Generate legacy locale file as shadow of `/locale` to `/locale-provider`.
|
|
*/
|
|
|
|
const glob = require('glob');
|
|
const fs = require('fs');
|
|
const chalk = require('chalk');
|
|
|
|
glob('components/locale/@(*_*|default).tsx', (er, files) => {
|
|
files.forEach(filePath => {
|
|
const modulePath = filePath.replace(/^components/, '..').replace('.tsx', '');
|
|
const legacyModulePath = filePath.replace('locale', 'locale-provider');
|
|
|
|
const template = `import locale from '${modulePath}';
|
|
|
|
export default locale;
|
|
`.trim();
|
|
|
|
console.log(modulePath, '=>', legacyModulePath);
|
|
fs.writeFileSync(legacyModulePath, template, 'utf8');
|
|
});
|
|
|
|
console.log(chalk.green('✨ Locale generate success!'));
|
|
});
|