Changes ------- - Bump frontend-platform to bring `intl-imports.js` script - Move all i18n imports into `src/i18n/index.js` so `intl-imports.js` can override it with latest translations - Add `atlas` into `make pull_translations` when `OPENEDX_ATLAS_PULL` environment variable is set. - Refactored i18n utils into own file to avoid overwriting them by atlas Refs: [FC-0012 project](https://openedx.atlassian.net/l/cp/XGS0iCcQ) implementing Translation Infrastructure OEP-58.
80 lines
2.9 KiB
Makefile
80 lines
2.9 KiB
Makefile
npm-install-%: ## install specified % npm package
|
|
npm install $* --save-dev
|
|
git add package.json
|
|
export TRANSIFEX_RESOURCE = frontend-app-gradebook
|
|
transifex_langs = "ar,de,es_419,fa_IR,fr,fr_CA,hi,it,pt,ru,uk,zh_CN"
|
|
|
|
intl_imports = ./node_modules/.bin/intl-imports.js
|
|
transifex_utils = ./node_modules/.bin/transifex-utils.js
|
|
i18n = ./src/i18n
|
|
transifex_input = $(i18n)/transifex_input.json
|
|
tx_url1 = https://www.transifex.com/api/2/project/edx-platform/resource/$(transifex_resource)/translation/en/strings/
|
|
tx_url2 = https://www.transifex.com/api/2/project/edx-platform/resource/$(transifex_resource)/source/
|
|
|
|
# This directory must match .babelrc .
|
|
transifex_temp = ./temp/babel-plugin-react-intl
|
|
|
|
NPM_TESTS=build i18n_extract lint test is-es5
|
|
|
|
.PHONY: test
|
|
test: $(addprefix test.npm.,$(NPM_TESTS)) ## validate ci suite
|
|
|
|
.PHONY: test.npm.*
|
|
test.npm.%: validate-no-uncommitted-package-lock-changes
|
|
test -d node_modules || $(MAKE) requirements
|
|
npm run $(*)
|
|
|
|
.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
|
|
|
|
# Despite the name, we actually need this target to detect changes in the incoming translated message files as well.
|
|
detect_changed_source_translations:
|
|
# Checking for changed translations...
|
|
git diff --exit-code $(i18n)
|
|
|
|
# Pushes translations to Transifex. You must run make extract_translations first.
|
|
push_translations:
|
|
# Pushing strings to Transifex...
|
|
tx push -s
|
|
# Fetching hashes from Transifex...
|
|
./node_modules/@edx/reactifex/bash_scripts/get_hashed_strings_v3.sh
|
|
# Writing out comments to file...
|
|
$(transifex_utils) $(transifex_temp) --comments --v3-scripts-path
|
|
# Pushing comments to Transifex...
|
|
./node_modules/@edx/reactifex/bash_scripts/put_comments_v3.sh
|
|
|
|
ifeq ($(OPENEDX_ATLAS_PULL),)
|
|
# Pulls translations from Transifex.
|
|
pull_translations:
|
|
tx pull -t -f --mode reviewed --languages=$(transifex_langs)
|
|
else
|
|
# Experimental: OEP-58 Pulls translations using atlas
|
|
pull_translations:
|
|
rm -rf src/i18n/messages
|
|
mkdir src/i18n/messages
|
|
cd src/i18n/messages \
|
|
&& atlas pull --filter=$(transifex_langs) \
|
|
translations/frontend-component-footer/src/i18n/messages:frontend-component-footer \
|
|
translations/frontend-component-header/src/i18n/messages:frontend-component-header \
|
|
translations/frontend-app-gradebook/src/i18n/messages:frontend-app-gradebook
|
|
|
|
$(intl_imports) frontend-component-header frontend-component-footer frontend-app-gradebook
|
|
endif
|
|
|
|
# This target is used by CI.
|
|
validate-no-uncommitted-package-lock-changes:
|
|
# Checking for package-lock.json changes...
|
|
git diff --exit-code package-lock.json
|