fix: heads in original and translation must be same level

This commit is contained in:
Zhicheng Wang 2018-03-01 22:28:13 +08:00
parent 53a7a4cbf5
commit 6642b82445
5 changed files with 29 additions and 11 deletions

View File

@ -3,17 +3,31 @@ import { DictEntry } from './dict-entry';
import { gatherFromMarkdownFiles, isTranslation } from './extractor';
describe('auto check translations', function () {
const entries = gatherFromMarkdownFiles(__dirname + '/../');
const entries = gatherFromMarkdownFiles(__dirname + '/../')
.filter(isNotCheatSheet)
.filter(isNotMarketingDocs)
.filter(isNotCnPages);
it('should not have <code-example> in translation', function () {
const codeExamples = entries.filter(entry => entry.translation.indexOf('<code-example') !== -1);
expect(codeExamples).eql([]);
});
it('english should not be translations', function () {
const lines = entries.filter(entry => isTranslation(entry.original))
.filter(isNotImg)
.filter(isNotCheatSheet)
.filter(isNotMarketingDocs)
.filter(isNotCnPages);
.filter(isNotImg);
expect(lines).eql([]);
});
it('should have same head level', function () {
const lines = entries
.filter(entry => isHead(entry.original) && isHead(entry.translation))
.filter(entry => {
const originalLevel = entry.original.replace(/^(#+).*$/, '$1').length;
const translationLevel = entry.translation.replace(/^(#+).*$/, '$1').length;
return originalLevel !== translationLevel;
});
expect(lines).eql([]);
});
});
@ -33,3 +47,7 @@ function isNotMarketingDocs(entry: DictEntry): boolean {
function isNotCnPages(entry: DictEntry): boolean {
return !/cn\/.*?.md$/.test(entry.sourceFile);
}
function isHead(line: string): boolean {
return /^#/.test(line);
}

View File

@ -11571,7 +11571,7 @@
},
{
"original": "## What's the difference between a _bootstrap_ component and an _entry component_?",
"translation": "### *引导组件*和*入口组件*有什么不同?",
"translation": "## *引导组件*和*入口组件*有什么不同?",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/ngmodule-faq.md"
},
{
@ -12226,7 +12226,7 @@
},
{
"original": "## The *PipeTransform* interface",
"translation": "### *PipeTransform*接口",
"translation": "## *PipeTransform*接口",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/pipes.md"
},
{
@ -15776,7 +15776,7 @@
},
{
"original": "### _Activated Route_ in action",
"translation": "#### _Activated Route_ 实战",
"translation": "### _Activated Route_ 实战",
"sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/guide/router.md"
},
{

View File

@ -870,7 +870,7 @@ For more information, see [Entry Components](guide/entry-components).
## What's the difference between a _bootstrap_ component and an _entry component_?
### *引导组件*和*入口组件*有什么不同?
## *引导组件*和*入口组件*有什么不同?
A bootstrapped component _is_ an [entry component](guide/ngmodule-faq#q-entry-component-defined)
that Angular loads into the DOM during the bootstrap process (application launch).

View File

@ -276,7 +276,7 @@ Your pipe has one such parameter: the `exponent`.
## The *PipeTransform* interface
### *PipeTransform*接口
## *PipeTransform*接口
The `transform` method is essential to a pipe.
The `PipeTransform` *interface* defines that method and guides both tooling and the compiler.

View File

@ -2621,7 +2621,7 @@ the `HeroDetailComponent` via the `ActivatedRoute` service.
### _Activated Route_ in action
#### _Activated Route_ 实战
### _Activated Route_ 实战
Import the `Router`, `ActivatedRoute`, and `ParamMap` tokens from the router package.