Home  >  Q&A  >  body text

python - django搭建中英双语网站,必须用双库吗?

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

高洛峰高洛峰2741 days ago501

reply all(5)I'll reply

  • 大家讲道理

    大家讲道理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?

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 10:34:25

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

    reply
    0
  • PHP中文网

    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

    reply
    0
  • ringa_lee

    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

    reply
    0
  • 大家讲道理

    大家讲道理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.

    reply
    0
  • Cancelreply