Thinkphp two ways to make Chinese and English websites
One, add the language script in the website program, set up the whole station automatic translation.
Second, create a new template on the original page, edit the site in the new page,
Advantages and Disadvantages :
one: advantages ..... It is not necessary to add content articles, do not design database language classification, production time is short, one time to add the whole station translation. Disadvantages......... Translation scripts may not be translated correctly, the details of the differences may affect the Site page layout, and can not be customized changes, low degree of free editing.
Second: the advantages ...... Can customize the content of the translation page, the page differences freely modified, high-freedom editing. Disadvantages........ Add content Trouble, Chinese and English content to add a copy, the database to design a language classification identification.
Production process:
A: I also refer to the Baidu Manual copy down (specific also depends on personal operation)
1. Under application/common/conf/new tags.php (default is not, need to create a new) file, add the following:
The 1 return Array (2 ' app_begin ' = = Array (' Behavior\checklangbehavior '),//indicates the multi-language detection behavior at the App_begin label location. 3 );
2. Add the following in the application/common/conf/config.php configuration file:
1 ' lang_switch_on ' + true, //Turn on Language Pack feature 2 ' Lang_auto_detect ' + true,//Auto Detect language Active after multilingual function 3 ' Lang_ List ' = ' zh-cn,en-us ',//allow switching of language lists with comma-delimited 4 ' var_language ' = ' l ',//default language toggle Variable
3. Create a new lang file under application/common/.
4. Create a new en-us.php file under application/common/lang/and add the following:
1 return Array (2 ' welcome ' = ' I am 中文版 ', 3 );
5. Create a new zh-cn.php file under application/common/lang/and add the following:
1 return Array (2 ' welcome ' = ' I am Chinese ', 3 );
6. Then make a reference in the corresponding template file, e.g. {$Think. Lang.welcome}
7. Set up a hyperlink in English and Chinese, as follows:
<a href= "? l=zh-cn" > Simplified Chinese </a> | <a href= "? l=en-us" >English</a>
Two: This is my own based on the design of the site.
1: According to your own website design database add a language field identifier in the required table (article),
2: In the background to add the article can be selected in English
3:home Module Add a controller (EnglishController.class.php) view Add a folder (English) Copy the Chinese page and modify the header and content.
4: In the Controller method, obtain the article information to add a judgment Is_lang = 0 (IndexController.class.php); Is-lang = 1 (EnglishController.class.php);
5: Finally set the link jump on the front end jump in the English option.
6: This is a more foolish approach, but very practical, familiar with the development of the time is also very fast, I hope to be useful to you, I am also a rookie, the great God has better and more convenient features more powerful @ me, this is my third blog, is the most serious, I hope in the future there will be more better technology to share with you
thinkphp Chinese and English website detailed