Provides various official and user-released code examples. For more information, see onethink or THINKPHP loading public Language Pack notes.
Step 1: Add the following code to the project directory: Application/home/conf/config. php or Application/index/conf/config. php:
'Lang _ SWITCH_ON '=> true, // enable the Language Pack Function
'Lang _ AUTO_DETECT '=> true, // automatic language Detection
'Default _ lang' => 'zh-cn', // DEFAULT language
'Lang _ list' => 'en-us, zh-cn, zh-tw ', // a LIST of allowed languages must be written.
'Var _ language' => 'l', // default LANGUAGE switch variable
Part 2: Application/home/conf/tags. php or Application/index/conf/tags. php, add:
'App _ begin' => array ('common \ Behavior \ CheckLangBehavior '),
Part 3: copy the Behavior \ Checklangbehavior file in the Library in thinkphp to application/common/behavior. Note that this class file is changed to namespace Common \ Behavior;
Use Think \ Behavior;
Use Think \ Hook; very important: otherwise the class file cannot be FOUND and not found is displayed;
Part 4: Create the lang folder and the zh_cn.PHP file in application/index or home. The file is read by default: file:
Return array (
'Site _ title' => 'hangzhou xuemeng ',
'_ SITE_URL _' => 'HTTP: // www.hzxuanmeng.com /',
'Site _ qq' => '2014, 2397196338 James ',
Write in the controller:
Echo L ('_ SITE_URL _');
Or write: {: L ("SITE_QQ")} in the template file: miracle.
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB