Skip to content

Commit 24d4c72

Browse files
fix: output flat KV format for Transifex translation extraction (#4177)
* feat: use custom formatter to output flat KV format for Transifex Replaces --format transifex (which outputs nested objects) with a small custom formatter that produces the flat {id: defaultMessage} format used by all other frontend repos in openedx-translations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: remove i18n_compile script This was part of the legacy tx CLI pull_translations workflow and is no longer needed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: remove legacy tx CLI translation targets from Makefile Removes push_translations, pull_translations, and detect_changed_source_translations along with their associated variables. These were part of the old Transifex CLI workflow which has been superseded by openedx-translations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: remove .tx Transifex CLI config No longer needed now that the tx CLI workflow has been removed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1b8b621 commit 24d4c72

File tree

4 files changed

+4
-31
lines changed

4 files changed

+4
-31
lines changed

.tx/config

Lines changed: 0 additions & 8 deletions
This file was deleted.

Makefile

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ build:
1313
rm -rf dist/setupTest.js
1414
./bin/paragon-scripts.js build-scss
1515

16-
export TRANSIFEX_RESOURCE = paragon
17-
transifex_langs = "ar,ca,es_419,fr,he,id,ko_KR,pl,pt_BR,ru,th,uk,zh_CN,es_AR,es_ES,pt_PT,tr_TR,it_IT"
18-
i18n = ./src/i18n
19-
transifex_input = $(i18n)/transifex_input.json
20-
2116
NPM_TESTS=build i18n_extract lint test
2217

2318
.PHONY: test
@@ -58,22 +53,6 @@ i18n.extract:
5853

5954
extract_translations: | requirements i18n.extract
6055

61-
# Despite the name, we actually need this target to detect changes in the incoming translated message files as well.
62-
detect_changed_source_translations:
63-
# Checking for changed translations...
64-
git diff --exit-code $(i18n)
65-
66-
# Pushes translations to Transifex. You must run make extract_translations first.
67-
push_translations:
68-
# Pushing strings to Transifex...
69-
tx push -s
70-
71-
# Pulls translations from Transifex.
72-
pull_translations: | requirements
73-
tx pull -t -f --mode reviewed --languages=$(transifex_langs)
74-
# compile files with translated strings to KEYVALUEJSON format which react-intl understands...
75-
npm run-script i18n_compile
76-
7756
# This target is used by Travis.
7857
validate-no-uncommitted-package-lock-changes:
7958
# Checking for package-lock.json changes...

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545
"example:start": "npm start --workspace=example",
4646
"example:start:with-theme": "npm run start:with-theme --workspace=example",
4747
"generate-changelog": "node generate-changelog.js",
48-
"i18n_compile": "formatjs compile-folder --format transifex ./src/i18n/messages ./src/i18n/messages",
49-
"i18n_extract": "formatjs extract 'src/**/*.{jsx,js,tsx,ts}' --out-file ./src/i18n/transifex_input.json --ignore='**/*.d.ts' --format transifex",
48+
"i18n_extract": "formatjs extract 'src/**/*.{jsx,js,tsx,ts}' --out-file ./src/i18n/transifex_input.json --ignore='**/*.d.ts' --format ./src/i18n/transifex-formatter.js",
5049
"type-check": "tsc --noEmit && tsc --project www --noEmit",
5150
"type-check:watch": "npm run type-check -- --watch",
5251
"build-types": "tsc --emitDeclarationOnly",

src/i18n/transifex-formatter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
exports.format = (messages) => Object.fromEntries(
2+
Object.entries(messages).map(([id, { defaultMessage }]) => [id, defaultMessage])
3+
);

0 commit comments

Comments
 (0)