-
Notifications
You must be signed in to change notification settings - Fork 713
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn in context translation into a plugin.
Make it unsafe-inline compliant.
- Loading branch information
Showing
8 changed files
with
51 additions
and
26 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
Empty file.
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,31 @@ | ||
from django.templatetags.static import static | ||
from django.utils.safestring import mark_safe | ||
|
||
from kolibri.core.hooks import FrontEndBaseHeadHook | ||
from kolibri.plugins import KolibriPluginBase | ||
from kolibri.plugins.hooks import register_hook | ||
|
||
|
||
class ContextTranslationPlugin(KolibriPluginBase): | ||
""" | ||
A plugin to enable support for translating the user interface of Kolibri | ||
using Crowdin's in-context translation feature. | ||
""" | ||
|
||
kolibri_option_defaults = "option_defaults" | ||
django_settings = "settings" | ||
|
||
|
||
@register_hook | ||
class JIPTHeadHook(FrontEndBaseHeadHook): | ||
@property | ||
def head_html(self): | ||
js_url = static("assets/context_translation/jipt.js") | ||
return mark_safe( | ||
"\n".join( | ||
[ | ||
f"""<script type="text/javascript" src="{js_url}"></script>""", | ||
"""<script type="text/javascript" src="//cdn.crowdin.com/jipt/jipt.js"></script>""", | ||
] | ||
) | ||
) |
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,5 @@ | ||
option_defaults = { | ||
"Deployment": { | ||
"LANGUAGES": "ach-ug", | ||
} | ||
} |
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,12 @@ | ||
from django.conf import locale | ||
|
||
ACH_LANG_INFO = { | ||
"ach-ug": { | ||
"bidi": False, | ||
"code": "ach-ug", | ||
"name": "In-context translation", | ||
"name_local": "Language Name", | ||
} | ||
} | ||
|
||
locale.LANG_INFO.update(ACH_LANG_INFO) |
2 changes: 2 additions & 0 deletions
2
kolibri/plugins/context_translation/static/assets/context_translation/jipt.js
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,2 @@ | ||
var _jipt = []; | ||
_jipt.push(['project', 'kolibri']); |