Repository navigation
fix(i18n): run localize-translate without cmd.exe and in batches to stay under the Windows command line limit - #186
Open
JohnYoungers wants to merge 2 commits into
Conversation
…alize-translate Run the localize-translate CLI script with node through execFileSync instead of a cmd.exe command string, and split the federation file list over several runs when it gets long. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The i18n builder now resolves @angular/localize from the workspace, which knip reports as an unlisted dependency. Declare it as an optional peer (like @angular/build does) and as a devDependency, and fail with a clear message when it is not installed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Problem
translateFederationArtifactsrunslocalize-translateas one command string throughexecSync, which usescmd.exeon Windows.cmd.exelimits the command line to 8191 characters. The-sargument lists every federation file, so in a workspace with a few hundred federation files the list alone is longer than that, and the build logs:It runs fine on Linux.
node_modules/.bin/localize-translateis a.cmdshim on Windows, so it can only be started throughcmd.exe, even without the long list.This was split out of #172. The missing-chunks part of that PR will follow once core#178 is released.
Change
@angular/localizeCLI script withprocess.execPaththroughexecFileSync, so no shell is involved. The script path is resolved from the workspace's@angular/localize/package.json(bin["localize-translate"]) instead of.bin/localize-translate.localize-translateonce per batch. A batch holds at most 16,000 characters of file names, which keeps the command under the 32,767 characterCreateProcesslimit with room for the other arguments. All batches write into the same staging folder, which is copied into the locale folders after the last run, as before. A failing batch still throws and skips the copy.JSON.stringifyoutput, so the CLI received[a.xlf,b.xlf]for a locale with several translation files. That is the formconvertArraysFromArgsin the CLI expects, so it is now built explicitly as[a,b].The
-slist is unchanged (still built fromshared,exposesandchunks), so there is no behavior change for the translated output.Verification
pnpm typecheckandpnpm lintpass.translateFederationArtifactsunit tests for the argument array, and added one that splits 1000 files over several runs and checks that every file is translated exactly once and that each pattern stays under the limit. On my Windows machine three tests ini18n.spec.tsfail (/vs\in path assertions), identically with and without this change; I could not run the suite on Linux.localize: truebuild with this change applied.Open question
I picked 16,000 characters for the batch size as roughly half of the Windows limit. If you prefer a different threshold, or batching by file count, it is a single constant.