Table of Contents
Overview of ThinkPHP multi-language support and multi-template support, thinkphp overview
How to achieve multi-language switching in thinkphp30
Thinkphp multi-language multi-template how to switch,
Home Backend Development PHP Tutorial Overview of ThinkPHP multi-language support and multi-template support, thinkphp overview_PHP tutorial

Overview of ThinkPHP multi-language support and multi-template support, thinkphp overview_PHP tutorial

Jul 13, 2016 am 10:20 AM
thinkphp multi-language support template

Overview of ThinkPHP multi-language support and multi-template support, thinkphp overview

This article briefly describes ThinkPHP’s multi-language support and multi-template support in the form of examples. It is a very important skill in ThinkPHP and is shared with everyone for your reference. The details are as follows:

1. ThinkPHP multi-language support:

Add in the config.php configuration file:

//多语言支持设置
'LANG_SWITCH_ON'=>true,
'DEFAULT_LANG'=>'zh-cn',
'LANG_AUTO_DETECT'=>true,
'LANG_LIST'=>'en-us,zh-cn,zh-tw',

Copy after login

Create three folders under the Home/Lang/ folder, namely zh-cn, en-us and zh-tw respectively representing Simplified Chinese, English and Traditional Chinese

Files corresponding to the template can be created in the

folder, or the public file common.php

zh-cn/common.php page is as follows:

<&#63;php
return array(
 'welcome'=>'你好',
 'lan'=>'简体中文', 
);
&#63;>

Copy after login

en-us/common.php page is as follows:

<&#63;php
return array(
 'welcome'=>'how are you fine&#63;',
 'lan'=>'english', 
);
&#63;>

Copy after login

zh-tw/common.php page is as follows:

<&#63;php
return array(
 'welcome'=>'你好',
 'lan'=>'簡體中文', 
);
&#63;>
Copy after login

The template index.php code is as follows:

欢迎:{$Think.lang.welcome} 语言:{$Think.lang.lan}
<a href="&#63;l=zh-cn" rel="external nofollow" >简体中文</a>
<a href="&#63;l=en-us" rel="external nofollow" >english</a>
<a href="&#63;l=zh-tw" rel="external nofollow" >繁體中文</a>

Copy after login

Or define it directly in the Action method: L('demo','test'); In this way, you can apply it directly in the template: {$Think.lang.demo}
For example, in the model: array('uname','require','user name required'); can be used like this: array('uname','require','%name');

2. ThinkPHP multiple template support:

Add in the config.php configuration file:

//多模板支持
 'TMPL_SWITCH_ON'=>true,
 'TMPL_DETECT_THEME'=>true,

Copy after login

Create other skin folders under /Home/Tpl/, such as the folder red, where the files are the same as those in the default file.

Add in the template file:

<a href="&#63;t=red" rel="external nofollow" >红</a>
<a href="&#63;t=default" rel="external nofollow" >默认</a>
Copy after login

I believe that the examples described in this article will be helpful to everyone’s ThinkPHP learning and development.

How to achieve multi-language switching in thinkphp30

return array(
'LANG_SWITCH_ON' => true,
'DEFAULT_LANG' => 'zh-cn', // Default language
'LANG_AUTO_DETECT' = > true, // Automatically detect language
'LANG_LIST'=>'en-us,zh-cn,zh-tw'//Must write the allowed language list
);
? >
Download the full version of thinkphp3.0 from the official thinkphp website. There are examples/lang and you might as well take a look
It’s hard to say, just look at the examples and you’ll understand

Thinkphp multi-language multi-template how to switch,

In general, just change the language pack. I think your English and Chinese templates are quite different.
A relatively simple way is to add the following code to index.php:
if (isset($_GET ['l'])) { $_GET['t'] = $_GET['l'];} Also remember to add the following configuration to the configuration file
'DEFAULT_THEME' => 'default','TMPL_DETECT_THEME ' => true, // Automatic detection template theme template switching example:
www.thinkphp.cn/extend/234.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/868244.htmlTechArticleOverview of ThinkPHP multi-language support and multi-template support, thinkphp overview This article briefly describes ThinkPHP's multi-language support in the form of examples With multiple template support. It is a very important skill in ThinkPHP, divided into...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

Does PyCharm Community Edition support enough plugins? Does PyCharm Community Edition support enough plugins? Feb 20, 2024 pm 04:42 PM

Does PyCharm Community Edition support enough plugins? Need specific code examples As the Python language becomes more and more widely used in the field of software development, PyCharm, as a professional Python integrated development environment (IDE), is favored by developers. PyCharm is divided into two versions: professional version and community version. The community version is provided for free, but its plug-in support is limited compared to the professional version. So the question is, does PyCharm Community Edition support enough plug-ins? This article will use specific code examples to

Which one is better, laravel or thinkphp? Which one is better, laravel or thinkphp? Apr 09, 2024 pm 03:18 PM

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

How to install thinkphp How to install thinkphp Apr 09, 2024 pm 05:42 PM

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

Pros and Cons Analysis: A closer look at the pros and cons of open source software Pros and Cons Analysis: A closer look at the pros and cons of open source software Feb 23, 2024 pm 11:00 PM

Pros and cons of open source software: Understanding the pros and cons of open source projects requires specific code examples In today’s digital age, open source software is getting more and more attention and respect. As a software development model based on the spirit of cooperation and sharing, open source software is widely used in different fields. However, despite the many advantages of open source software, there are also some challenges and limitations. This article will delve into the pros and cons of open source software and demonstrate the pros and cons of open source projects through specific code examples. 1. Advantages of open source software 1.1 Openness and transparency Open source software

How to add PPT mask How to add PPT mask Mar 20, 2024 pm 12:28 PM

Regarding PPT masking, many people must be unfamiliar with it. Most people do not understand it thoroughly when making PPT, but just make it up to make what they like. Therefore, many people do not know what PPT masking means, nor do they understand it. I know what this mask does, and I don’t even know that it can make the picture less monotonous. Friends who want to learn, come and learn, and add some PPT masks to your PPT pictures. Make it less monotonous. So, how to add a PPT mask? Please read below. 1. First we open PPT, select a blank picture, then right-click [Set Background Format] and select a solid color. 2. Click [Insert], word art, enter the word 3. Click [Insert], click [Shape]

See all articles