-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow user set language preference
- Loading branch information
Showing
7 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
eox_tenant/edxapp_wrapper/backends/lang_pref_middleware_p_test_v1.py
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
""" | ||
LanguagePreferenceMiddleware Backend for testing. | ||
""" | ||
from unittest.mock import MagicMock | ||
|
||
def get_language_preference_middleware(): | ||
"""Backend to mock the LanguagePreferenceMiddleware for testing.""" | ||
return MagicMock() |
9 changes: 9 additions & 0 deletions
9
eox_tenant/edxapp_wrapper/backends/lang_pref_middleware_p_v1.py
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
""" | ||
LanguagePreferenceMiddleware Backend. | ||
""" | ||
from openedx.core.djangoapps.lang_pref.middleware import LanguagePreferenceMiddleware # pylint: disable=import-error | ||
|
||
|
||
def get_language_preference_middleware(): | ||
"""Backend to get the LanguagePreferenceMiddleware from openedx.""" | ||
return LanguagePreferenceMiddleware |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
""" Backend abstraction. """ | ||
from importlib import import_module | ||
|
||
from django.conf import settings | ||
|
||
|
||
def get_language_preference_middleware(*args, **kwargs): | ||
""" Get DarkLangMiddleware. """ | ||
backend_function = settings.LANGUAGE_PREFERENCE_MIDDLEWARE | ||
backend = import_module(backend_function) | ||
return backend.get_language_preference_middleware(*args, **kwargs) |
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
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
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
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