How does thinkphp support multiple languages? The manual is not very clear. Thinkphp3.2.3
Web: http://www.kancloud.cn/manual/thinkphp/1874
However, I directly output L () in the controller. I can only adapt to the ThinkPHP core directory-> the language files in Lang. I want to add the Lang language files in the module, but use L () the parameter name is printed directly. how can this problem be solved?
Reply to discussion (solution)
What you said in the connection is clear.
How did you do it?
I use 3.1, but it should not be much worse.
1. Add Related configurations to config. php in the application configuration directory.
'Lang _ SWITCH_ON '=> true, // enable the language pack function
'Lang _ AUTO_DETECT '=> false, // automatic language detection
'Default _ lang' => 'Ja ', // DEFAULT Language
'Lang _ list' => 'zh-cn, en-us, jar', // a list of allowed languages must be written.
'Var _ language' => 'Lang ', // Default LANGUAGE switch variable
2. create the tags. php file in the application configuration directory and add the following content:
Return array (
// Add the following line of definition.
// 'App _ begin' => array ('behavior \ CheckLang '),
// If version 3.2.1 is required
'App _ begin' => array ('behavior \ CheckLangBehavior '),
);
3. create a Lang folder in the common directory and add a new language pack file.
Set variables, for example:
Return array (
'Operation _ fail '=> 'Operation failed ',
'Operation _ success '=> 'Operation successful ',
);
Read variable:
1. read from the controller: L ('Operation _ fail ')
2. read in model: {% operation_fail}
3. read from the template: {: L ('Operation _ fail ')}
Oh, I understand. it turns out to be my 'app _ begin' => array ('behavior \ CheckLangBehavior '). This is written in config. php and should be written in tags. php. thank you.