Discuss YII2 developing multi-language dynamic website scheme

Source: Internet
Author: User
In addition to using multiple data table scenarios, are there other scenarios? All data read from the database is implemented in multiple languages.

Reply content:

In addition to using multiple data table scenarios, are there other scenarios? All data read from the database is implemented in multiple languages.

It is too rare to use multiple sets of data tables, usually in a language file ... The database can be stored only key, and then automatically converted to translate keywords, such as category table
Category.id = 1, category.name = ' demo ', Category.slug = demo, Category.meta = ' It is demo '
The corresponding translation file
Category_id_1_name = ' demo '
Category_id_1_meta = ' This is a demo '
If necessary, you can develop the language file Management page, but generally with a po-like editor on the line.
Of course, there are things that can't be done like documents that require additional language fields rather than new tables. such as the article table will contain ID, language, title, content, etc., when displayed automatically according to the language to filter the different document list out on the line.

Summary is simple translation using language files, complex data to add language fields, different language content is managed by multiple records.

As for "all data read from the database to achieve multi-language", this scheme is too tired, the database pressure is also large, the data maintenance is also large, and lack of flexibility. Often we think of translation as the front end in order to optimize the interaction use of the scheme, rather than the work of the database. A similar problem is currency conversion, number format, date format, do you have to rely on the database? What is the price of a new product in 3 different formats? Feel tired when you think about it.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.