From 75d127b2a81da69fd5f4eb0deacb2d04f4fefa85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Thu, 10 Nov 2022 14:24:45 +0100 Subject: [PATCH] Update docs on managing translations (#748) --- Readme.md | 24 ++++++++++++++++++++++++ scripts/build-translations.js | 9 +++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 3ffe2cef1..d4986dc52 100644 --- a/Readme.md +++ b/Readme.md @@ -33,3 +33,27 @@ yarn run start ``` We also provide a `Dockerfile` for easy deployment. + +## Managing translations + +You should have checked out the https://github.com/ooni/translations +repository. + +From inside of `ooni/translations` to update the transifex master copy (this is +done when edits to the master spreadsheet are done), you should run: +``` +./update-explorer-source.sh +``` + +Then when the translations have been done and you want to pull in the +translated versions, run: +``` +./update-explorer-translations.sh +``` + +From inside of the ooni/explorer repo you should then run: +``` +yarn run script:build-translations +``` + +(this assumes you have `ooni/translations` checked out in the parent directory) diff --git a/scripts/build-translations.js b/scripts/build-translations.js index 4766c55d9..fbf2864c2 100644 --- a/scripts/build-translations.js +++ b/scripts/build-translations.js @@ -1,19 +1,16 @@ /* eslint-disable no-console */ -/* global require */ const glob = require('glob') -const { basename, resolve } = require('path') -// const csvParse = require('csv-parse/lib/sync') +const { basename } = require('path') const { readFileSync, writeFileSync } = require('fs') const LANG_DIR = './public/static/lang/' -const DEFAULT_LOCALE = 'en' const TRANSLATED_STRINGS_DIR = '../translations/explorer' -const supportedLanguages = glob.sync(`${LANG_DIR}/*.json`).map((f) => basename(f, '.json')) +const supportedLanguages = glob.sync(`${TRANSLATED_STRINGS_DIR}/*`).map((f) => basename(f, '.json')) // Copy latest files from `translations` supportedLanguages.forEach((lang) => { - console.log('> Getting latest translations for langugae ✨', lang) + console.log('> Getting latest translations for:', lang) writeFileSync(`${LANG_DIR}/${lang}.json`, readFileSync(`${TRANSLATED_STRINGS_DIR}/${lang}/strings.json`)) })