From 03372fb9647eb2d37a85208d08bf3a09d200795d Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Mon, 29 Jan 2024 18:46:09 +0300 Subject: [PATCH] feat: extract translations for atlas pull allow MFEs and others to use this repo translations via openedx-translations github repository --- .gitignore | 2 ++ Makefile | 23 +++++++++++++++++++++++ package.json | 1 + 3 files changed, 26 insertions(+) diff --git a/.gitignore b/.gitignore index 908e81fe5..00b0d34c5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ .vscode coverage dist +src/i18n/transifex_input.json node_modules /docs/api .env.private +/temp/ diff --git a/Makefile b/Makefile index 139d2f848..97dc258b5 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,12 @@ # Documentation CLI usage: https://github.com/documentationjs/documentation/blob/master/docs/USAGE.md +i18n = ./src/i18n +transifex_input = $(i18n)/transifex_input.json +transifex_utils = $(i18n)/scripts/transifex-utils.js + +# This directory must match .babelrc . +transifex_temp = ./temp/babel-plugin-react-intl + doc_command = ./node_modules/.bin/documentation build src -g -c ./docs/documentation.config.yml -f md -o ./docs/_API-body.md --sort-order alpha cat_docs_command = cat ./docs/_API-header.md ./docs/_API-body.md > ./docs/API.md @@ -24,3 +31,19 @@ docs-watch: docs-lint: ./node_modules/.bin/documentation lint src + + +.PHONY: requirements +requirements: ## install ci requirements + npm ci + +i18n.extract: + # Pulling display strings from .jsx files into .json files... + rm -rf $(transifex_temp) + npm run-script i18n_extract + +i18n.concat: + # Gathering JSON messages into one file... + $(transifex_utils) $(transifex_temp) $(transifex_input) + +extract_translations: | requirements i18n.extract i18n.concat diff --git a/package.json b/package.json index 2dce795d9..cf43646ad 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "docs": "jsdoc -c jsdoc.json", "docs-watch": "nodemon -w src -w docs/template -w README.md -e js,jsx --exec npm run docs", "lint": "fedx-scripts eslint --ext .js --ext .jsx .", + "i18n_extract": "fedx-scripts formatjs extract", "snapshot": "fedx-scripts jest --updateSnapshot", "start": "fedx-scripts webpack-dev-server --progress", "test": "fedx-scripts jest --coverage",