ThinkPHP uses the public language pack and the solution is ThinkPHP3.1.3. My project description: 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 under the app in the project root directory, and then in zh... "/> <scripttype =" text/javascript "sr
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 ')}