Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
ed9b93ff
Commit
ed9b93ff
authored
Sep 26, 2017
by
Ned Batchelder
Committed by
GitHub
Sep 26, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16100 from edx/nedbat/lazy_format
Have to format lazily for translated constant messages
parents
fb1d6886
f8f911ae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
openedx/core/djangoapps/user_api/accounts/__init__.py
+16
-5
No files found.
openedx/core/djangoapps/user_api/accounts/__init__.py
View file @
ed9b93ff
...
...
@@ -4,6 +4,11 @@ Account constants
from
django.utils.translation
import
ugettext_lazy
as
_
# In Django 1.11, there's django.utils.text.format_lazy.
from
django.utils.functional
import
allow_lazy
format_lazy
=
allow_lazy
(
lambda
s
,
*
a
,
**
kw
:
s
.
format
(
*
a
,
**
kw
),
unicode
)
# The minimum and maximum length for the name ("full name") account field
NAME_MIN_LENGTH
=
2
...
...
@@ -60,15 +65,21 @@ USERNAME_CONFLICT_MSG = _(
# Translators: This message is shown to users who enter a username/email/password
# with an inappropriate length (too short or too long).
USERNAME_BAD_LENGTH_MSG
=
_
(
u"Username must be between {min} and {max} characters long."
)
.
format
(
min
=
USERNAME_MIN_LENGTH
,
max
=
USERNAME_MAX_LENGTH
USERNAME_BAD_LENGTH_MSG
=
format_lazy
(
_
(
u"Username must be between {min} and {max} characters long."
),
min
=
USERNAME_MIN_LENGTH
,
max
=
USERNAME_MAX_LENGTH
,
)
EMAIL_BAD_LENGTH_MSG
=
_
(
u"Enter a valid email address that contains at least {min} characters."
)
.
format
(
min
=
EMAIL_MIN_LENGTH
EMAIL_BAD_LENGTH_MSG
=
format_lazy
(
_
(
u"Enter a valid email address that contains at least {min} characters."
),
min
=
EMAIL_MIN_LENGTH
,
)
PASSWORD_EMPTY_MSG
=
_
(
u"Enter a password."
)
PASSWORD_BAD_MIN_LENGTH_MSG
=
_
(
u"Password is not long enough."
)
PASSWORD_BAD_MAX_LENGTH_MSG
=
_
(
u"Password cannot be longer than {max} character."
)
.
format
(
max
=
PASSWORD_MAX_LENGTH
)
PASSWORD_BAD_MAX_LENGTH_MSG
=
format_lazy
(
_
(
u"Password cannot be longer than {max} character."
),
max
=
PASSWORD_MAX_LENGTH
,
)
# These strings are normally not user-facing.
USERNAME_BAD_TYPE_MSG
=
u"Username must be a string."
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment