3

I want to have my website in three languages and allow user to change preffered language somewhere in my template. My models will need translating. I found a few libraries perhaps I should use :

https://code.google.com/p/django-multilingual/ for traslating my models

https://pypi.python.org/pypi/django-localeurl/1.4 for language prefix in URL's

https://docs.djangoproject.com/en/dev/topics/i18n/ for translating static parts of my site

However I can't understand how these come together. Perhaps someone could give me a rundown of steps to translate my website.

4

1 回答 1

5

如果您使用 Django 1.4,则可以使用i18n_patterns而不是 django-localeurl。或更晚。

i18n_patterns 将根据 URL 前缀设置活动语言。

Django I18n 将在基于活动语言的 python 代码和模板中提供翻译的消息。(您必须创建和编译翻译)makemessagescompilemessages

对于模型中的翻译,有很多库,其中大多数使用主动语言来服务于现场翻译。我更喜欢django-modeltranslation,它允许在不更改代码的情况下翻译 3rd 方应用程序模型。

希望这可以帮助!

于 2013-04-05T07:13:59.417 回答