1
0
Fork 0
mirror of https://github.com/Kunsi/pretalx-plugin-broadcast-tools synced 2024-11-22 07:51:01 +00:00

Add i18n support

This commit is contained in:
Tobias Kunze 2021-11-21 13:07:19 +01:00
parent 7107150736
commit 07474c6976
3 changed files with 20 additions and 10 deletions

View file

@ -1,23 +1,21 @@
from django import forms
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from hierarkey.forms import HierarkeyForm from hierarkey.forms import HierarkeyForm
from i18nfield.forms import I18nFormField, I18nFormMixin, I18nTextInput
class LowerThirdsSettingsForm(HierarkeyForm): class LowerThirdsSettingsForm(I18nFormMixin, HierarkeyForm):
lower_thirds_no_talk_info = forms.CharField( lower_thirds_no_talk_info = I18nFormField(
help_text=_( help_text=_(
"Will be shown as talk title if there's currently no talk " "Will be shown as talk title if there's currently no talk "
"running." "running."
), ),
initial="Sorry, there's currently no talk running",
label=_('"no talk running" information'), label=_('"no talk running" information'),
widget=I18nTextInput,
required=True, required=True,
) )
lower_thirds_info_string = forms.CharField( lower_thirds_info_string = I18nFormField(
help_text=_( help_text=_("Will only be shown if there's a talk running."),
"Will only be shown if there's a talk running."
),
initial="",
label=_("info line"), label=_("info line"),
required=False, required=False,
widget=I18nTextInput,
) )

View file

@ -1,8 +1,19 @@
from django.dispatch import receiver from django.dispatch import receiver
from django.urls import resolve, reverse from django.urls import resolve, reverse
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import gettext_noop, ugettext_lazy as _
from i18nfield.strings import LazyI18nString
from pretalx.common.models.settings import hierarkey
from pretalx.orga.signals import nav_event_settings from pretalx.orga.signals import nav_event_settings
hierarkey.add_default(
"lower_thirds_no_talk_info",
LazyI18nString.from_gettext(
gettext_noop("Sorry, there's currently no talk running")
),
LazyI18nString,
)
hierarkey.add_default("lower_thirds_info_string", "", LazyI18nString)
@receiver(nav_event_settings) @receiver(nav_event_settings)
def navbar_info(sender, request, **kwargs): def navbar_info(sender, request, **kwargs):

View file

@ -37,6 +37,7 @@ class LowerThirdsOrgaView(PermissionRequired, FormView):
return { return {
"obj": self.request.event, "obj": self.request.event,
"attribute_name": "settings", "attribute_name": "settings",
"locales": self.request.event.locales,
**kwargs, **kwargs,
} }