How does PHP switch between Chinese and English websites? Now I want to build a foreign trade website that requires both Chinese and English versions. I would like to ask if I want to create two websites separately or only one, and then switch between Chinese and English versions? ------ Solution ------------------ multilingual website solution php Preface: multilingual website development focuses on solving problems between languages. So how can we solve this problem? It takes about three steps: 1. how does PHP switch between Chinese and English websites?
Now I want to build a foreign trade website that requires both Chinese and English versions. I would like to ask if I want to create two websites separately or only one, and then switch between Chinese and English versions?
------ Solution --------------------
Multilingual website solution php
Preface:
Multi-language website development focuses on solving inter-language problems.
So how can we solve this problem? It takes about three steps:
1. webpage multi-language
2. multi-language database
3. Unified user access languages
1. webpage multi-language
Considerations:
A. When A user logs in, the user automatically identifies characters and calls different language packs?
B. when switching between different languages, how does one call different language packs?
C. add the directory structure after multiple languages?
The page has multiple languages, that is, the appearance is multilingual. static language packs can be used here.
The language directory should be included in the design and have independent subdirectories for different languages.
Such as English language/en, simplified Chinese language/gb, traditional Chinese language/b5 (other languages can be expanded)
Each directory contains the language version of each page. When you select a language version, you can call the corresponding version of the language pack.
Specific practices:
0. Identify the browser language using the js language and call different language packs.
1. language/en/global. ln is a global language pack for the English version.
2. the content of global. ln is:
$ Title = "English webstie ";
$ Charset = "UTF-8 ";
3. index. php call:
Require_once ()
?>;
;
;
; $ Title ;
;
;
;;
;
In this way, the page can be expanded in multiple languages.
2. multi-language database
The following are the considerations:
A. How does one input data in the background in multiple languages?
B. how to save the content submitted by users in different versions?
C. are there three language packs available, either in English or in simplified Chinese?
Multi-language database is the unity of multiple languages in the database. UTF-8 encoding is required.
All the texts in any language are stored in the database using UTF-8. Use table fields for table recognition
The language version of the text.
Details:
A. questions about background addition:
1. multilingual input is required when the backend is added. First, create a database encoded with UTF-8 and enter the English/simplified format,
Then it is stored in the database in UTF-8 encoding mode.
2. create a table structure encoded with UTF-8. the importlanguage indicates the language version of the table.
However, in a specific version, search for the text of the version to display. Other text is not displayed.
Drop table if exists 'zz _ importer ';
Create table if not exists 'zz _ importer '(
'Importid' int (11) not null auto_increment,
'Importtime' date not null default '2017-00-00 ',
'Improtfile' varchar (100) not null default '',
'Importlanguage' varchar (100) not null default''
Primary key ('importid ')
) ENGINE = MyISAM default charset = uft-8;
3. simplified conversion to traditional Chinese.
Use php iconv. this process is valid for linux/unix and does not work for windows.
Iconv ("GB2312", "BIG5", $ text );
4. because, charset = "UTF-8", data is encoded in UTF-8 format,
When adding data, you must use en/gb/big5 to identify the language version.
Insert into 'zz _ importer 'VALUES (, '','', 'en ');
Insert into 'zz _ importer 'VALUES (, '','', 'GB ');
Insert into 'zz _ importer 'VALUES (, '','', 'big5 ');
B. Questions about user addition:
1. suppose in simplified Chinese. because the page header is UTF-8, the user's browser will be UTF-8 encoded
Browse the page.
2. the added database exists in UTF-8 format.
3. when adding data, use gb to identify the language version.
Insert into 'zz _ importer 'VALUES (, '','', 'GB ');
C. whether it is provided separately or converted to simplified or traditional Chinese
Provided separately-compliant with multi-language standards, with high flexibility and no special ISP requirements.
Conversion provision-the submission speed is affected, and the ISP must provide iconv function support.
3. Unified user access languages
A. assume that when you use the simplified Chinese version:
;
This applies to all language versions.
B. call the language/gb language pack.
C. search for data with a language field of gb in the database and display it
D. when the user submits the information, refer to the problem of database B in multiple languages above.