Skip to content

Commit

Permalink
feat: setup transifex translations for onboarding component
Browse files Browse the repository at this point in the history
VAN-1992
  • Loading branch information
mubbsharanwar committed Aug 1, 2024
1 parent fccfc91 commit dff7378
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
8 changes: 8 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[main]
host = https://www.transifex.com

[o:2uedx:p:pros:r:frontend-component-authn-edx]
file_filter = src/i18n/messages/<lang>.json
source_file = src/i18n/transifex_input.json
source_lang = en
type = KEYVALUEJSON
53 changes: 27 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
export TRANSIFEX_RESOURCE = frontend-component-authn-edx
transifex_resource = frontend-component-authn-edx
transifex_langs = "ar,fr,es_419,zh_CN,pt,it,de,uk,ru,hi,fr_CA"

transifex_utils = ./node_modules/.bin/transifex-utils.js
i18n = ./src/i18n
transifex_input = $(i18n)/transifex_input.json

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

build:
rm -rf ./dist
Expand All @@ -25,36 +16,46 @@ requirements:
test:
npm run test

# i18n targets
i18n_requirements: ## Update package requirements
npm install

i18n.extract:
# Pulling display strings from .jsx files into .json files...
rm -rf $(transifex_temp)
npm run-script i18n_extract
npm run i18n_extract

i18n.concat: ## Merge extracted messages into message files
# Gathering JSON messages into one file...
./src/i18n/i18n-concat.js ./temp/messages.json ./src/i18n/transifex_input.json
cp ./src/i18n/transifex_input.json ./src/i18n/messages/en.json

i18n.pre_validate: | i18n.extract i18n.concat ## Extract messages for translation and test if that produced changes
git diff --exit-code ./src/i18n/transifex_input.json

i18n.concat:
# Gathering JSON messages into one file...
$(transifex_utils) $(transifex_temp) $(transifex_input)
i18n_translations_extract:
docker-compose exec -u node ${EXEC_FLAGS} ${TRANSIFEX_RESOURCE} sh -c "make i18n.extract"

extract_translations: | requirements i18n.extract i18n.concat
extract_translations: | i18n_requirements i18n.extract i18n.concat ## Extract messages for translation and merge them into message files

# 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)
git diff --exit-code ./src/i18n

# Pushes translations to Transifex. You must run make extract_translations first.
push_translations:
# Pushing strings to Transifex...
push_translations: | i18n.extract ## Extract messages for translation and push them 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
# Adding translator comments...
# Fetching strings from Transifex...
bash ./src/i18n/scripts/get_hashed_strings.sh
# Writing out comments to file...
./src/i18n/i18n-concat.js ./temp/messages.json --comments
# Adding comments to Transifex...
bash ./src/i18n/scripts/put_comments.sh

# Pulls translations from Transifex.
pull_translations:
tx pull -t -f --mode reviewed --languages=$(transifex_langs)
tx pull -t -f --mode reviewed --languages="es_419"
cp ./src/i18n/messages/es_419.json ./src/i18n/messages/es.json

# This target is used by Travis.
validate-no-uncommitted-package-lock-changes:
Expand Down

0 comments on commit dff7378

Please sign in to comment.