ThinkPHP learning notes (13) multi-template and multi-language support

Source: Internet
Author: User
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 ),);


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.