Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django missing translation of some strings. Any idea why?

I have a medium sized Django project, (running on AppEngine if it makes any difference), and have all the strings living in .po files like they should.

I'm seeing strange behavior where certain strings just don't translate. They show up in the .po file when I run make_messages, with the correct file locations marked where my {% trans %} tags are. The translations are in place and look correct compared to other strings on either side of them. But when I display the page in question, about 1/4 of the strings simply don't translate.

Digging into the relevant generated .mo file, I don't see either the msgid or the msgstr present.

Has anybody seen anything similar to this? Any idea what might be happening?

  • trans tags look correct
  • .po files look correct
  • no errors during compile_messages
like image 924
Jason Kester Avatar asked Jan 21 '09 00:01

Jason Kester


People also ask

How does Django translation work?

Django then provides utilities to extract the translation strings into a message file. This file is a convenient way for translators to provide the equivalent of the translation strings in the target language. Once the translators have filled in the message file, it must be compiled.

What is load I18n in Django?

{% load i18n %} is needed for internationalization. The purpose of internationalization is to allow a single application to read in multiple languages. In order to do this: you need a few hooks called translation strings. To give your template access to these tags, put {% load i18n %} toward the top of your template..

Is Django multilingual?

Django offers multiple language support out-of-the-box. In fact, Django is translated into more than 100 languages. This tutorial looks at how to add multiple language support to your Django project.


1 Answers

The fuzzy marker is added to the .po file by makemessages. When you have a new string (with no translations), it looks for similar strings, and includes them as the translation, with the fuzzy marker. This means, this is a crude match, so don't display it to the user, but it could be a good start for the human translator.

It isn't a Django behavior, it comes from the gettext facility.

like image 200
Ned Batchelder Avatar answered Oct 19 '22 18:10

Ned Batchelder