打算用django做一个中英文网站。是不是必须建立双库?
如果是三语网站呢?
另外,针对导航这些固定信息,有没有不存数据库而实现的方法。
大家讲道理2017-04-18 10:34:25
I don’t know if I misunderstood your needs. Shouldn’t it be saved in English and then internationalized?
怪我咯2017-04-18 10:34:25
The database is one, and the places on the page that need to be translated are i18n
PHP中文网2017-04-18 10:34:25
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
ringa_lee2017-04-18 10:34:25
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
大家讲道理2017-04-18 10:34:25
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.