diff --git a/aio/tools/translator/bin/translate-one.ts b/aio/tools/translator/bin/translate-one.ts
index 0feb105d71..383a76a20b 100644
--- a/aio/tools/translator/bin/translate-one.ts
+++ b/aio/tools/translator/bin/translate-one.ts
@@ -3,5 +3,5 @@
import { dirs } from '../dirs';
import { translateFile } from '../translate';
-const filename = 'ajs-quick-reference.md';
+const filename = 'api-page-class.md';
translateFile(__dirname + '/../../../../../content-en/' + 'guide/' + filename, dirs.content + 'guide/' + filename);
diff --git a/aio/tools/translator/translate.ts b/aio/tools/translator/translate.ts
index e5a427ceb7..1b87ce13e9 100644
--- a/aio/tools/translator/translate.ts
+++ b/aio/tools/translator/translate.ts
@@ -45,7 +45,7 @@ export function translate(content: string): string[] {
export function translateFile(sourceFile: string, targetFile: string): void {
const content = fs.readFileSync(sourceFile, 'utf-8');
const result = translate(content);
- fs.writeFileSync(targetFile, result.join('\n\n'), 'utf-8');
+ fs.writeFileSync(targetFile, result.join('\n\n').trim() + '\n', 'utf-8');
}
export function translateDirectory(sourceDir: string, targetDir: string): void {
diff --git a/aio/tools/translator/utils.spec.ts b/aio/tools/translator/utils.spec.ts
index 927f1b207a..e85963f999 100644
--- a/aio/tools/translator/utils.spec.ts
+++ b/aio/tools/translator/utils.spec.ts
@@ -3,24 +3,46 @@ import { normalizeLines } from './utils';
describe(' 工具函数', () => {
it('把“1. ”列表处理成空行分隔的格式,以便处理', function () {
- const lines = normalizeLines('1. abc\n11. def\n');
- expect(lines).eql('1. abc\n\n11. def\n');
+ const lines = normalizeLines(`1. abc
+11. def
+`);
+ expect(lines).eql(`
+1. abc
+
+11. def
+`);
});
it('把“- ”列表处理成空行分隔的格式,以便处理', function () {
- const lines = normalizeLines('- abc\n- def\n');
- expect(lines).eql('- abc\n\n- def\n');
+ const lines = normalizeLines(`- abc
+- def
+`);
+ expect(lines).eql(`
+- abc
+
+- def
+`);
});
it('把“* ”列表处理成空行分隔的格式,以便处理', function () {
- const lines = normalizeLines('* abc\n* def\n');
- expect(lines).eql('* abc\n\n* def\n');
+ const lines = normalizeLines(`* abc
+* def
+`);
+ expect(lines).eql(`
+* abc
+
+* def
+`);
});
it('把“# ”标题处理成空行分隔的格式,以便处理', function () {
const lines = normalizeLines(`\n# abc
def`);
- expect(lines).eql('\n\n# abc\n\ndef');
+ expect(lines).eql(`
+# abc
+
+def
+`);
});
it('拆解单行的成对 tag', function () {
@@ -159,13 +181,11 @@ def`);
`);
expect(lines).eq(`
-
a @@ -193,7 +212,6 @@ def`); 一
- `); }); @@ -203,34 +221,64 @@ def`); abc `)).eql(` -