2018-03-01 22:19:59 +08:00
|
|
|
import { expect } from 'chai';
|
2018-03-01 22:52:16 +08:00
|
|
|
import { dirs } from './dirs';
|
2018-03-03 11:01:57 +08:00
|
|
|
import { kernelText, lookup, translate } from './translate';
|
2018-03-01 22:19:59 +08:00
|
|
|
|
|
|
|
|
2018-03-02 08:08:39 +08:00
|
|
|
describe('根据字典进行翻译', () => {
|
2018-03-02 14:25:07 +08:00
|
|
|
it('抽取核心字符', function () {
|
|
|
|
expect(kernelText(' # Forms ABC ')).eql('# Forms ABC');
|
|
|
|
});
|
|
|
|
|
2018-03-02 08:08:39 +08:00
|
|
|
it('查字典', () => {
|
2018-03-01 22:19:59 +08:00
|
|
|
expect(lookup('# Forms')[0].translation).eql('# 表单');
|
|
|
|
});
|
2018-03-01 22:52:16 +08:00
|
|
|
|
2018-03-02 08:08:39 +08:00
|
|
|
it('自动根据字典翻译单个文件', function () {
|
2018-03-01 22:52:16 +08:00
|
|
|
const fs = require('fs');
|
2018-03-02 14:25:07 +08:00
|
|
|
const content = fs.readFileSync(__dirname + '/../../../../content-en/' + 'guide/forms.md', 'utf-8');
|
2018-03-01 22:52:16 +08:00
|
|
|
const result = translate(content);
|
|
|
|
fs.writeFileSync(dirs.content + 'guide/forms.md', result.join('\n\n'), 'utf-8');
|
|
|
|
});
|
2018-03-01 22:19:59 +08:00
|
|
|
});
|