PD-5781 Fix peer review i18n in print view - #2888
Open
cryptalith wants to merge 1 commit into
Open
Conversation
The peer review heading is the only print-view string with placeholders,
and it rendered truncated in every locale ("Revisión por pares ($") with
both counts missing and no build diagnostic.
normalize-xlf parses $localize calls out of fetch-orcid.js, since the file
is a plain asset that ng extract-i18n never sees. Its placeholder converter
only matched UPPERCASE names, but the source uses camelCase, so the raw
`${reviewsCount}:reviewCount:` text was written verbatim into the XLF.
Fixing the name pattern alone is not enough: Xliff1TranslationParser only
recognises real <x id="..."/> elements, so the `{$NAME}` text form that
converter aimed for parses as literal content, leaves the message with zero
placeholders and truncates the translation at the first `$`. Emit proper
XLIFF placeholder elements instead, carried through the xml2js Builder as
sentinels because it escapes markup found in a text node.
printView.* units are now always regenerated from fetch-orcid.js rather than
only added when absent, so re-parsing a unit that already holds <x/> cannot
degrade it, and add a build-time check that fails on leftover legacy syntax
and warns when a target drops a placeholder.
Locale targets are converted in place, preserving the reordering translators
applied in tr and zh-TW.
Member
|
Task linked: PD-5781 Fix Peer Review i18n in Print View |
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.
PD-5781
Problem
The peer review heading is the only print-view string with placeholders, and it was broken in every locale — not falling back to English, but rendering truncated with both counts gone:
Revisión por pares ($Revisión por pares (7 revisiones de 3 publicaciones/concesiones)@angular/localizeemitted no diagnostic, so this shipped silently.Root cause
fetch-orcid.jsis a plain asset, song extract-i18nnever sees it.normalize-xlf.prebuild.tsparses the$localizecalls out of the file instead, and its placeholder converter only matched UPPERCASE names:The source uses camelCase (
:reviewCount:), so nothing matched and the raw${reviewsCount}:reviewCount:text went verbatim into the XLF.Fixing the name pattern alone would not have worked.
Xliff1TranslationParseronly recognises real<x id="..."/>elements, so the{$NAME}text form that converter aimed for parses as literal content, leaves the message with zero placeholders, and truncates the translation at the first$.Changes
<x id="..."/>placeholder elements. These are carried through the xml2jsBuilderas sentinels, since it escapes any markup found in a text node; the sentinels never reach disk.printView.*units fromfetch-orcid.jsinstead of only adding them when absent, so re-parsing a unit that already holds<x/>cannot degrade it. Verified idempotent across repeated runs.trandzh-TW.<x/>is the standard XLIFF 1.2 form Angular already emits elsewhere, and Transifex already round-trips it here — 7 translated targets per locale contain it today. The previous raw-text form was the outlier.Verification
makeEs2015TranslatePluginpass;uk/cacorrectly fall back to English.messages.xlfis a one-line change — the usual regeneration churn was kept out.Follow-ups (not in this PR)
<x/>form; the new check fails the build if a pull brings the old syntax back.writeXlf's xml2js round-trip does not preserve mixed content, so the ~32 Angular-extracted units inmessages.xlfhave their<x/>elements moved to the end of each source on every build. Confirmed independent of this change (the unmodified script frommainreproduces it). Tracked separately.