Skip to content

Commit

Permalink
Merge pull request #336 from openedx/dsheraz/push-translation-update
Browse files Browse the repository at this point in the history
build: update push translation job
  • Loading branch information
DawoudSheraz authored Apr 6, 2022
2 parents 671d98c + 4d1387f commit 51cc791
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"i18n": {
"plugins": [
["react-intl", {
"messagesDir": "./src/data/i18n/default/",
"messagesDir": "./temp/babel-plugin-react-intl",
"enforceDescriptions": true
}]
]
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
node_modules
npm-debug.log
coverage
.idea

dist/
src/data/i18n/default/src/
temp/babel-plugin-react-intl

## Emacs ###
*~
/temp
/.vscode
1 change: 1 addition & 0 deletions .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ host = https://www.transifex.com

[o:open-edx:p:edx-platform:r:studio-frontend]
file_filter = src/data/i18n/locales/<lang>.json
source_file = src/data/i18n/default/transifex_input.json
source_lang = en_US
type = KEYVALUEJSON

28 changes: 19 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
UNAME := $(shell uname)

i18n = ./src/data/i18n/default
transifex_input = $(i18n)/transifex_input.json

# This directory must match .babelrc .
transifex_temp = ./temp/babel-plugin-react-intl

export TRANSIFEX_RESOURCE = studio-frontend

# Help message borrowed from https://github.com/edx/devstack, which borrowed it from https://github.com/pydanny/cookiecutter-djangopackage.
Expand Down Expand Up @@ -28,6 +35,9 @@ down: ## stop and remove studio-frontend container
stop: ## stops studio-frontend container
docker-compose stop

requirements:
npm install

npm-install-%: ## install specified % npm package on the studio-frontend container
docker exec dahlia.studio-frontend npm install $* --save-dev
git add package.json
Expand Down Expand Up @@ -55,27 +65,27 @@ asset-page-flag: ## insert a waffle flag into local docker devstack
i18n.docker: ## what devs should do from their host machines
docker exec -t dahlia.studio-frontend bash -c 'make i18n.extract && make i18n.preprocess'

extract_translations: ## no prerequisites so we can control order of operations
echo "We have to define this target due to tooling assumptions"
echo "Also we have to npm install using this hook b/c there's no other place for it in the current setup"
npm install
npm run-script i18n_extract
extract_translations: | requirements i18n.extract i18n.preprocess

i18n.extract: ## move display strings from displayMessages.jsx to displayMessages.json
npm run-script i18n_extract

i18n.preprocess: ## gather all display strings into a single file
$$(npm bin)/reactifex ./src/data/i18n/default/src/components/ ./src/data/i18n/default/transifex_input.json
$$(npm bin)/edx_reactifex $(transifex_temp) $(transifex_input)

i18n.pre_validate: | i18n.extract i18n.preprocess
git diff --exit-code ./src/data/i18n/default/transifex_input.json

tx_url1 = https://www.transifex.com/api/2/project/edx-platform/resource/studio-frontend/translation/en/strings/
tx_url2 = https://www.transifex.com/api/2/project/edx-platform/resource/studio-frontend/source/
push_translations: | i18n.extract
# Transifex is set up to watch transifex_input.json, but that filetype lacks comments
# Pushes translations to Transifex. You must run make extract_translations first.
push_translations:

# # Pushing strings to Transifex...
tx push -s

./node_modules/@edx/reactifex/bash_scripts/get_hashed_strings_v3.sh
$$(npm bin)/edx_reactifex ./src/data/i18n/default --comments --v3-scripts-path
$$(npm bin)/edx_reactifex $(transifex_temp) --comments --v3-scripts-path
./node_modules/@edx/reactifex/bash_scripts/put_comments_v3.sh

pull_translations: ## must be exactly this name for edx tooling support, see ecommerce-scripts/transifex/pull.py
Expand Down

0 comments on commit 51cc791

Please sign in to comment.