thinkphp Study Notes (13) multi-template support and multi-language support

Source: Internet
Author: User
thinkphp Study Notes (13) multi-template support and multi-language support

The first is multi-template support:

You need to create a new red folder and the corresponding action HTML template above the TPL

conf.php
Multi-Template Support
' Tmpl_switch_on ' =>true,
' Tmpl_detect_theme ' =>true,

Index.html

Template One

Default


Multi-lingual Support:

confg.php

Multi-language support//whether to open multi-lingual support ' lang_switch_on ' =>true,//under the folder name to write ' Default_lang ' + ' ZH-CN ',//automatic detection language ' lang_auto_ DETECT ' =>true,

Create the corresponding folder language pack, all action public named common.php, for different action named different PHP files; for example user.php

Common code:

 
  ' Welcome ', ' lan ' = ' 中文版 ', ' usernamenull ' = ' username ' is null ', '; >

Set Language mode one in common

Design Language Method Two: Set in action, using the L function

        Quick Setup Language//        L (' demo ', ' Multi-language test ');

referencing and replacing text on a page

Welcome:
 
  
Language:
Demo
Chinese Simplified
中文版

Set how languages are used in model: ; need to add a leader character

For example, set prompt validation information in model

protected $_validate=array (//Add internationalized Array (' username ', ' require ', ', '
 
   , 0,0,1) in the model, array (' username ', ' Checklen ', ' username length not valid ', 0, ' callback ', 3 ', Array (' Password ', ' require ', ' username required ', 0,0,1), Array (' Repassword ', ' require ', ' Username Required ', 0,0,1 ', Array (' Password ', ' repassword ', ' password inconsistent ', 0, ' confirm ', 1),//array (' Createip ', ' email ', ' mailbox format not ', 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.