yii2中的语言包的使用,yii::t()方法
来源:互联网 发布:传感器数据采集软件 编辑:程序博客网 时间:2024/05/20 23:38
第一步,打开basic/messages/zh-CN/app.php文件
<?php/** * Created by PhpStorm. * User: funson * Date: 2014/10/25 * Time: 10:33 */return [ 'YES' => '是', 'NO' => '否',];
以键值对形式配置return内容
第二步,使用语言包
也就是我们标题中提到的yii::t()方法
Yii::t('app','YES');
这段代码就会输出 【是】
下面是t方法的官方解释
t() public methodstring t( $category, $message, $params = [], $language = null )$categorystringTranslates a message to the specified language.
This is a shortcut method of yii\i18n\I18N::translate().
The translation will be conducted according to the message category and the target language will be used.
You can add parameters to a translation message that will be substituted with the corresponding value after translation. The format for this is to use curly brackets around the parameter name as you can see in the following example:
$username = 'Alexander';
echo \Yii::t('app', 'Hello, {username}!', ['username' => $username]);Further formatting of message parameters is supported using the PHP intl extensions message formatter. Seeyii\i18n\I18N::translate() for more details.
The message category.
$messagestringThe message to be translated.
$paramsarrayThe parameters that will be used to replace the corresponding placeholders in the message.
$languagestringThe language code (e.g.
en-US
,en
). If this is null, the current application language will be used.return stringThe translated message
- yii2中的语言包的使用,yii::t()方法
- Yii2如何使用Yii:t()
- Yii-架构- 语言包的使用
- yii2 在yii里面使用php 的mongo函数
- Yii2学习笔记(一):Yii的安装和使用
- yii2高级模板安装和yii migrate的使用
- yii框架-yii2分页的使用与扩展(十五)
- yii2 高级框架无法使用yii命令的问题
- yii2高级模板安装和yii migrate的使用
- Yii2中的components的使用
- yii2使用cookie的方法
- Yii框架博客系统的语言包配置
- Yii中的findAll , findByAttributes和deleteAllByAttributes等方法的使用
- YII2.0的yii文件
- yii使用SESSION的方法
- yii使用cookie的方法
- YII使用ckeditor的方法
- YII2-数据库yii\db\Query 查询方法
- 原生矩阵操作类及方法
- 秒懂poly定理
- 修改xampp的mysql默认密码
- LeetCode#258 Add Digits
- iOS NSUserdefaults
- yii2中的语言包的使用,yii::t()方法
- Ubantu操作系统下搭建FTP服务器
- SQL与NoSQL(MongoDB)数据库的对应关系图表
- Android开发之SQLite插入数据优化
- 如何使用Android Studio把自己的Android library分享到jCenter和Maven Central
- 卡尔曼算法笔记---思想和实际应用物理含义的理解
- Bean named '*' must be of type [*], but was actually of type [com.sun.proxy.$Proxy34]
- WebView基本用法
- 软件版本号规范