ThinkPHP public Language Pack Problems and Solutions

Source: Internet
Author: User

ThinkPHP public Language Pack Problems and Solutions
I am using ThinkPHP3.1.3. My projects


Note: Because my projects are grouped, we now use the Admin group to create a Language Pack as an example.

First, create a new zh-cn folder for Lang under the app under the project root directory, create an Admin group under the zh-cn folder, and create a user. php In the Admin folder. The Language Pack definition can be found below


 

Write the language information in user. php as follows:

Return array (

'Site _ title' => '24 youth ',

'Site _ url' => 'HTTP: // jahan.sinaapp.com /',

'Site _ keyword' => 'php thinkphp ',

.................

);

Next, configure in config. php (the configuration information file of your project ).

Return array (

'Lang _ AUTO_DETECT '=> FALSE, // disable automatic language detection. You can enable this function in multiple languages.

'Lang _ SWITCH_ON '=> TRUE, // enable the Language Pack function, which must be enabled

'Default _ LANG '=> 'zh-cn', // zh-cn folder name/lang/zh-cn/common. php

);

Add the code in the project tags. php (usually in the Conf directory, if not, you can create it yourself) as follows:

Return array (

'App _ begin' => array (

'Checklang ',

),

);

Before the app runs, it loads the configuration file and calls the CheckLang method. When I run the project, I find that an error has occurred. The error message is "Class 'checklangbehavior 'not found".

Because the 'checklangbehavior 'class is not found, we can download a full TP version and find CheckLangBehavior. class. php, as shown below:

 


Put this class in the Extend directory of the project, or in the Lib directory. In this way, you can use custom language packs.

Language Pack call:

If it is called in Action, the format is L ('site _ name ')

If it is called in the template file, the format is {: L ('site _ name ')}

 
 

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.