fix(cli): po loader push performance, multi-entry sections, pseudo mode crash#2064
Conversation
📝 WalkthroughWalkthroughThis PR delivers a patch release for lingo.dev that addresses PO loader push performance, fixes multi-entry section handling, and resolves a pseudo mode crash. Changes include optimizations to the push operation, a new test case validating multi-entry translations, and an addition to the pseudo localizer's interface. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/cli/src/cli/loaders/po/index.ts (1)
66-86: Verify the section-matching logic for header-only sections.Inside the
if (!msgid)block,msgidisundefined. Line 83 comparescsMsgid === msgid, which effectively checkscsMsgid === undefined. This appears intentional for matching header-only sections, but the logic could be clearer.Consider adding a comment to clarify the intent:
const csMsgid = Object.keys(csEntries).find( (key) => csEntries[key].msgid, ); + // Match sections that both lack a real msgid (header-only sections) return csMsgid === msgid;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/cli/loaders/po/index.ts` around lines 66 - 86, The matching branch using if (!msgid) currently compares csMsgid === msgid (i.e., === undefined) to detect header-only sections; update the block around currentSections/currentSection to make the intent explicit by either changing the comparison to check for absence of csMsgid (e.g., csMsgid == null) or adding a clear inline comment explaining that csMsgid === undefined is intentionally used to match header-only PO sections, referencing msgid, csPo, csContextKey, csEntries and csMsgid so future readers understand this special-case logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/cli/src/cli/loaders/po/index.ts`:
- Around line 66-86: The matching branch using if (!msgid) currently compares
csMsgid === msgid (i.e., === undefined) to detect header-only sections; update
the block around currentSections/currentSection to make the intent explicit by
either changing the comparison to check for absence of csMsgid (e.g., csMsgid ==
null) or adding a clear inline comment explaining that csMsgid === undefined is
intentionally used to match header-only PO sections, referencing msgid, csPo,
csContextKey, csEntries and csMsgid so future readers understand this
special-case logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a7f9564e-aba7-42b0-bb91-345613734c81
📒 Files selected for processing (4)
.changeset/light-shrimps-hear.mdpackages/cli/src/cli/loaders/po/index.spec.tspackages/cli/src/cli/loaders/po/index.tspackages/cli/src/cli/localizer/pseudo.ts
Summary
Fix PO loader push crashing on large files, missing entries in multi-entry sections, and pseudo mode crash due to missing
validateSettings.Changes
pushparsing the entire target file for every sectionpushonly translating the first entry when multiple entries share a section without blank lines between themvalidateSettingsto pseudo localizer so--pseudomode no longer crashesTesting
Business logic tests added:
Visuals
N/A - no UI changes
Checklist
Summary by CodeRabbit