语言包使用
添加语言包文件
位置:/Ue/lang/语言.php 【自行创建】
命名: zh.php、en.php ,规则 : 语种.php
<?php
return [
'name'=>'文石PHP',
'title'=>'文石PHP - 星量PHP框架',
'keywords'=>'uephp,文石PHP,星量PHP框架,PHPMVC框架,轻量级PHP框架',
'description'=>'uephp框架主打轻量级,简单易入门,让新手更快的理解并使用MVC框架',
];
语言设置
使用 $this->setLang($langType) 全局函数可以设置使用的语种,如:
<?php
class indexController extends Mb{
public function index(){}
public function setLg(){
if(empty($this->gets[0])){exit;}
if(in_array($this->gets[0], array('zh', 'en'))){
$this->setLang($this->gets[0]);
header('location:/');
}
}
}
使用 lang($key) 函数获取语言
<?php
class indexController extends Mb{
public function index(){
$this->setLang('zh');
echo lang('title');
}
}