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

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

问题描述

我对 django 翻译有疑问.

I have a problem with django translations.

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

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

问题 2 - 我用 django-admin.py makemessages -l 创建了我自己的语言环境文件,将翻译字符串添加到文件中,但它们也没有出现在页面上.

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.

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

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.

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

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/

文件是

django.mo 和 django.po

django.mo and django.po

我在问题1中引用的文件是django own et transaltion,我改了.

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

推荐答案

好吧,我刚才也遇到了同样的错误.我解决了它在我的 django.po 文件中删除翻译字符串上的#,fuzzy"标签.如果有这个标签,似乎没有翻译文本,所以一定要翻译文本,然后删除这一行.

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.

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

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!

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

PD:我知道您在几个月前遇到了这个问题,但我留下这个回复是因为我们从未听说过您是否解决了这个问题.

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天全站免登陆