django国际化和翻译问题 [英] django internationalization and translations issue

查看:152
本文介绍了django国际化和翻译问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个django翻译的问题。



问题1 - 我在django.po文件中更新了字符串,但更改不会出现在网页上。



问题2 - 我用django-admin.py makemessages -l等创建了我自己的区域设置文件,将翻译字符串添加到文件中,但是它们也不会出现在页面上。



我不认为这是设置问题,因为django.po文件的翻译确实出现在网站上,它只是从我自己生成的文件中的更改和翻译



编辑:
我的settings.py包含以下内容:

  gettext = lambda s:s 
LANGUAGE_CODE ='et'

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

我自己的区域设置文件位于

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

,文件是



django.mo和django.po



文件I参考问题1是django自己和transaltion,我改变了。

解决方案

嗯,我有一个这样的错误前。我解决了它在我的django.po文件中的翻译字符串上删除了#,fuzzy标签。看起来如果翻译的文本有这个标签,那么请务必翻译文本,然后删除这行。



这是一个翻译文本的例子不是在po文件上的服务器:

 #:course / models.py:13 
#,fuzzy
msgidcode
msgstrcódigo

所以,只需删除标志并离开它像这样:

 #:course / models.py:13 
msgidcode
msgstr código

我希望这适合你。祝你好运!



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



PD :我知道你在几个月前收到了这个问题,但是我留下了这个回应,因为你解决了这个问题,我们从来没有听说过。


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.

解决方案

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.

这篇关于django国际化和翻译问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆