Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added Chinese translation for coding-standard. #102

Merged
merged 5 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 17 additions & 8 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,23 @@ function buildChangelog() {
}

function buildCodeStandard() {
const codeStandardDestPath = path.resolve(config.ecWWWGeneratedDir, 'coding-standard-content.html');
fse.ensureDirSync(path.dirname(codeStandardDestPath));
fse.outputFileSync(
codeStandardDestPath,
marked(fs.readFileSync('en/coding-standard.md', 'utf-8')),
'utf-8'
);
console.log(chalk.green('generated: ' + codeStandardDestPath));
// support for Chinese character
const customRenderer = new marked.Renderer();
customRenderer.heading = function(text, level, raw) {
const id = raw.toLowerCase().replace(/[^\w\u4e00-\u9fa5]+/g, '-');
return `<h${level} id="${id}">${text}</h${level}>\n`;
};

for (let lang of languages) {
const codeStandardDestPath = path.resolve(config.ecWWWGeneratedDir, `${lang}/coding-standard-content.html`);
fse.ensureDirSync(path.dirname(codeStandardDestPath));
fse.outputFileSync(
codeStandardDestPath,
marked(fs.readFileSync(`${lang}/coding-standard.md`, 'utf-8'), { renderer: customRenderer }),
'utf-8'
);
console.log(chalk.green('generated: ' + codeStandardDestPath));
}

console.log('Build code standard done.');
}
Expand Down
6 changes: 3 additions & 3 deletions en/coding-standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ try {
### Statement


**[MUST]** The comma must not be ignored at the end of a statement.
**[MUST]** The semicolon must not be ignored at the end of a statement.


**[MUST]** The `{}` must not be ignored even if there is only one line.
Expand All @@ -424,7 +424,7 @@ if (condition)
```


**[MUST]** Place no comma at the end of a function definition.
**[MUST]** Place no semicolon at the end of a function definition.

```js
// good
Expand All @@ -435,7 +435,7 @@ function funcName() {
function funcName() {
};

// For function expression, the comma must not be ignored.
// For function expression, the semicolon must not be ignored.
var funcName = function () {
};
```
Expand Down