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
172
votes
4 answers

"gettext()" vs "gettext_lazy()" in Django

I have a question about using ugettext and gettext_lazy() for translations. I learned that in models I should use gettext_lazy(), while in views ugettext. But are there any other places, where I should use gettext_lazy() too? What about form…
Dzejkob
  • 2,302
  • 2
  • 15
  • 20
139
votes
6 answers

Unable to find a locale path to store translations for file __init__.py

I'm trying to translate a Django app. I created some strings with {% trans %} in my templates. However, when I execute the following command in my app folder, I receive an error message: $ django-admin.py makemessages -l fr CommandError: Unable to…
Antoine M.
  • 3,631
  • 3
  • 15
  • 20
115
votes
7 answers

How to get the current language in Django?

How can I get the current language in Django?
diegueus9
  • 29,351
  • 16
  • 62
  • 74
49
votes
3 answers

How to translate a model label in Django Admin?

I could translate Django Admin except a model label because I don't know how to translate a model label in Django Admin. So, how can I translate a model label in Django Admin?
luc
  • 41,928
  • 25
  • 127
  • 172
41
votes
5 answers

Django internationalization language codes

Where can I find list of languages and language_code like this. (Swedish,sv) (English,en)
Hulk
  • 32,860
  • 62
  • 144
  • 215
35
votes
4 answers

Django internationalization for admin pages - translate model name and attributes

Django's internationalization is very nice (gettext based, LocaleMiddleware), but what is the proper way to translate the model name and the attributes for admin pages? I did not find anything about this in the…
geekQ
  • 29,027
  • 11
  • 62
  • 58
33
votes
6 answers

What's the correct way to set up Django translation?

I've got an issue with translations not working on Django 1.6. I've added this to my settings.py: LANGUAGE_CODE = 'en-us' ugettext = lambda s: s LANGUAGES = ( ('en', ugettext('English')), ('de', ugettext('German')), ) Also added…
frlan
  • 6,950
  • 3
  • 31
  • 72
29
votes
6 answers

Django makemessages errors Unknown encoding "utf8"

I installed python separated from yum. Now, I need to recompile the language pack for the OSQA system, but get this message: Error: errors happened while running xgettext on __init__.py xgettext:…
digoferra
  • 1,001
  • 3
  • 17
  • 33
28
votes
10 answers

AppRegistryNotReady: The translation infrastructure cannot be initialized

When I try to access to my app, I'm getting the following error below: AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import…
Alexandre Tea
  • 313
  • 1
  • 3
  • 7
22
votes
4 answers

How can I change Django admin language?

I have a django 1.6 site with i18n working. I can change the frontend language with a select box in the top of the template, but I don't know if there is a django app or trick to change the admin language, because it seems to store somewhere in…
maikelpac
  • 303
  • 1
  • 3
  • 7
22
votes
6 answers

How to install GNU gettext on windows 7?

I need to install version 0.15 or higher of GNU's gettext so that I can use some i18n feateres with django. I've downloaded : http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.3.1.tar.gz from https://www.gnu.org/software/gettext/ However I have no…
Marijus
  • 4,195
  • 15
  • 52
  • 87
21
votes
1 answer

Context value / variable not rendered inside blocktrans template tag

I've a context processor which adds objects (i.e. site) to the template context but the value is not rendered inside the {% blocktrans %} template tag. Outside the template tag, the value prints just fine.

{% trans "About" %} {{ site.domain…

Franck
  • 325
  • 3
  • 7
21
votes
1 answer

Alowing 'fuzzy' translations in django pages?

I've done some research and found that django translations don't show up when a string is marked as "fuzzy". However, I haven't been able to find any documentation on whether I can override this behaviour. Is there a Django setting that can be used…
user764357
15
votes
2 answers

Django makemessages not creating newly added languages

I had 12 languages in my Django app, if I run the command: python manage.py makemessages --all It would create all the 12 .po files for the languages, now I added 3 more languages: LANGUAGES = ( ... ('th', gettext('Thai')), ('tl',…
PepperoniPizza
  • 8,842
  • 9
  • 58
  • 100
14
votes
9 answers

Issue trying to change language from Django template

I need to include two buttons or links to allow users change language between English and Spanish. I've read the docs and tried this:
{% csrf_token %}
Caumons
  • 9,341
  • 14
  • 68
  • 82
1
2 3
23 24