tp5多語言開啟

2021-08-21 14:17:51 字數 1279 閱讀 9153

在config.php中配置檔案

// 是否開啟多語言

'lang_switch_on'         => true,

'lang_list'              => ['zh-cn','en-us'],

'default_filter'         => '',

'lang_auto_detect'       => true,

'var_language'          => 'lang',  // 預設語言切換變數

// 預設全域性過濾方法 用逗號分隔多個

'default_filter'         => '',

// 預設語言

在html中

change language:

請求控制器:

建構函式中:

//多語言

if(!(cookie::has('think_var')))

$this->assign('think_lang',cookie::get('think_var'));

//語言切換

public function lang()

}在語言包裡lang/en-us.php中

<?php

return [

"heander_lang"=>"heander_lang",

"heander_lang_cht"=>"heander_lang_cht",

"heander_lang_en"=>"english",

'name'=>'english name',

];最後替換d:\www\picture\thinkphp\library\think\lang.php檔案的detect方法 

TP5 多語言設計,並且美化URL

花了兩小時來研究tp5的語言載入,終於有點頭緒,並不需要在配置中配置 lang switch on 1 用 think lang load 來載入語言 2 為了美化 url 在路由中配置路由,比如我這配置了兩個,為了測試使用 route get cn index index index route ...

軟體多語言

locale是指特定於某個國家或地區的一組設定,包括字符集,數字 貨幣 時間和日期的格式等。在windows中,每個locale可以用乙個32位數字表示,記作lcid。在winnt.h中可以看到lcid的組成。它的高16位表示字元的排序方法,一般為0。在它的低16位中,低10位是primary la...

多語言切換

專案中應用到了多語言切換,鞏固一下。貼上 大家一起學習。廢話不多說直接上 1 新增多語言 在res values 下預設有個strings,需要多種語言就來建立幾個strings,values右鍵 new 乙個 values res file file name 就是strings director...