The framework's underlying language pack is located at:ThinkPHP/Lang/zh-cn.php 可以参考如何编写语言文件
First step: Configure the relevant options for multilingual support in the configuration file under project directory take my path for example is application\common\conf\config.php
The configuration is as follows: ' lang_switch_on ' = + true,//turn on the Language pack feature
' Lang_auto_detect ' = true,//auto-detect language
' Default_lang ' = ' zh-cn ',//default language
' Lang_list ' = ' en-us,zh-cn,zh-tw ',//must write a list of allowed languages
' Var_language ' = ' l ',//default language toggle Variable
Second step: To enable multi-lingual features, you need to configure the turn on multilingual behavior, in the application (application) configuration directory (conf) (that is, under the Application\common\conf\ folder), manually create a behavior definition file tags.php
The contents are as follows: <?php
Return Array (
Add the following line definition
' App_begin ' = = Array (' Behavior\checklangbehavior '),
);
The third step: Specific language Pack file naming and location as follows
Take my project as an example apply a language pack in application\common\ create a folder lang\ create a language file. php
For example, the Chinese language pack is:Application/Common/Lang/zh-cn.php 应用公共语言包
Fourth step: Get the corresponding language value from the language file
The controller can be directly removed with L (' key '), for example:
The contents of the language pack file are as follows: <?php
Return Array (
' Lan_define ' = ' welcome ',
);
The controller gets the following:
$value =l (' lan_define ');
$this->assign (' value ', $value);
$this->display ();
In the template: {$value}
You can also get it directly from the template: {$Think. Lang.lan_define}
thinkphp Multi-language support how to configure and deploy