Merge pull request #3 from rixx/i18n

Add i18n-support
This commit is contained in:
Franzi 2021-11-21 13:16:54 +01:00 committed by GitHub
commit a425caa211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 hierarkey.forms import HierarkeyForm
from i18nfield.forms import I18nFormField, I18nFormMixin, I18nTextInput
class LowerThirdsSettingsForm(HierarkeyForm):
lower_thirds_no_talk_info = forms.CharField(
class LowerThirdsSettingsForm(I18nFormMixin, HierarkeyForm):
lower_thirds_no_talk_info = I18nFormField(
help_text=_(
"Will be shown as talk title if there's currently no talk "
"running."
),
initial="Sorry, there's currently no talk running",
label=_('"no talk running" information'),
widget=I18nTextInput,
required=True,
)
lower_thirds_info_string = forms.CharField(
help_text=_(
"Will only be shown if there's a talk running."
),
initial="",
lower_thirds_info_string = I18nFormField(
help_text=_("Will only be shown if there's a talk running."),
label=_("info line"),
required=False,
widget=I18nTextInput,
)

View File

@ -1,8 +1,19 @@
from django.dispatch import receiver
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
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)
def navbar_info(sender, request, **kwargs):

View File

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