Django 与第三方应用程序的国际化
我有一个 Django 项目,它使用 django-tagging 并应该以德语运行。因此,我查看了源代码,发现 django-tagging 确实使用了 gettext_lazy ,因此是完全可翻译的。但是,包中没有可用的翻译。所以我认为必须有一种方法可以让我在我的项目中翻译它。
换句话说,我希望 ./manage.py makemessages -a 包含来自 django-tagging 的未翻译字符串,但显然我的期望是错误的。
那么,我该如何正确处理这种情况呢?在上游存储库中翻译 django-tagging 是否会按预期工作?
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.
In other words, I expect ./manage.py makemessages -a
to include untranslated strings from django-tagging
, but apparently I'm wrong to expect that.
So, how do I manage this situation properly? Will translating django-tagging
in the upstream repository work as expected?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在 django-tagging 目录中创建 gettext 消息并向项目负责人贡献翻译:
如果您想在项目目录中创建消息目录,您应该在项目目录中安装或符号链接应用程序(检查 makemessages 的 -S 选项)。然后使用如上所述的manage.py makemessages命令。
如果您想查看有关翻译第 3 部分应用程序的更多详细信息,请检查:
http://source.mihelac.org/2010/07/31/handling-i18n-in-django-projects/
You can create gettext messages in django-tagging directory and contribute translations to project leader:
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.
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/
在我的项目目录中,我创建了到该第三方应用程序的符号链接,并使用“--symlinks”选项运行 makemessages 命令:
../manage.py makemessages -l nl --symlinks
然后删除我的符号链接
Within my project directory I make a symlink to that third party app and run my makemessages command with the '--symlinks' option:
../manage.py makemessages -l nl --symlinks
then I remove my symlink
详细:
然后运行
django-admin.py makemessages --locale=*lang* --symlinks
例如,如果我想翻译
django-tagging
:(我的manage.py定位
agregator/site_aggregator_backend/manage.py
)和
django-admin.py makemessages --locale=uk --symlinks
并且所有工作都完美!
Detailed:
and then run
django-admin.py makemessages --locale=*lang* --symlinks
for instance if i want translate
django-tagging
:(my manage.py locates
agregator/site_aggregator_backend/manage.py
)and
django-admin.py makemessages --locale=uk --symlinks
and all work perfectly!