For example, a website like this, switch language after the product is the same, is to share a database, or simply a server?
Http://www.farfetch.com/cn/shopping/women/creatures-of-the-wind--jainic-jacket--item-11220708.aspx?storeid= 9946&from=1&ffref=lp_pic_5_1_
Http://www.apicloud.com/index?
Hope the Great God guidance, thank you!
Reply content:
For example, a website like this, switch language after the product is the same, is to share a database, or simply a server?
Http://www.farfetch.com/cn/shopping/women/creatures-of-the-wind--jainic-jacket--item-11220708.aspx?storeid= 9946&from=1&ffref=lp_pic_5_1_
Http://www.apicloud.com/index?
Hope the Great God guidance, thank you!
The general framework provides this functionality, such as PHP CodeIgniter and Ruby on Rails.
Implementation I have not studied, but the idea is based on the language of the current settings to get the corresponding string in the language file.
Language does not exist in the database because the data is not many, are put in the file.
Actually, it's useless to say that. You find a framework that supports multiple languages.
Multiple languages are divided into 2 main parts:
1. Display strings on the page, which are translated through a language file
2. Multiple languages of database data need to be supported when designing a database, typically placing multiple language fields in a multi-lingual table. For example, the multi-language table corresponding to the X table is x_i18n. Then the background management lets the user enter the data in different languages, the foreground finds the corresponding data display according to the different language.
1. Different languages may be at the time of the switch is to visit different site content, because the Chinese site is mainly for the Chinese, English mainly for Europe and the United States, the site of the focus of the product is not the same, the corresponding content will be different.
2. If you simply implement multiple languages, many frameworks will bring their own i18 function bar, page use tags ~
That's what you do in Yii2. Build a class that specializes in string translation, and then refer to it once
return [
'Create' =>'创建','Update' =>'更新','Delete' =>'删除','operate'=>'操作','Submit'=>'提交','Search'=>'搜索','Reset'=>'重置',
Implemented in multiple language files, such as:
The Chinese configuration file has
Key=> ' This is the content '
English configuration file
Key=> ' This is content '
Www.x.com/zh/xxx.html, go to read the Chinese configuration file,
Www.x.com/en/xxx.html, go to read the English configuration file,
Recommended Reference Drupal
Configure multi-language files, according to certain rules on the line, using an array to translate the need for multiple languages, the display of what language will be the language of the configuration file on the line. The framework is also broadly implemented.