Use lazy gettext in models and forms to allow things to be shown in Spanish.
This commit is contained in:
parent
6e34abda84
commit
87e9296007
@ -1,6 +1,6 @@
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from apps.map.models import CaseStudy, CaseStudyDraft
|
from apps.map.models import CaseStudy, CaseStudyDraft
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
from django.utils.translation import ugettext as _
|
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
from django.utils.text import format_lazy
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from crispy_forms.helper import FormHelper
|
from crispy_forms.helper import FormHelper
|
||||||
from crispy_forms.layout import Submit, Layout, HTML, Fieldset, Div
|
from crispy_forms.layout import Submit, Layout, HTML, Fieldset, Div
|
||||||
@ -152,6 +153,24 @@ class BootstrapClearableFileInput(forms.ClearableFileInput):
|
|||||||
template_name = 'map/forms/widgets/file.html'
|
template_name = 'map/forms/widgets/file.html'
|
||||||
|
|
||||||
|
|
||||||
|
def PreviousButton():
|
||||||
|
return HTML(
|
||||||
|
format_lazy(
|
||||||
|
"<a class='btn btn-primary btnPrevious'>{prev}</a>",
|
||||||
|
prev=_("Previous")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def NextButton():
|
||||||
|
return HTML(
|
||||||
|
format_lazy(
|
||||||
|
"<a class='btn btn-primary btnNext pull-right'>{next}</a>",
|
||||||
|
next=_("Next")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class LongCaseStudyForm(BaseCaseStudyForm):
|
class LongCaseStudyForm(BaseCaseStudyForm):
|
||||||
"""Long version of the CaseStudy form."""
|
"""Long version of the CaseStudy form."""
|
||||||
|
|
||||||
@ -242,39 +261,58 @@ class LongCaseStudyForm(BaseCaseStudyForm):
|
|||||||
self.fields['project_owners'].required = True
|
self.fields['project_owners'].required = True
|
||||||
self.fields['shareholders'].required = True
|
self.fields['shareholders'].required = True
|
||||||
|
|
||||||
|
organising_vs_label = _(
|
||||||
|
'Socio-environmental impacts (negative and potentially positive)')
|
||||||
|
organising_pro_label = _(
|
||||||
|
'Socio-environmental impacts (positive and potentially negative)')
|
||||||
|
organising_other_label = _(
|
||||||
|
'Socio-environmental impacts (positive and negative)')
|
||||||
|
|
||||||
self.fields['socioeconomic_benefits'].label = \
|
self.fields['socioeconomic_benefits'].label = format_lazy(
|
||||||
'<span class="organising organising-vs">' + \
|
(
|
||||||
_('Socio-environmental impacts (negative and potentially positive)') + \
|
'<span class="organising organising-vs">{vs}</span>'
|
||||||
'</span>' + \
|
'<span class="organising organising-pro">{pro}</span>'
|
||||||
'<span class="organising organising-pro">' + \
|
'<span class="organising organising-none organising-idk">{other}</span>'
|
||||||
_('Socio-environmental impacts (positive and potentially negative)') + \
|
),
|
||||||
'</span>' + \
|
vs=organising_vs_label,
|
||||||
'<span class="organising organising-none organising-idk">' + \
|
pro=organising_pro_label,
|
||||||
_('Socio-environmental impacts (positive and negative)') + \
|
other=organising_other_label
|
||||||
'</span>'
|
)
|
||||||
|
|
||||||
|
organising_other_text = _(
|
||||||
|
'Please expand on your response given in the full description on page one.'
|
||||||
|
' For example, for positive impacts you need to go beyond emissions'
|
||||||
|
' savings, paying rent for land, or complying with environmental or social'
|
||||||
|
' legislation. For negative impacts you need to focus on substantive'
|
||||||
|
' impacts on vulnerable groups, violations of land rights or abusive labour'
|
||||||
|
' practices.')
|
||||||
|
|
||||||
|
organising_vs_text = _(
|
||||||
|
'Please expand on your response given in the description. Note that we aim'
|
||||||
|
' to focus on violation of land rights / human rights / collective rights,'
|
||||||
|
' substantive negative impacts on vulnerable groups, aggression / threats /'
|
||||||
|
' violence severe environmental and/or cultural impacts, abusive labor '
|
||||||
|
' practices, and corruption / governance issues, but feel free to cover any'
|
||||||
|
' additional aspect that you consider relevant. Please also describe and'
|
||||||
|
' analyze socio-environmental impacts that could be presented or considered'
|
||||||
|
' as positive.')
|
||||||
|
|
||||||
|
organising_pro_text = _(
|
||||||
|
'Please expand on your response given in the description. Please also'
|
||||||
|
' describe and analyze socio-environmental impacts that could be considered'
|
||||||
|
' as negative.')
|
||||||
|
|
||||||
|
self.fields['socioeconomic_benefits'].help_text = format_lazy(
|
||||||
|
(
|
||||||
|
'<span class="organising organising-none organising-idk">{other}</span>'
|
||||||
|
'<span class="organising organising-vs">{vs}</span>'
|
||||||
|
'<span class="organising organising-pro">{pro}</span>'
|
||||||
|
),
|
||||||
|
vs=organising_vs_text,
|
||||||
|
pro=organising_pro_text,
|
||||||
|
other=organising_other_text
|
||||||
|
)
|
||||||
|
|
||||||
self.fields['socioeconomic_benefits'].help_text = \
|
|
||||||
'<span class="organising organising-none organising-idk">' + \
|
|
||||||
_('Please expand on your response given in the full description on page one.'
|
|
||||||
' For example, for positive impacts you need to go beyond emissions savings,'
|
|
||||||
' paying rent for land, or complying with environmental or social legislation.'
|
|
||||||
' For negative impacts you need to focus on substantive impacts on vulnerable groups, '
|
|
||||||
' violations of land rights or abusive labour practices.') + \
|
|
||||||
'</span>' + \
|
|
||||||
'<span class="organising organising-vs">' + \
|
|
||||||
_('Please expand on your response given in the description. Note that we aim to' \
|
|
||||||
' focus on violation of land rights / human rights / collective rights, substantive' \
|
|
||||||
' negative impacts on vulnerable groups, aggression / threats / violence,' \
|
|
||||||
' severe environmental and/or cultural impacts, abusive labor practices, and' \
|
|
||||||
' corruption / governance issues, but feel free to cover any additional aspect' \
|
|
||||||
' that you consider relevant. Please also describe and analyze socio-environmental' \
|
|
||||||
' impacts that could be presented or considered as positive.') + \
|
|
||||||
'</span>' + \
|
|
||||||
'<span class="organising organising-pro">' + \
|
|
||||||
_('Please expand on your response given in the description. Please also describe' \
|
|
||||||
' and analyze socio-environmental impacts that could be considered as negative.') + \
|
|
||||||
'</span>'
|
|
||||||
|
|
||||||
self.helper.form_action = reverse('long-form')
|
self.helper.form_action = reverse('long-form')
|
||||||
self.helper.layout = Layout(
|
self.helper.layout = Layout(
|
||||||
@ -322,7 +360,7 @@ class LongCaseStudyForm(BaseCaseStudyForm):
|
|||||||
'social_media_links'
|
'social_media_links'
|
||||||
),
|
),
|
||||||
FormActions(
|
FormActions(
|
||||||
HTML("<a class='btn btn-primary btnNext pull-right'>"+_("Next")+"</a>")
|
NextButton()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
Tab(
|
Tab(
|
||||||
@ -384,24 +422,29 @@ class LongCaseStudyForm(BaseCaseStudyForm):
|
|||||||
css_class="manufacturing_questions"
|
css_class="manufacturing_questions"
|
||||||
),
|
),
|
||||||
FormActions(
|
FormActions(
|
||||||
HTML("<a class='btn btn-primary btnPrevious'>"+_("Previous")+"</a>"),
|
PreviousButton(),
|
||||||
HTML("<a class='btn btn-primary btnNext pull-right'>"+_("Next")+"</a>")
|
NextButton()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
Tab(
|
Tab(
|
||||||
_("Socio-environmental analysis"),
|
_("Socio-environmental analysis"),
|
||||||
HTML(
|
HTML(
|
||||||
"<p>" +
|
format_lazy(
|
||||||
_("In the following, we expect the analysis to reflect the"
|
"<p>{text}</p>",
|
||||||
" perspective of the organization(s) or person(s) describing"
|
text=_(
|
||||||
" the case.") + "</p>"
|
"In the following, we expect the analysis to reflect "
|
||||||
|
" the perspective of the organization(s) or person(s) "
|
||||||
|
" describing the case.")
|
||||||
|
)
|
||||||
),
|
),
|
||||||
'positive_or_negative',
|
'positive_or_negative',
|
||||||
Div(
|
Div(
|
||||||
HTML(
|
HTML(
|
||||||
"<label class='col-md-3 control-label'>" +
|
format_lazy(
|
||||||
_("What kind of case is this entry about?") +
|
"<label class='col-md-3 control-label'>{text}</label>",
|
||||||
"</label>"),
|
text=_("What kind of case is this entry about?")
|
||||||
|
)
|
||||||
|
),
|
||||||
Div(
|
Div(
|
||||||
'positive_case_type',
|
'positive_case_type',
|
||||||
'negative_case_reasons',
|
'negative_case_reasons',
|
||||||
@ -424,8 +467,8 @@ class LongCaseStudyForm(BaseCaseStudyForm):
|
|||||||
css_class="common_questions"
|
css_class="common_questions"
|
||||||
),
|
),
|
||||||
FormActions(
|
FormActions(
|
||||||
HTML("<a class='btn btn-primary btnPrevious'>"+_("Previous")+"</a>"),
|
PreviousButton(),
|
||||||
HTML("<a class='btn btn-primary btnNext pull-right'>"+_("Next")+"</a>")
|
NextButton()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
Tab(
|
Tab(
|
||||||
@ -439,8 +482,8 @@ class LongCaseStudyForm(BaseCaseStudyForm):
|
|||||||
'shown_on_other_platforms',
|
'shown_on_other_platforms',
|
||||||
'shown_on_other_platforms_detail',
|
'shown_on_other_platforms_detail',
|
||||||
FormActions(
|
FormActions(
|
||||||
HTML("<a class='btn btn-primary btnPrevious'>"+_("Previous")+"</a>"),
|
PreviousButton(),
|
||||||
HTML("<a class='btn btn-primary btnNext pull-right'>"+_("Next")+"</a>")
|
NextButton()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
Tab(
|
Tab(
|
||||||
@ -450,7 +493,7 @@ class LongCaseStudyForm(BaseCaseStudyForm):
|
|||||||
'other_documents',
|
'other_documents',
|
||||||
'other_documents_files',
|
'other_documents_files',
|
||||||
FormActions(
|
FormActions(
|
||||||
HTML("<a class='btn btn-primary btnPrevious'>"+_("Previous")+"</a>"),
|
PreviousButton(),
|
||||||
Submit('submit', _('Submit'), css_class="btn-success pull-right")
|
Submit('submit', _('Submit'), css_class="btn-success pull-right")
|
||||||
)
|
)
|
||||||
)))
|
)))
|
||||||
|
@ -5,7 +5,7 @@ from django.contrib.auth.models import User
|
|||||||
from django.contrib.gis.db import models
|
from django.contrib.gis.db import models
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.template.defaultfilters import slugify
|
from django.template.defaultfilters import slugify
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from django_extensions.db.fields import AutoSlugField
|
from django_extensions.db.fields import AutoSlugField
|
||||||
from django_countries.fields import CountryField
|
from django_countries.fields import CountryField
|
||||||
@ -657,7 +657,7 @@ class CaseStudy(models.Model):
|
|||||||
# Should be filled in if generation_technology was answered as bio-energy
|
# Should be filled in if generation_technology was answered as bio-energy
|
||||||
biomass_detail = models.CharField(
|
biomass_detail = models.CharField(
|
||||||
verbose_name=_("Bio-energy feedstock"),
|
verbose_name=_("Bio-energy feedstock"),
|
||||||
help_text="<div class='text-muted'>" + _(
|
help_text=_("<div class='text-muted'>"
|
||||||
"<p>Please describe the source of the fuel and how it is processed/used."
|
"<p>Please describe the source of the fuel and how it is processed/used."
|
||||||
" Please consider:</p>\n"
|
" Please consider:</p>\n"
|
||||||
"<ul>\n"
|
"<ul>\n"
|
||||||
@ -669,7 +669,7 @@ class CaseStudy(models.Model):
|
|||||||
"</ul>\n"
|
"</ul>\n"
|
||||||
"<p>We do not expect users to know this information, but if you do "
|
"<p>We do not expect users to know this information, but if you do "
|
||||||
" it may be useful to give a fuller picture.</p>"
|
" it may be useful to give a fuller picture.</p>"
|
||||||
) + "</div>",
|
"</div>"),
|
||||||
max_length=200,
|
max_length=200,
|
||||||
blank=True
|
blank=True
|
||||||
)
|
)
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<p style="margin-top: 40px">If you are interested in writing a technology assessment or policy analysis to appear on this site, please email <a href="mailto:info@ojuso.org">info@ojuso.org</a>.</p>
|
<p style="margin-top: 40px">{% trans 'If you are interested in writing a technology assessment or policy analysis to appear on this site, please email <a href="mailto:info@ojuso.org">info@ojuso.org</a>.' %}</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user