New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run string formatting after gettext() call #6368
Conversation
Don't interpolate parameters before looking up the string in gettext, otherwise it won't find anything and fallback to English. Fixes #6367.
Codecov Report
@@ Coverage Diff @@
## develop #6368 +/- ##
========================================
Coverage 83.98% 83.98%
========================================
Files 61 61
Lines 4301 4301
Branches 522 522
========================================
Hits 3612 3612
Misses 565 565
Partials 124 124
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM based on visual review and testing in make dev
.
@@ -46,11 +46,11 @@ <h2 id="submit-heading" class="headline">{{ gettext('Submit Messages') }}</h2> | |||
{{ form.msg(class="fill-parent") }} | |||
{% if allow_document_uploads %} | |||
{% if min_len > 0 %} | |||
<p class="center" id="min-msg-length">{{ gettext('If you are only sending a message, it must be at least {} characters long.'.format(min_len)) }}</p> | |||
<p class="center" id="min-msg-length">{{ gettext('If you are only sending a message, it must be at least {} characters long.').format(min_len) }}</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing: this case did not work correctly, but that's due to this string not being collected for translation, the code change is valid.
@@ -204,7 +204,7 @@ def submit(logged_in_source: SourceUser) -> werkzeug.Response: | |||
min_len = InstanceConfig.get_default().initial_message_min_len | |||
if (min_len > 0) and (msg and not fh) and (len(msg) < min_len): | |||
flash(gettext( | |||
"Your first message must be at least {} characters long.".format(min_len)), | |||
"Your first message must be at least {} characters long.").format(min_len), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testing - confirmed that this case works correctly when rebased onto the i18n-merge
branch.
{% endif %} | ||
{% else %} | ||
{% if min_len > 0 %} | ||
<p class="center" id="min-msg-length">{{ gettext('Your first message must be at least {} characters long.'.format(min_len)) }}</p> | ||
<p class="center" id="min-msg-length">{{ gettext('Your first message must be at least {} characters long.').format(min_len) }}</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing: this case works correctly (with min-length set and document uploads disabled).
Status
Ready for review
Description of Changes
Don't interpolate parameters before looking up the string in gettext,
otherwise it won't find anything and fallback to English.
Fixes #6367.
Testing
{}
appear in the error message when inputting too short of a message, and the correct character count is shown.Deployment
Any special considerations for deployment? No.
Checklist
make lint
) and tests (make test
) pass in the development container