kopia lustrzana https://github.com/wagtail/wagtail
Fix translations and pluralisation within CopyForm
rodzic
a14f604142
commit
455159378f
|
@ -2,7 +2,7 @@ from django import forms
|
|||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import ugettext_lazy
|
||||
from django.utils.translation import ungettext, ugettext_lazy
|
||||
|
||||
|
||||
class SearchForm(forms.Form):
|
||||
|
@ -85,25 +85,32 @@ class CopyForm(forms.Form):
|
|||
can_publish = kwargs.pop('can_publish')
|
||||
super(CopyForm, self).__init__(*args, **kwargs)
|
||||
|
||||
self.fields['new_title'] = forms.CharField(initial=self.page.title)
|
||||
self.fields['new_slug'] = forms.SlugField(initial=self.page.slug)
|
||||
self.fields['new_title'] = forms.CharField(initial=self.page.title, label=_("New title"))
|
||||
self.fields['new_slug'] = forms.SlugField(initial=self.page.slug, label=_("New slug"))
|
||||
|
||||
pages_to_copy = self.page.get_descendants(inclusive=True)
|
||||
subpage_count = pages_to_copy.count() - 1
|
||||
if subpage_count > 0:
|
||||
self.fields['copy_subpages'] = forms.BooleanField(required=False, initial=True,
|
||||
help_text=_("This will copy %(count)s subpages.") % {'count': subpage_count})
|
||||
self.fields['copy_subpages'] = forms.BooleanField(
|
||||
required=False, initial=True, label=_("Copy subpages"),
|
||||
help_text=ungettext(
|
||||
"This will copy %(count)s subpage.",
|
||||
"This will copy %(count)s subpages.",
|
||||
subpage_count) % {'count': subpage_count})
|
||||
|
||||
if can_publish:
|
||||
pages_to_publish_count = pages_to_copy.live().count()
|
||||
if pages_to_publish_count > 0:
|
||||
# In the specific case that there are no subpages, customise the field label and help text
|
||||
if subpage_count == 0:
|
||||
label = 'Publish copied page'
|
||||
label = _("Publish copied page")
|
||||
help_text = _("This page is live. Would you like to publish its copy as well?")
|
||||
else:
|
||||
label = 'Publish copies'
|
||||
help_text = _("%(count)s of the pages being copied are live. Would you like to publish their copies?") % {'count': pages_to_publish_count}
|
||||
label = _("Publish copies")
|
||||
help_text = ungettext(
|
||||
"%(count)s of the pages being copied is live. Would you like to publish its copy?",
|
||||
"%(count)s of the pages being copied are live. Would you like to publish their copies?",
|
||||
pages_to_publish_count) % {'count': pages_to_publish_count}
|
||||
|
||||
self.fields['publish_copies'] = forms.BooleanField(
|
||||
required=False, initial=True, label=label, help_text=help_text
|
||||
|
|
Ładowanie…
Reference in New Issue