Django 与第三方应用程序的国际化

发布于 2024-09-27 03:32:38 字数 294 浏览 0 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

万水千山粽是情ミ 2024-10-04 03:32:38

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

django-admin.py makemessages -l de

如果您想在项目目录中创建消息目录,您应该在项目目录中安装或符号链接应用程序(检查 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:

django-admin.py makemessages -l de

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/

违心° 2024-10-04 03:32:38

在我的项目目录中,我创建了到该第三方应用程序的符号链接,并使用“--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

余生一个溪 2024-10-04 03:32:38

详细:

ln -s full/path/to/installed/app/folder path/to/folder/with/symlinks/in/your/project

然后运行

django-admin.py makemessages --locale=*lang* --symlinks

例如,如果我想翻译django-tagging:(

 ln -s /home/user/python_projects/agregator_gitlab/venv/lib/python3.6/site-packages/tagging /home/user/python_projects/agregator_gitlab/agregator/site_aggregator_backend/extra-locales/tagging

我的manage.py定位agregator/site_aggregator_backend/manage.py

django-admin.py makemessages --locale=uk --symlinks

并且所有工作都完美!

Detailed:

ln -s full/path/to/installed/app/folder path/to/folder/with/symlinks/in/your/project

and then run

django-admin.py makemessages --locale=*lang* --symlinks

for instance if i want translate django-tagging:

 ln -s /home/user/python_projects/agregator_gitlab/venv/lib/python3.6/site-packages/tagging /home/user/python_projects/agregator_gitlab/agregator/site_aggregator_backend/extra-locales/tagging

(my manage.py locates agregator/site_aggregator_backend/manage.py)

and

django-admin.py makemessages --locale=uk --symlinks

and all work perfectly!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文