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 ')}