diff --git a/aio/content/dict/checker.spec.ts b/aio/tools/translator/checker.spec.ts similarity index 94% rename from aio/content/dict/checker.spec.ts rename to aio/tools/translator/checker.spec.ts index 969d3e1e2d..d2cbb08d11 100644 --- a/aio/content/dict/checker.spec.ts +++ b/aio/tools/translator/checker.spec.ts @@ -1,9 +1,10 @@ import { expect } from 'chai'; import { DictEntry } from './dict-entry'; +import { dirs } from './dirs'; import { gatherFromMarkdownFiles, isTranslation } from './extractor'; describe('auto check translations', function () { - const entries = gatherFromMarkdownFiles(__dirname + '/../') + const entries = gatherFromMarkdownFiles(dirs.content) .filter(isNotCheatSheet) .filter(isNotMarketingDocs) .filter(isNotCnPages); diff --git a/aio/content/dict/dict-1.json b/aio/tools/translator/dict-1.json similarity index 100% rename from aio/content/dict/dict-1.json rename to aio/tools/translator/dict-1.json diff --git a/aio/content/dict/dict-2.json b/aio/tools/translator/dict-2.json similarity index 100% rename from aio/content/dict/dict-2.json rename to aio/tools/translator/dict-2.json diff --git a/aio/content/dict/dict-3.json b/aio/tools/translator/dict-3.json similarity index 100% rename from aio/content/dict/dict-3.json rename to aio/tools/translator/dict-3.json diff --git a/aio/content/dict/dict-entry.ts b/aio/tools/translator/dict-entry.ts similarity index 100% rename from aio/content/dict/dict-entry.ts rename to aio/tools/translator/dict-entry.ts diff --git a/aio/tools/translator/dirs.ts b/aio/tools/translator/dirs.ts new file mode 100644 index 0000000000..ddfa382544 --- /dev/null +++ b/aio/tools/translator/dirs.ts @@ -0,0 +1,9 @@ +export const dirs = { + aio: __dirname + '/../../', + get content(): string { + return this.aio + 'content/'; + }, + get here(): string { + return this.aio + 'tools/translator/'; + }, +}; diff --git a/aio/content/dict/extractor.spec.ts b/aio/tools/translator/extractor.spec.ts similarity index 78% rename from aio/content/dict/extractor.spec.ts rename to aio/tools/translator/extractor.spec.ts index b7703c6a77..d1858d6bf4 100644 --- a/aio/content/dict/extractor.spec.ts +++ b/aio/tools/translator/extractor.spec.ts @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import { dirs } from './dirs'; import { gatherFromMarkdownFiles, gatherTranslations, listMarkdownFiles, splitAndTrim } from './extractor'; describe('gather to dictionary', () => { @@ -31,20 +32,20 @@ describe('gather to dictionary', () => { it('should gather from real file', function () { const fs = require('fs'); - const content = fs.readFileSync(__dirname + '/../guide/forms.md', 'utf-8'); + const content = fs.readFileSync(dirs.content + 'guide/forms.md', 'utf-8'); const result = gatherTranslations(content); expect(result[0]).eql({original: '# Forms', translation: '# 表单'}); }); it('should list files recursive', function () { - expect(listMarkdownFiles(__dirname + '/../').length).greaterThan(10); + expect(listMarkdownFiles(dirs.content).length).greaterThan(10); }); it('should gather from directory', () => { - const entries = gatherFromMarkdownFiles(__dirname + '/../'); + const entries = gatherFromMarkdownFiles(dirs.content); const dict = JSON.stringify(entries, null, 2); const fs = require('fs'); - fs.writeFileSync(__dirname + '/../dict/dict-3.json', dict, 'utf-8'); + fs.writeFileSync(dirs.here + 'dict-3.json', dict, 'utf-8'); expect(entries.length).greaterThan(100); }); diff --git a/aio/content/dict/extractor.ts b/aio/tools/translator/extractor.ts similarity index 100% rename from aio/content/dict/extractor.ts rename to aio/tools/translator/extractor.ts diff --git a/aio/content/dict/translate.spec.ts b/aio/tools/translator/translate.spec.ts similarity index 100% rename from aio/content/dict/translate.spec.ts rename to aio/tools/translator/translate.spec.ts diff --git a/aio/content/dict/translate.ts b/aio/tools/translator/translate.ts similarity index 100% rename from aio/content/dict/translate.ts rename to aio/tools/translator/translate.ts