angular-cn/aio/tools/translator/translate.spec.ts
Zhicheng Wang b8400fad7c feat: 三行简化为两行
refactor: 抽取出工具函数
2018-03-03 11:01:57 +08:00

22 lines
703 B
TypeScript

import { expect } from 'chai';
import { dirs } from './dirs';
import { kernelText, lookup, translate } from './translate';
describe('根据字典进行翻译', () => {
it('抽取核心字符', function () {
expect(kernelText(' # Forms ABC ')).eql('# Forms ABC');
});
it('查字典', () => {
expect(lookup('# Forms')[0].translation).eql('# 表单');
});
it('自动根据字典翻译单个文件', function () {
const fs = require('fs');
const content = fs.readFileSync(__dirname + '/../../../../content-en/' + 'guide/forms.md', 'utf-8');
const result = translate(content);
fs.writeFileSync(dirs.content + 'guide/forms.md', result.join('\n\n'), 'utf-8');
});
});