diff --git a/ihatemoney/utils.py b/ihatemoney/utils.py index 491eaf077..554d0eecc 100644 --- a/ihatemoney/utils.py +++ b/ihatemoney/utils.py @@ -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 != "admin@example.com" 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, ) diff --git a/ihatemoney/web.py b/ihatemoney/web.py index 9417ace57..527c24448 100644 --- a/ihatemoney/web.py +++ b/ihatemoney/web.py @@ -336,8 +336,10 @@ def create_project(): # Display the error as a simple "info" alert, because it's # not critical and doesn't prevent using the project. flash_email_error( - "We tried to send you an reminder email, but there was an error. " - "You can still use the project normally.", + _( + "We tried to send you an reminder email, but there was an error. " + "You can still use the project normally." + ), category="info", ) return redirect(url_for(".list_bills", project_id=project.id)) @@ -363,8 +365,10 @@ def remind_password(): return redirect(url_for(".password_reminder_sent")) else: flash_email_error( - "Sorry, there was an error while sending you an email with " - "password reset instructions." + _( + "Sorry, there was an error while sending you an email with " + "password reset instructions." + ) ) # Fall-through: we stay on the same page and display the form again return render_template("password_reminder.html", form=form) @@ -469,7 +473,9 @@ def import_project(): b["currency"] = g.project.default_currency for a in attr: if a not in b: - raise ValueError(_("Missing attribute {}").format(a)) + raise ValueError( + _("Missing attribute: %(attribute)s", attribute=a) + ) currencies.add(b["currency"]) # Additional checks if project has no default currency @@ -586,7 +592,7 @@ def invite(): # send the email message_body = render_localized_template("invitation_mail") message_title = _( - "You have been invited to share your " "expenses for %(project)s", + "You have been invited to share your expenses for %(project)s", project=g.project.name, ) msg = Message( @@ -600,7 +606,9 @@ def invite(): return redirect(url_for(".list_bills")) else: flash_email_error( - "Sorry, there was an error while trying to send the invitation emails." + _( + "Sorry, there was an error while trying to send the invitation emails." + ) ) # Fall-through: we stay on the same page and display the form again @@ -797,7 +805,10 @@ def change_lang(lang): session["lang"] = lang session.update() else: - flash(_(f"{lang} is not a supported language"), category="warning") + flash( + _("%(lang)s is not a supported language", lang=lang), + category="warning", + ) return redirect(request.headers.get("Referer") or url_for(".home"))