-
Notifications
You must be signed in to change notification settings - Fork 161
Description
While reviewing the Spanish translations, I noticed multiple strings that contain %(within)s; display the %(within)s in English to the user.
I'll focus just on confirm and reset expired messages, which use two strings from the configuration to obtain the value of %(within)s:
"CONFIRM_EMAIL_WITHIN": "5 days",
"RESET_PASSWORD_WITHIN": "1 days",These strings are used for token max_age and to create flash messages to inform the user. For example, the user will receive a message like:
"You did not reset your password within %(within)s. " where %(within)s will be "5 days" or "1 days"
Notice the incorrect plural for "1 day"
Since "within" isn't translated, users will receive a mix of English and non-English:
"[localized message] 5 days"
Translation of "within" on messages
These two configuration values are used to render the message on flask_security/views.py:597 and to obtain the token max_age (flask_security/utils.py:855).
They could be marked for translation like other config values with _(), and kept non-localized. They can also be translated before calling get_message.
This will work for the default values, but not for custom application values, so it's not ideal.
For the pluralization error
The configuration values ending with _WITHIN are used to generate a timedelta (which expects the arguments days, seconds, microseconds, milliseconds, minutes, hours, and weeks), see utils.get_within_delta.
I don't think milliseconds and microseconds will ever be used, but right now they are supported
Thus, singular cannot be used to specify _WITHIN values.
Conclusion
To translate these periods properly, a solution like naturaldelta from humanize package would be needed.
Another option will be to remove the delta time from the messages and use a default like:
"You did not reset your password within the allowed time."
Both are breaking changes adding a new dependency (unless naturaldelta is borrowed) or removing a placeholder from a configuration string.
What do you think would be the best solution?
BTW: sorry for the long description