Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Ground Controller Lvl 1
Message 1 of 1

urls not found

- My urls are automatically translated (Python, from django.utils.translation import ugettext_lazy as _)
- The English version is on urls.py then, the translated versions in django.po (one french, one spanish, one dutch)

 

Basically the problem is that when you are on the website and you click on the flag it translate without any problem, but, if you have a Spanish, French or dutch device it doesn´t find any urls either the English of the other language.  

 

 


Ex in urls.py:
from django.conf.urls import url
from django.views.generic import TemplateView
from django.conf.urls.i18n import i18n_patterns
from django.utils.translation import ugettext_lazy as _

from . import views
from views import ExtraContextTemplateView

urlpatterns = [
url(_(r'^contact/$'), views.contact, name='contact'),
]

 


In index.html:
<form action="{% url 'set_language' %}"
method="post"
style="display: none;"
id="form-change-lang">{% csrf_token %}
<select name="language">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected{% endif %}>
{{ language.name_local }} ({{ language.code }})
</option>
{% endfor %}
</select>
<input type="submit" value="Go" />
</form>

 

 

In setting, common.py I have:

LANGUAGE_CODE = 'en'

gettext = lambda s: s
LANGUAGES = [
('en', _('English')),
('es', _('Spanish')),
('fr', _('French')),
('nl', _('Dutch')),
]

prefix_default_language = False

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

AUTOSLUG_MODELTRANSLATION_ENABLE = True