Django 模型翻译:将翻译存储在数据库中还是使用 gettext?
我正在 Django 网站的 I18N 流程中。
我选择了两个可能不错的 django-apps :
- django-modeltranslation ,它修改了用于存储翻译的数据库架构
- django-dbgettext,它检查数据库内容以创建.po文件并使用gettext
从您的角度来看,这两种技术的优缺点是什么?
I'm in a Django website's I18N process.
I've selected two potentially good django-apps :
- django-modeltranslation which modifies the db schema to store translations
- django-dbgettext which inspect db content to create .po files and uses gettext
From your point of view, what are the pros and cons of those two techniques ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您想让应用程序的用户(或第三方翻译人员)轻松更新翻译而无需更改代码,那么请选择将翻译存储在数据库中的解决方案之一。
如果您想要更好的质量控制(版本控制、多组眼睛等),那么请使用 gettext。通过使用 gettext,您还可以控制要翻译的字符串。
只是我的2c。
If you want to let users of your app(or third party translators) easily update the translations without code changes then go for one of the solutions that stores the translations in the database.
If you instead want greater quality control(version control, several set of eyes, etc), then use gettext. By using gettext you may also control which strings you want translate.
Just my 2c.
django-modeltranslation 最适合存储翻译值。您将转到 django-admin 并输入翻译后的值。
但是如果你使用django-dbgettext,那么你不需要在django-admin中输入任何值,你可以使用rosetta。如果您无法查找任何翻译值并且希望它进行翻译,那么您可以在“*dbgettext_registration.py*”中输入模型并运行命令“python manage.py dbgettext_export”然后是“python管理.py编译消息”。
django-modeltranslation is best for storing translated value. you will go to django-admin and put translated value.
But If you are using django-dbgettext, then you dont need to put any value in django-admin, you can use rosetta for that. If you are not able to look any value for translation and you want it to translate, then you can do entry of model in "*dbgettext_registration.py*" and run command "python manage.py dbgettext_export" then "python manage.py compilemessages".
http://packages.python.org/django-easymode/ 结合了两者:
http://packages.python.org/django-easymode/i18n/index.html
http://packages.python.org/django-easymode/i18n/translation .html
Gettext用于翻译大量数据,admin用于日常更新。
http://packages.python.org/django-easymode/ combines the two:
http://packages.python.org/django-easymode/i18n/index.html
http://packages.python.org/django-easymode/i18n/translation.html
Gettext is used to translate large ammounts of data, and the admin is used for day to day updates.
我建议您始终使用文件进行翻译。它是可移植的,并且不会对数据库性能产生未知的影响(尤其是使用“神奇”包来修补数据库模式时的问题)
这个包看起来简单且可扩展:https://github.com/ecometrica/django-vinaigrette
I would suggest you always use files for your translations. It's portable and doesn't have unknown impacts on DB performance (especially an issue when using "magic" packages that monkey patch your DB schema)
This package looks simple and extensible: https://github.com/ecometrica/django-vinaigrette