Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

django internationalization and translations issue

I have a problem with django translations.

Problem 1 - I updated string in django.po file, but the change does not appear on the webpage.

Problem 2 - I have created my own locale file with django-admin.py makemessages -l et, added the translation string into file, but they too do not appear on the page.

I do not think this is setting problem, because the translations from django.po file do appear on the website, its just the changes and the translations from my own generated file that do not appear.

Edit: My settings.py contains this:

gettext = lambda s: s
LANGUAGE_CODE = 'et'

LANGUAGES = (
             ('et', gettext('Estonian')),
             )

my own locale files are in

/path/to/project/locale/et/LC_MESSAGES/

and the files are

django.mo and django.po

the file I refer to in problem 1 is django own et transaltion, which I changed.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Well, I got this same error a few moments ago. I solved it deleting the "#, fuzzy" tag over the translation strings in my django.po files. It seems that translated text is not served if it got this tag, so make sure to translate the text and then delete this line.

Here is an example of a translated text not server on a po file:

     #: course/models.py:13
     #, fuzzy
     msgid "code"
     msgstr "código"

So, just delete the flag and leave it like this:

     #: course/models.py:13
     msgid "code"
     msgstr "código"

I hope this work for you. Good luck!

Reference: http://share-experiences.com/blog/what-fuzzy-means-python-django-gettext/

PD: I know you got this issue a few month ago, but I leave this response due that you we never heard if you got this problem solved.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...