mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-12-05 13:48:03 +08:00
4ccb8ea9ae
* init i18n * update router * finish router * Review: message/messageBox/notification * Tag: update doc * Review: pagination/popover/progress * i18n: sync with master
27 lines
866 B
JavaScript
27 lines
866 B
JavaScript
'use strict';
|
|
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
var langConfig = require('../../examples/i18n/page.json');
|
|
|
|
langConfig.forEach(lang => {
|
|
try {
|
|
fs.statSync(path.resolve(__dirname, `../../examples/pages/${ lang.lang }`));
|
|
} catch (e) {
|
|
fs.mkdirSync(path.resolve(__dirname, `../../examples/pages/${ lang.lang }`));
|
|
}
|
|
|
|
Object.keys(lang.pages).forEach(page => {
|
|
var templatePath = path.resolve(__dirname, `../../examples/pages/template/${ page }.tpl`);
|
|
var outputPath = path.resolve(__dirname, `../../examples/pages/${ lang.lang }/${ page }.vue`);
|
|
var content = fs.readFileSync(templatePath, 'utf8');
|
|
var pairs = lang.pages[page];
|
|
|
|
Object.keys(pairs).forEach(key => {
|
|
content = content.replace(new RegExp(`<%=\\s*${ key }\\s*>`, 'g'), pairs[key]);
|
|
});
|
|
|
|
fs.writeFileSync(outputPath, content);
|
|
});
|
|
});
|