Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a regex pattern for detecting unnamed percentage format specifiers in localization utility code. The change corrects the regex pattern that was overly complex and potentially incorrect.
- Simplifies the
RE_UNNAMED_PERCENTregex pattern to properly match unnamed format specifiers - Updates the comment to clarify what patterns are matched
|
Do you plan to rewrite other translatable strings, i.e. all strings containing |
|
In the short term, I want to fix a key few (about 5 strings) where translators have not used |
SaschaCowley
left a comment
There was a problem hiding this comment.
Clarifications for translators
Co-authored-by: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com>
Link to issue number:
Fixup of #18503 and #18270
Summary of the issue:
The regex to check for unnamed string interpolations doesn't support the %% symbol, which escapes %.
This leads to certain usages of it raising incorrect interpolation errors.
The regex for missing names for brace interpolations is not working.
i.e.
"{}"should raise an error without a name like"{name}".This causes issues where the order of the arguments change in the string.
e.g. "Character: {}\nReplacement: {}" being translated to "Replacement: {}\nCharacter: {}" will result in the expected interpolation being in the wrong place.
These should be fixed in the source .po files to add names to instances of "{}".
Description of user facing changes:
Adds a more rigourous check for interpolations using brace formats, which will reduce string errors in the UI.
Description of developer facing changes:
None
Description of development approach:
Testing strategy:
Added unit tests for recognizing interpolations
Tested running
pre-commit run checkPo --all-files.Known issues with pull request:
{}interpolations{}to missing translated strings (or match newly fixed source strings).Code Review Checklist:
@coderabbitai summary