fix(build): repair yarn build:translations + stop pre-commit hook swallowing its failure - #2923
Open
piyalbasu wants to merge 1 commit into
Open
fix(build): repair yarn build:translations + stop pre-commit hook swallowing its failure#2923piyalbasu wants to merge 1 commit into
piyalbasu wants to merge 1 commit into
Conversation
…llowing its failure
`yarn build:translations` has been failing at webpack config load:
[webpack-cli] ✖ TypeError: I18nextWebpackPlugin is not a constructor
at prodConfig (extension/webpack.extension.js:76:13)
i18next-scanner-webpack@1.0.0 ships transpiled ESM and exports the plugin
on `.default`, so the CommonJS `require` returns
`{ __esModule: true, default: [Function] }` rather than the constructor.
Unwrap `.default` with a plain-export fallback.
This was invisible because `.husky/addTranslations.sh` had no `set -e`: the
build failed, `git add extension/src/popup/locales/` ran anyway, and the
hook exited 0. Every commit since the version drift has silently skipped
catalog generation, so the documented locale workflow in
extension/LOCALIZATION.MD was a no-op and hand-edited catalogs went
unchecked. Added `set -e`.
The catalog changes here are the now-working build's own output: two
sort-order corrections per locale ("This token already has a trustline
added." after "This site was flagged as suspicious", "Token address"
after "Token") that accumulated while the hook was mute. No keys added or
removed — 842/842 en/pt parity before and after.
Verified: `yarn build:extension:translations` completes ("i18next-scanner:
done."), both catalogs parse, 0 keys missing in pt, prettier clean.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Repairs translation catalog generation and ensures pre-commit failures propagate correctly.
Changes:
- Unwraps the scanner plugin’s CommonJS default export.
- Makes catalog generation fail fast.
- Applies generated key-order corrections.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
extension/webpack.extension.js |
Fixes plugin construction. |
.husky/addTranslations.sh |
Enables fail-fast hook behavior. |
extension/src/popup/locales/en/translation.json |
Corrects generated key ordering. |
extension/src/popup/locales/pt/translation.json |
Corrects generated key ordering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
PR Preview build is ready: https://github.com/stellar/freighter/releases/tag/untagged-2b5d42cc6f06a12312be (SDF collaborators only — install instructions in the release description) |
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.
TL;DR
The command that regenerates our translation files has been broken, and the pre-commit hook that runs it has been hiding the failure and reporting success. So for however long the breakage has existed, translation catalogs have not actually been regenerated on commit — the documented localization workflow has been a no-op, and hand-edited catalogs went unchecked.
This fixes both: the command works again, and the hook now fails loudly instead of pretending it passed. Also included are the two small ordering corrections the now-working command produces on its first real run — leftover drift from the silent period. No copy changes, no strings added or removed, nothing user-visible.
Found while addressing review feedback on #2922, where a reviewer asked me to run the translation build and it wouldn't run.
Implementation details (for agents)
What changed:
extension/webpack.extension.js—yarn build:translationsfailed at config load:i18next-scanner-webpack@1.0.0ships transpiled ESM and exports the plugin on.default, so the CommonJSrequireyields{ __esModule: true, default: [Function] }— not a constructor:Unwrapped with a plain-export fallback (
.default || module) so it survives a future non-ESM republish..husky/addTranslations.sh— the reason nobody noticed. The script was:#!/bin/sh yarn build:extension:translations git add extension/src/popup/locales/No
set -e, so the failing build's non-zero exit was discarded,git addran regardless, and the hook exited 0. Addedset -e.This is the mechanism by which the out-of-sort keys in #2922 reached a commit: the hook is supposed to catch exactly that (
sort: trueis set on the parser) and it was mute.Catalog changes: the now-working build's own output, not hand edits. Two sort-order corrections per locale:
"This token already has a trustline added."now follows"This site was flagged as suspicious""Token address"now follows"Token"Both are
localeCompareorderings the parser enforces viasort: true; the drift accumulated while the hook was silent.Verification:
yarn build:extension:translationscompletes —i18next-scanner: done., webpack compiled, exit 0. Confirmed both standalone and via the pre-commit hook path (the hook ran it successfully while committing this change).en, 842 inpt, 0 missing inpt— identical counts before and after, so no key was added, removed, or renamed.npx prettier --checkclean on all three changed files;sh -n .husky/addTranslations.shclean.Out of scope: the plugin version itself is not bumped — the
.defaultunwrap is the minimal fix and works with the currently locked version. Worth a look at whetheri18next-scanner-webpackis still maintained, separately.🤖 Generated with Claude Code