forked from spiral-project/ihatemoney
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
F-strings are a bad idea for translations, because they cause Babel to crash when collecting strings to translate: python-babel/babel#715 But even if we replaced f-strings with new-style string interpolation such as `_("{foo}").format(foo=foo)`, it's still a bad idea, because a wrong translation can crash Ihatemoney at runtime with a KeyError. Instead, we must really use old-style python formatting since they are well supported in Babel. Wrong translations that mess with string interpolations will cause Babel to give an error when compiling translation files, which is exactly what we want.
- Loading branch information
Baptiste Jonglez
committed
Feb 3, 2023
1 parent
35013ef
commit d5639f1
Showing
2 changed files
with
27 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,15 +64,19 @@ def flash_email_error(error_message, category="danger"): | |
(admin_name, admin_email) = email.utils.parseaddr( | ||
current_app.config.get("MAIL_DEFAULT_SENDER") | ||
) | ||
error_extension = "." | ||
error_extension = _("Please check the email configuration of the server.") | ||
if admin_email != "[email protected]" and current_app.config.get( | ||
"SHOW_ADMIN_EMAIL" | ||
): | ||
error_extension = f" or contact the administrator at {admin_email}." | ||
error_extension = _( | ||
"Please check the email configuration of the server " | ||
"or contact the administrator: %(admin_email)s", | ||
admin_email=admin_email, | ||
) | ||
|
||
flash( | ||
_( | ||
f"{error_message} Please check the email configuration of the server{error_extension}" | ||
"{error_message} {error_extension}".format( | ||
error_message=error_message, error_extension=error_extension | ||
), | ||
category=category, | ||
) | ||
|
This file contains 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