How does thinkphp support multiple languages? The manual is not very clear.

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

Related Article

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.