Django 的 I18N 与第三方应用程序 [英] Django's I18N with third-party apps

查看:24
本文介绍了Django 的 I18N 与第三方应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Django 项目,它使用 django-tagging 并且应该以德语运行.所以我查看了源代码,发现 django-tagging 确实使用了 gettext_lazy 并且因此是完全可翻译的.但是,包中没有可用的翻译.所以我认为我必须有一种方法可以从我的项目中翻译它.

I have a Django project which uses django-tagging and is supposed to run in German. So I looked into the sources and found that django-tagging does indeed use gettext_lazy and is thus completely translatable. However, there are no translations available in the package. So I assume there must be a way for me to translate it from within my project.

换句话说,我希望 ./manage.py makemessages -a 包含来自 django-tagging 的未翻译字符串,但显然我的期望是错误的.

In other words, I expect ./manage.py makemessages -a to include untranslated strings from django-tagging, but apparently I'm wrong to expect that.

那么,我该如何妥善处理这种情况呢?在上游存储库中翻译 django-tagging 会按预期工作吗?

So, how do I manage this situation properly? Will translating django-tagging in the upstream repository work as expected?

推荐答案

您可以在django-tagging 目录中创建gettext 消息并将翻译贡献给项目负责人:

You can create gettext messages in django-tagging directory and contribute translations to project leader:

django-admin.py makemessages -l de

如果你想在你的项目目录中创建消息目录,你应该在你的项目目录中安装或符号链接应用程序(检查 makemessages 的 -S 选项).然后使用上面的 manage.py makemessages 命令.

If you want to create message catalog in your project directory, you should install or symlink app (check -S option of makemessages) in your project directory. Then use manage.py makemessages command as above.

如果您想查看有关翻译第 3 部分应用程序的更多详细信息,请查看:

If you want to see more details about translating 3rd part apps, please check:

http://source.mihelac.org/2010/07/31/handling-i18n-in-django-projects/

这篇关于Django 的 I18N 与第三方应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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