python - django搭建中英双语网站,必须用双库吗?
高洛峰
高洛峰 2017-04-18 10:32:25
0
5
568

打算用django做一个中英文网站。是不是必须建立双库?
如果是三语网站呢?
另外,针对导航这些固定信息,有没有不存数据库而实现的方法。

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(5)
大家讲道理

I don’t know if I misunderstood your needs. Shouldn’t it be saved in English and then internationalized?

刘奇

The database is one, and the places on the page that need to be translated are i18n

洪涛

If you don’t consider the website style and layout issues of each country, when creating a table that needs to be changed frequently, there will be one Chinese field and one English field. If you don’t need to change it frequently, you can directly create the configuration file in the program

If you consider issues such as style and layout, build different front-end projects

For reference only

左手右手慢动作

I agree, you can consider using i18n, and then write the parts that need to be translated in the locale. For details, you can refer to the sandbox of django-oscar

大家讲道理

Check it out: django internationalization and localization
You can also implement it yourself. General principle:
1. Construct a language corresponding dictionary, for example:
lan = {

'login': {
    'cn': u'登录',
    'en': 'Login',
    'xx': 'xxx',
},

}
2. There is a global parameter in the project to indicate which language is currently used: cn en xx
3. In py and html (django template), the corresponding content is obtained through the above dictionary. It's more troublesome in js: I thought before that I would put the text (translated) that needs to be displayed in js into the shadow form in html, and then get it in html when js is loaded.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template