Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

fix: use crowdin-glossary #336

Merged
merged 6 commits into from
May 8, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@ If you're using a platform like Utopian.io and would like to be promoted to
proofreader status on the Electron project, please translate 1,000 words or
more before applying. When contacting us, please include a link to your existing translations on the project.

## Glossaries

There are two different "glossaries" in the Electron world:

### 1. [The Electron Glossary](https://github.com/electron/electron/blob/master/docs/glossary.md)

The Electron Glossary is a **hand-written** markdown file. It defines terms
that are common in Electron development, like "ASAR", "IPC", "V8", etc.
To add entries to it, open a pull request on the electron/electron repository.

### 2. [The Crowdin Glossary](https://support.crowdin.com/glossary/)

The Crowdin Glossary is **programatically generated**. It defines terms to give
translators context when translating in the Crowdin UI, and to help avoid
translations of strings like `Array` and `win.open()` that should remain in
their original "English" form. It includes entries for JavaScript builtins,
Electron API names, method names, event names, etc. To modify this glossary,
see [script/upload-crowdin-glossary.js](script/upload-crowdin-glossary.js)

## Developing `electron-i18n`

The rest of this document describes how this repo is structured, how
Expand Down
15 changes: 11 additions & 4 deletions lib/parse-glossary-doc.js → lib/parse-electron-glossary.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const cheerio = require('cheerio')
const hubdown = require('hubdown')

async function parseGlossaryDoc (locale) {
async function parseElectronGlossary (locale) {
assert(locale, '`locale` is a required argument to parseGlosssaryDoc()')

const sourceFile = path.join(__dirname, `../content/${locale}/docs/glossary.md`)
const md = fs.readFileSync(sourceFile, 'utf8')
const {content: html} = await hubdown(md)
Expand All @@ -13,7 +16,6 @@ async function parseGlossaryDoc (locale) {
.map((i, el) => {
return {
term: $(el).text(),
type: 'electronJargon',
description: $(el).next('p')
.text()
.replace(/\n/g, ' ')
Expand All @@ -22,9 +24,14 @@ async function parseGlossaryDoc (locale) {
})
.get()
.reduce((acc, entry) => {
acc[entry.term] = entry
if (entry && entry.term && entry.description && entry.description.length) {
acc[entry.term] = entry
} else {
console.error('glossary entry is missing required properties', entry)
console.error('locale', locale)
}
return acc
}, {})
}

module.exports = parseGlossaryDoc
module.exports = parseElectronGlossary
155 changes: 79 additions & 76 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"check-for-leaks": "^1.2.0",
"cheerio": "^1.0.0-rc.2",
"clean-deep": "^3.0.2",
"crowdin-glossary": "^1.2.0",
"del": "^3.0.0",
"dotenv-safe": "^5.0.1",
"electron-docs": "^3.0.2",
"form-data": "^2.3.2",
"get-crowdin-file-ids": "^1.1.1",
"github-slugger": "^1.2.0",
"globals": "^11.3.0",
Expand All @@ -40,7 +40,6 @@
"semantic-release": "^15.1.7",
"simple-statistics": "^5.3.1",
"standard": "^11.0.1",
"tmp": "^0.0.33",
"travis-deploy-once": "^4.4.1",
"walk-sync": "^0.3.2"
},
Expand All @@ -60,11 +59,9 @@
"pretest": "npm run build",
"travis-deploy-once": "travis-deploy-once",
"semantic-release": "semantic-release",
"glossary": "npm-run-all glossary:*",
"glossary:build": "node script/build-glossary.js",
"glossary:upload": "node script/upload-glossary.js",
"upload-crowdin-glossary": "node script/upload-crowdin-glossary.js",
"wordcount": "node script/wordcount.js > wordcount.md"
},
"electronLatestStableTag": "v2.0.0",
"electronMasterBranchCommit": "daf75dd3755c994fdfba3f70686e75f4e4c4a2a2"
}
}
Loading