diff --git a/lang/readme.md b/lang/readme.md index 360fc145d..12aec9eed 100644 --- a/lang/readme.md +++ b/lang/readme.md @@ -1,15 +1,25 @@ -Jitsi Meet Translation -========================== +# Jitsi Meet Translation + Jitsi Meet uses [i18next](http://i18next.com) library for translation. i18next uses separate json files for each language. -Translating Jitsi Meet -====================== +## Translating Jitsi Meet + The translation of Jitsi Meet is handled editing manually the language files. -Development -=========== +You can use the `update-translation.js` script as follows to help you with that: + +```js +cd lang +node update-translation.js main-es.json +``` + +That will cause the `main-es.json` file to be updated with all the missing keys set as empty +strings. All that's missing is for you to fill in the blanks! + +## Development + If you want to add new functionality for Jitsi Meet and you have texts that need to be translated you must add key and value in main.json file in English for each translatable text. Than you can use the key to get the translated text for the current language. @@ -43,7 +53,3 @@ You can add translatable text in the HTML: For the available values of ``options`` parameter for the above methods of translation module see [i18next documentation](http://i18next.com/pages/doc_features). **Note:** It is useful to add attributes in the HTML for persistent HTML elements because when the language is changed the text will be automatically translated. - - - - diff --git a/lang/update-translation.js b/lang/update-translation.js new file mode 100644 index 000000000..4c4de048c --- /dev/null +++ b/lang/update-translation.js @@ -0,0 +1,38 @@ +/* eslint-disable */ + +const fs = require('fs'); +const process = require('process'); +const traverse = require('traverse'); +const mainLang = require('./main.json'); + +const [ targetLangFile ] = process.argv.slice(-1); + +if (!targetLangFile) { + console.log('No target language file specified'); + process.exit(1); +} + +const targetLang = require(`./${targetLangFile}`); + +const paths = traverse(mainLang).reduce(function(acc, item) { + if (this.isLeaf) { + acc.push(this.path); + } + + return acc; +}, []); + +const result = {}; + +for (const path of paths) { + if (traverse(targetLang).has(path)) { + traverse(result).set(path, traverse(targetLang).get(path)); + } else { + //console.log(`${path.join('.')} is missing`); + traverse(result).set(path, ''); + } +} + +const data = JSON.stringify(result, undefined, 4); + +fs.writeFileSync(`./${targetLangFile}`, data); diff --git a/package-lock.json b/package-lock.json index 09af8a6da..1ff84b742 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17777,6 +17777,12 @@ "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", "dev": true }, + "traverse": { + "version": "0.6.6", + "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.6.tgz", + "integrity": "sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc=", + "dev": true + }, "trim-right": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", diff --git a/package.json b/package.json index 963351bfb..31b043ea1 100644 --- a/package.json +++ b/package.json @@ -146,6 +146,7 @@ "sass": "1.26.8", "string-replace-loader": "2.1.1", "style-loader": "0.19.0", + "traverse": "0.6.6", "unorm": "1.6.0", "webpack": "4.43.0", "webpack-bundle-analyzer": "3.4.1",