Skip to content

fix: add comma flag to printf regex to correctly highlight placeholder#4049

Merged
mathjazz merged 1 commit intomozilla:mainfrom
wassafshahzad:wassaf/4039-fix-printf-comma-placeholder
Mar 31, 2026
Merged

fix: add comma flag to printf regex to correctly highlight placeholder#4049
mathjazz merged 1 commit intomozilla:mainfrom
wassafshahzad:wassaf/4039-fix-printf-comma-placeholder

Conversation

@wassafshahzad
Copy link
Copy Markdown
Contributor

Description

The printf placeholder regex in Pontoon's translation editor did not include the , (comma) flag in its format specifier pattern. This caused placeholders like %2$,d, a valid Java/Android printf format that renders integers with thousands separators (e.g. 1,000), to go un-highlighted in the translate view, making them invisible to translators who need to preserve them in their translations.

The fix adds , to the flags character class in the printf regex in both placeholder.ts (used for highlighting) and editFieldModes.ts (used for editor syntax),bringing them in sync and ensuring %2$,d is correctly identified and highlighted alongside other placeholders.

Closes

Fixes #4039

Screenshots

Screenshot 2026-03-29 205402

Copy link
Copy Markdown
Collaborator

@mathjazz mathjazz left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for the fix!

@mathjazz mathjazz merged commit 97992d5 into mozilla:main Mar 31, 2026
6 checks passed
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$,d placeholder is incorrectly highlighted in translate view

2 participants