Notes on loading public language packs for onethink or THINKPHP

Source: Internet
Author: User
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

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.