Questions tagged [django-i18n]

Django internationalization provides developers with the ability to build web applications and provide content in multiple languages and locales.

Django internationalization provides developers with the ability to build web applications and provide content in multiple languages and locales.

For text translations, the Django developer can accomplish this goal by adding a minimal amount of hooks to Python and templates. These hooks are called translation strings. They tell Django: “This text should be translated into the end user’s language, if a translation for this text is available in that language.”

Internationalization is achieved in three steps:

  1. Embed translation strings in your Python code and templates.
  2. Get translations for those strings, in whichever languages you want to support.
  3. Activate the locale middleware in your Django settings.
359 questions
0
votes
2 answers

Django 1.5: Remove default language prefix from url in django i18n

I'm using Django 1.5. I have setup internationalization in the project and has set up following variables in the settings.py file LANGUAGE_CODE = 'en' LANGUAGES = ( ('en', 'English'), ('es', 'Spanish') ) and the urls.py file…
Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
0
votes
1 answer

How to translate variables in Jinja2/Django

I use i18n in my Jinja2 templates and everything works fine for plain text. But I can't find any info how to use translations with variables, which I can't avoid using. Here is an example: {% set words = ["Hello", "world"] %} {% for word in words…
Myroslav Hryshyn
  • 716
  • 7
  • 18
0
votes
1 answer

Why language is not changing with set_language url in Django?

I added django-user-language-middleware package but it only change language when I manually change it at admin or DB. When I use set_language link, it doesn't update language. Before adding that middleware, it was working without any problem but I…
Taras
  • 447
  • 2
  • 7
  • 18
0
votes
0 answers

Django translation makemessages missing #. in .po file

I'm experiencing syntax error when i run manage.py compilemessages. I opened the .po file and found out that some line doesn't have #: at the beginning of the line. he translation code was implemented correctly in the source file. It was replaced…
Wreeecks
  • 2,186
  • 1
  • 33
  • 53
0
votes
1 answer

django languange change takes effect only after reload

In my app I can change the language by the following: from django.utils.translation import LANGUAGE_SESSION_KEY # LANGUAGE_SESSION_KEY is "_language" ... def my_view(request, my_lang=en): request.session[LANGUAGE_SESSION_KEY] = my_lang ... …
cknoll
  • 2,130
  • 4
  • 18
  • 34
0
votes
1 answer

Django "settings.DATABASES is improperly configured" and "ImproperlyConfigured at /i18n/setlang/"

I wrote a django web application and now I need to translate it to english. I followed the documentation but I keep getting this strange error: ImproperlyConfigured at /i18n/setlang/ settings.DATABASES is improperly configured. Please supply the…
Miguel
  • 2,738
  • 3
  • 35
  • 51
0
votes
1 answer

Django uggetext as __ instead of _ breaks makemessages

I just came across a weird bug (?) where I initially had from django.utils.translation import ugettext as _ Which I changed for from django.utils.translation import ugettext as __ But, surprisingly, running ./manage.py makemessages --all after…
Vadorequest
  • 16,593
  • 24
  • 118
  • 215
0
votes
1 answer

Locale from django app not change

I newbie into Django, and I need make a I18N system. I have this url.py: from django.contrib import admin from django.urls import path, include from . import views urlpatterns = [ path('', views.index, name='home'), path(r'^i18n/',…
Dimmy Magalhães
  • 357
  • 1
  • 6
  • 21
0
votes
1 answer

Django template text does not get translated with LocaleMiddleware

Like in the subject, I have two strings to translate:

{% blocktrans %} My, ludzie, mamy skłonność doświadczania samych siebie jako czegoś oddzielnego od otaczającego nas Wszechświata. Jest to łudzenie naszej…

oskar333
  • 157
  • 2
  • 11
0
votes
1 answer

Django ugettext_lazy not working for interpolated strings in forms

I have form: class UserForm(forms.Form): fname = forms.CharField(max_length=30, label=_('First Name'), validators=[Alpha()]) lname = forms.CharField(max_length=30, label=_('Last Name {name}').format(name='XXXX'), validators=[Beta()]) i am rendering…
Saqib
  • 685
  • 3
  • 15
0
votes
0 answers

Python Django I want remove language code in url(path)

I want remove language code in url for example select en select jp select cn I want it to appear as www.abc.com instead of www.abc.com/jp, www.abc.com/cn. I want to get language code from session and activate it. not url help me urls.py urlpatterns…
강준우
  • 15
  • 3
0
votes
1 answer

Django language selection from dropdown (links and images)

I could use this code: mytemplate.html:
{% csrf_token %}