ThinkPHP learning notes (13) multi-template support and multi-language support first, multi-template support: you need to create a red folder and the corresponding action html template conf On The tpl. php // multi-template support: 'tmpl _ SWITCH_ON '= & gt; true, 'tmpl _ DETECT_THEME ThinkPHP learning notes (13) multi-template support and multi-language support
First, multi-template support:
You need to create a red folder and an html template for the corresponding action on the tpl.
Conf. php
// Supports multiple templates
'Tmpl _ SWITCH_ON '=> true,
'Tmpl _ DETECT_THEME '=> true,
Index.html
Template 1
Default
Multi-language support:
Confg. php
// Multi-language support // whether to enable multi-language support 'Lang _ SWITCH_ON '=> true, // write 'default _ Lang '=> 'zh-cn' according to the folder name under LANG, // The Automatic detection language 'Lang _ AUTO_DETECT' => true,
Create a corresponding folder language pack. all actions are named common. php in the public and different php files are named for different actions. for example, user. php
Common Code:
'Welcome ', 'lan' => 'English', 'usernamenull '=> 'username is Null',);?>
Set Language 1 in common
Design language Method 2: Set in Action and use the L function
// Set the language quickly // L ('demo', 'multilingual test ');
Reference and replace text on the page
Welcome:
Language:
Demo:
Simplified Chinese
English
Set the language used in the Model: ; A leading character must be added.
For example, set the prompt verification information in the model.
Protected $ _ validate = array (// add an internationalized array ('username', 'require ','
', 0, 0, 1), array ('username', 'checklen', 'invalid username length', 0, 'callback', 3), array ('password ', 'require ', 'username mandatory', 1), array ('repassword', 'require ', 'username mandatory', 1 ), array ('password', 'repassword', 'inconsistent password', 0, 'firm', 1), // array ('createip', 'address ', 'wrong email format ', 0, 'regex', 1 ),);