Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
41b25fec
Commit
41b25fec
authored
10 years ago
by
Sarina Canelake
Browse files
Options
Downloads
Patches
Plain Diff
Ensure system language is released in dark lang middleware
LMS-2644
parent
5cef9f7a
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/djangoapps/dark_lang/middleware.py
+6
-1
6 additions, 1 deletion
common/djangoapps/dark_lang/middleware.py
common/djangoapps/dark_lang/tests.py
+6
-0
6 additions, 0 deletions
common/djangoapps/dark_lang/tests.py
with
12 additions
and
1 deletion
common/djangoapps/dark_lang/middleware.py
+
6
−
1
View file @
41b25fec
...
...
@@ -10,6 +10,7 @@ in the user's session.
This middleware must be placed before the LocaleMiddleware, but after
the SessionMiddleware.
"""
from
django.conf
import
settings
from
django.utils.translation.trans_real
import
parse_accept_lang_header
...
...
@@ -33,6 +34,7 @@ def dark_parse_accept_lang_header(accept):
for
lang
,
priority
in
browser_langs
:
lang
=
CHINESE_LANGUAGE_CODE_MAP
.
get
(
lang
.
lower
(),
lang
)
django_langs
.
append
((
lang
,
priority
))
return
django_langs
# If django 1.7 or higher is used, the right-side can be updated with new-style codes.
...
...
@@ -65,7 +67,10 @@ class DarkLangMiddleware(object):
"""
Current list of released languages
"""
return
DarkLangConfig
.
current
().
released_languages_list
language_options
=
DarkLangConfig
.
current
().
released_languages_list
if
settings
.
LANGUAGE_CODE
not
in
language_options
:
language_options
.
append
(
settings
.
LANGUAGE_CODE
)
return
language_options
def
process_request
(
self
,
request
):
"""
...
...
This diff is collapsed.
Click to expand it.
common/djangoapps/dark_lang/tests.py
+
6
−
0
View file @
41b25fec
...
...
@@ -93,6 +93,12 @@ class DarkLangMiddlewareTests(TestCase):
self
.
process_request
(
accept
=
'
rel;q=1.0, unrel;q=0.5
'
)
)
def
test_accept_with_syslang
(
self
):
self
.
assertAcceptEquals
(
'
en;q=1.0, rel;q=0.8
'
,
self
.
process_request
(
accept
=
'
en;q=1.0, rel;q=0.8, unrel;q=0.5
'
)
)
def
test_accept_multiple_released_langs
(
self
):
DarkLangConfig
(
released_languages
=
(
'
rel, unrel
'
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment