Fix unreplaced placeholders in console messages#123
Open
JumpLink wants to merge 1 commit into
Open
Conversation
The labels module dispatched messages with three inconsistent
placeholder styles ($d, {label}, and %s/%d in swapped order), so
"Found $d labels." was shown literally on every platform (#118).
- Core: unify all message placeholders to printf-style %s/%d and
fix the swapped params order in "Label already defined at line"
- Core: add formatMessage() utility for platforms without their
own gettext formatting
- Web: substitute message params via formatMessage()
- Android: translate and format console messages via localize()
- Translations: migrate msgids/msgstrs to the corrected
placeholders, preserving all existing translations
Fixes #118
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.
Fixes #118
Problem
The message console showed
Found $d labels.with a literal$din every language. The labels module dispatched messages with three inconsistent placeholder styles:Found $d labels.$d$dLabel already defined at line %s: %d%s/%dswapped%s, line content as%d(→NaN)Label {label} is already used as a symbol…{label}On top of that, only the GNOME app formatted params at all (via gettext + GJS
String.format); the Web and Android apps logged the raw message, so even%dplaceholders were never substituted there.Fix
%s/%d(the style every other core message already uses) and fix the swapped specifier order in the "Label already defined" message.formatMessage()utility.formatMessage()in all console log handlers.localize()from@nativescript/localize(which substitutes printf-style params viavsprintf), with a safe fallback to the raw message. Console messages were previously shown untranslated.String.formathandles%s/%dcorrectly once the msgids are fixed..pofiles and the.pot, preserving every existing translation. The German.pohad already worked around the bug with%din its msgstrs; that was kept intact. Android i18n JSONs and the.potwere regenerated withyarn workspace @learn6502/translations run build.Verification
formatMessage()checked against all affected messages (singular/plural count, line-number+content, label name,%%escape, no-params passthrough)."Found %d labels.".format(5)→Found 5 labels..poentries validated by script (each msgstr contains exactly the placeholders of its msgid).yarn format,yarn check:format,yarn buildpass; type checks pass for6502,common-ui,app-web,app-android.