django i18n support: fuzzy!
October 2021
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
This site is an effort to share some of the base knowledge I have gathered through all this years working with Linux, FreeBSD, OpenBSD, Python or Zope, among others. So, take a look around and I hope you will find the contents useful.
Recent Entries
Recent Comments
Recent Trackbacks
OpenBSD (9 items)
BSD (0 items)
FreeBSD (19 items)
Linux (3 items)
Security (3 items)
Python (22 items)
Zope (13 items)
Daily (144 items)
e-shell (9 items)
Hacks (14 items)
PostgreSQL (3 items)
OSX (8 items)
Nintendo DS (0 items)
enlightenment (0 items)
Apache (3 items)
Nintendo Wii (1 items)
Django (24 items)
Music (12 items)
Plone (7 items)
Varnish (0 items)
Lugo (2 items)
Sendmail (0 items)
europython (7 items)
Cherokee (1 items)
self (1 items)
Nature (1 items)
Hiking (0 items)
uwsgi (0 items)
nginx (0 items)
cycling (10 items)
Networking (1 items)
DNS (0 items)

Syndicate this site (XML)

RSS/RDF 0.91

26 noviembre

django i18n support: fuzzy!

well, it is not a matter of django, but of gettext anyway...

It took me some time until I discovered this, so I think it would be nice to post about it.

In a recent project, I needed to add i18n support to a django app. This was the first project that needed such support since the first time i used django some time ago, so I took a look at the official docs, I read some posts in some blogs over the internet and I followed three easy steps:

1- Inside my app dir, I used the tool to generate the needed .po files for my language (.es):

../ makemessages -l es

2- Then I opened up emacs and I used the po mode to edit the .po file (locale/es/LC_MESSAGES/django.po inside my app dir). It is pretty easy to edit a .po file, you could use any text editor to add the translated strings in place, but the po mode has some interesting shortcuts to get it done quickly.

3- Finally I generated the .mo file that contains the pre-compiled translation information, again, using inside my app dir:

../ compilemessages

Then I restarted my django server (I would have to restart apache if we have the app in a production environment) and I tested the app on a web browser.

Nice! It seemed to work, everything was in .es now... but... wait... there were still some untranslated texts.

I went back to emacs and I revised the whole .po file, everythin seemed to be ok, I regenerated the .mo file and restarted the server again... and those strings were still untranslated.

Then something catched my eye in the .po file, the word fuzzy:

#, fuzzy
msgid "Public states"
msgstr "Publicados"

Seems like the fuzzy mark prevents the strings marked as fuzzy to be translated, as that means it is marked for translator revision (more info: ).

To solve this problem, I just removed the fuzzy mark, I regenerated the .mo file and I restarted the server once more. And then everything was correctly translated.

Posted by wu at 00:06 | Comments (0) | Trackbacks (0)
<< A week since the WPD | Main | self() 2.9 released >>
Find non-translated strings.

I had to i18n a django app myself recently. I wrote a little tool to find all the non-translated strings in your django templates. Might be helpful to you and others.

Posted by: Rory McCann at marzo 06,2011 20:58
Re: django i18n support: fuzzy!

you can use rosseta too

Posted by: bob at agosto 22,2013 13:05
Please send trackback to:
There are no trackbacks.
Post a comment