Skip to content

fix(build): repair yarn build:translations + stop pre-commit hook swallowing its failure - #2923

Open
piyalbasu wants to merge 1 commit into
masterfrom
fix/translations-build
Open

fix(build): repair yarn build:translations + stop pre-commit hook swallowing its failure#2923
piyalbasu wants to merge 1 commit into
masterfrom
fix/translations-build

Conversation

@piyalbasu

Copy link
Copy Markdown
Contributor

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.jsyarn build:translations failed at config load:

[webpack-cli] ✖ TypeError: I18nextWebpackPlugin is not a constructor
    at prodConfig (extension/webpack.extension.js:76:13)
    at module.exports (extension/webpack.extension.js:126:16)

i18next-scanner-webpack@1.0.0 ships transpiled ESM and exports the plugin on .default, so the CommonJS require yields { __esModule: true, default: [Function] } — not a constructor:

> Object.keys(require("i18next-scanner-webpack"))
[ '__esModule', 'default' ]

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 add ran regardless, and the hook exited 0. Added set -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: true is 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 localeCompare orderings the parser enforces via sort: true; the drift accumulated while the hook was silent.

Verification:

  • yarn build:extension:translations completes — 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).
  • Both catalogs parse as JSON; 842 keys in en, 842 in pt, 0 missing in pt — identical counts before and after, so no key was added, removed, or renamed.
  • Re-running the build after the fix is idempotent (no further diff).
  • npx prettier --check clean on all three changed files; sh -n .husky/addTranslations.sh clean.

Out of scope: the plugin version itself is not bumped — the .default unwrap is the minimal fix and works with the currently locked version. Worth a look at whether i18next-scanner-webpack is still maintained, separately.

🤖 Generated with Claude Code

…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>
Copilot AI review requested due to automatic review settings July 29, 2026 18:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown
Contributor

PR Preview build is ready: https://github.com/stellar/freighter/releases/tag/untagged-2b5d42cc6f06a12312be (SDF collaborators only — install instructions in the release description)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants