feat: simplify i18n extraction to output flat KV directly#200
Merged
brian-smith-tcril merged 1 commit intoopenedx:mainfrom Mar 25, 2026
Merged
Conversation
Update the formatjs formatter to output flat {key: value} JSON instead
of an array of objects, and write directly to src/i18n/transifex_input.json.
This removes the need for a separate concat step and matches the format
expected by openedx-translations.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
formatter.tsto output flat{"key": "value"}JSON instead of an array of{id, defaultMessage, description}objectsopenedx.tsto write directly tosrc/i18n/transifex_input.json, removing the need for a separate concat stepThis follows the pattern established in openedx/paragon#4177 and unblocks
make extract_translationson frontend-base MFE branches (e.g. frontend-app-authn'sfrontend-basebranch), which don't have access tofrontend-platformorfrontend-build.Verified by installing a local tarball of
frontend-baseinfrontend-app-authn(on itsfrontend-basebranch) and confirmingnpm run i18n_extractsuccessfully writes flat KV tosrc/i18n/transifex_input.json.Test plan
make extract_translationsin an MFE on afrontend-basebranch and verifysrc/i18n/transifex_input.jsonis created in flat KV formatLog
extract-translations work log
Repo:
frontend-app-authn— branchextract-translations(offfrontend-base)Goal: Get
make extract_translationsworking on thefrontend-basebranch, using the pattern established in openedx/paragon#4177.Background
Standard MFEs use a two-step pipeline via
make extract_translations:i18n.extract— runsfedx-scripts formatjs extract(fromfrontend-build), outputs an array of{id, defaultMessage, description}objects to./temp/babel-plugin-formatjs/Default.messages.jsoni18n.concat— runstransifex-utils.js(fromfrontend-platform), reads that array and writes flat KV tosrc/i18n/transifex_input.jsonThe
frontend-basebranch doesn't havefrontend-platformorfrontend-buildavailable, so this pipeline breaks.Pattern (from paragon#4177)
src/i18n/transifex-formatter.js— a small custom formatter that outputs flat KV JSONi18n_extractscript inpackage.jsonto use--format ./src/i18n/transifex-formatter.jsError (current)
make extract_translationsfails at thei18n.concatstep:The
i18n.extractstep runsopenedx formatjs extract(from@openedx/frontend-base's CLI) but doesn't write anything to./temp/babel-plugin-formatjsin the formattransifex-utils.jsexpects, causing the concat step to throw.Investigation findings
i18n_extractinpackage.jsonrunsopenedx formatjs extract(from@openedx/frontend-baseCLI)frontend-base's ownformatter.jsand writes an array of{id, defaultMessage, description}objects to./temp/formatjs/Default.messages.jsoni18n.concatstep passes./temp/babel-plugin-formatjstotransifex-utils.js— that directory never gets created, so it throwsFound no messagesfrontend-build-era path./temp/babel-plugin-formatjs, butfrontend-base's CLI writes to./temp/formatjsThe fix from paragon#4177 sidesteps this entirely — use a custom formatter that outputs flat KV directly, removing the need for the concat step altogether.
Setup done in authn (
extract-translationsbranch)@openedx/frontend-dev-utilsas a dev dependencydev:autoinstallscript:PORT=1999 PUBLIC_PATH=/authn FRONTEND_BASE_DIR=../frontend-base devutils-dev-with-autoinstallpack:watchrunning infrontend-base(simplify-i18n-extractbranch)dev:autoinstallrunning in authn — picks up pack changes fromfrontend-baseautomaticallySteps
make extract_translationsis currently broken (confirmed same error with latest autoinstalledfrontend-base)frontend-base(simplify-i18n-extractbranch): updatedformatter.tsto output flat KV, updatedopenedx.tsto write directly tosrc/i18n/transifex_input.jsoni18n.concatstep, removed unusedtransifex_utils/transifex_temp/transifex_inputvariables, simplifiedextract_translationstargetnpm run i18n_extractwrites flat KV tosrc/i18n/transifex_input.jsonNote on testing
make extract_translationsrunsnpm ci(viarequirements) which reinstalls from the registry, wiping out the local pack. During dev, usenpm run i18n_extractdirectly afterdev:autoinstallhas installed the local pack. The fullmake extract_translationswill work correctly once thefrontend-basechanges are published.🤖 Generated with Claude Code