Hi,
I'm learning Django Translation using django-swingtime with Django 1.7.9 installed.
I followed the official docs and embedded my string to translate with <title>{% trans "String to translate" %}</title> in my Template and managed to create both the po and mo files successfully.
But, the page is still shown up in English.
Note: the translation works just fine for my models.
Partly of the template I was using can be found from below:
{% extends "base.html" %}
{% load url from future %}
{% load i18n %}
{% block title %}Event Occurrence{% endblock %}
{% block main_content %}
<h3>{% trans "Swingtime Event Occurrence" %}</h3>
<h4>
<a href="{{ occurrence.event.get_absolute_url }}">{{ occurrence.title }}</a>
–
{% with occurrence.start_time as st %}
<a href="{% url 'swingtime-daily-view' st.year st.month st.day %}">
{{ st|date:"l, F jS P" }}</a>
</h4>
{% endwith %}
<dl>
<dt>{% trans "Event type:" %}</dt>
<dd>{{ occurrence.event.event_type }}</dd>
The subroutine to render my Template is:
#-------------------------------------------------------------------------------
def occurrence_view(
request,
event_pk,
pk,
template='swingtime/occurrence_detail.html',
form_class=forms.SingleOccurrenceForm
):
'''
View a specific occurrence and optionally handle any updates.
Context parameters:
``occurrence``
the occurrence object keyed by ``pk``
``form``
a form object for updating the occurrence
'''
occurrence = get_object_or_404(Occurrence, pk=pk, event__pk=event_pk)
if request.method == 'POST':
form = form_class(request.POST, instance=occurrence)
if form.is_valid():
form.save()
return http.HttpResponseRedirect(request.path)
else:
form = form_class(instance=occurrence)
return render(request, template, {'occurrence': occurrence, 'form': form})
And the url configuration associated with the Template reads:
url(
r'^events/(\d+)/(\d+)/$',
views.occurrence_view,
name='swingtime-occurrence'
),
Could some one help me solve this problem?
Thanks very much
Br
Sean