Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make site title configurable via the theme hook. #11433

Merged
merged 2 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kolibri/core/templates/kolibri/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="google" content="notranslate">
{% theme_favicon %}
<title>{% trans "Kolibri" %}</title>
<title>{% site_title %}</title>
{% if LANGUAGE_CODE == "ach-ug" %}
<script type="text/javascript">
var _jipt = [];
Expand Down
2 changes: 1 addition & 1 deletion kolibri/core/templates/kolibri/unsupported_browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="google" content="notranslate">
{% theme_favicon %}
<title>{% trans "Kolibri" %}</title>
<title>{% site_title %}</title>
<style>
body {
margin: 0;
Expand Down
10 changes: 10 additions & 0 deletions kolibri/core/templatetags/core_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from kolibri.core.hooks import FrontEndBaseHeadHook
from kolibri.core.hooks import FrontEndBaseSyncHook
from kolibri.core.theme_hook import ThemeHook
from kolibri.utils.translation import ugettext as _

register = template.Library()

Expand Down Expand Up @@ -71,3 +72,12 @@ def theme_favicon():
favicon_url = favicon_urls[0] if favicon_urls else static("assets/logo.ico")

return format_html('<link rel="shortcut icon" href="{}">', favicon_url)


@register.simple_tag()
def site_title():
"""
Return the text of the site title, if provided by the theme. If not, the
default will be returned.
rtibbles marked this conversation as resolved.
Show resolved Hide resolved
"""
return ThemeHook.get_theme().get("siteTitle", _("Kolibri"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My translation knowledge is shaky at best, but does this support translation of the title in the theme?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand things, yes, the theme should support translation. The theme is just a Django plugin with a hook which returns a dict of values. It should be able to call _() on the value it returns for siteTitle.

(That would mean we need to set up gettext support for kolibri-endless-key-theme, but that’s fairly straightforward.)

4 changes: 2 additions & 2 deletions kolibri/plugins/pwa/templates/pwa/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
{% get_current_language_bidi as LANGUAGE_BIDI %}
{% get_current_language as LANGUAGE_CODE %}
{
"name": "{% trans 'Kolibri'|escapejs %}",
"short_name": "{% trans 'Kolibri'|escapejs %}",
"name": "{% site_title|escapejs %}",
"short_name": "{% site_title|escapejs %}",
"dir": "{{ LANGUAGE_BIDI|yesno:'rtl,ltr'|escapejs }}",
"lang": "{{ LANGUAGE_CODE|escapejs }}",
"icons": [
Expand Down