zoukankan      html  css  js  c++  java
  • Yii2.0实现语言包切换功能

    在yii2.0高级模板框架中,以前台为例,首先  在前台frontend 下面建立  messages/zh-CN 
    在 messages文件夹中创建一个文件:  ①common.php                                                     
    如果是使用的后台目录,就在  backend/config/main.php 中添加如下的配置文件
    return  [
                         'language'=>'zh-CN',//选择中文语言包
            ......        
                             components =>[ 
                             'i18n'=>[
     'translations'=>[
                                  '*' =>[
                         'class'=>'yiii18nPhpMessageSource',
                         'fileMap'=>[
                                        'common'=>'common.php'
                                                               ]
                                                     ]
                               ]
    ]
                       ],
    ]
    添加language和i18n之后,基本上已经完成
     
    在common.php 中添加peizhi.png
     

    在说出页面展示即可

    main.png
         如果出现index.png
    就代表成功
  • 相关阅读:
    异常处理、网络编程
    内置函数、反射、__str__、__del__、元类
    tomcat 拒绝服务
    html标签
    google 与服务器搭建
    liunx centox ssh 配置
    java 泛型
    Windows Mysql安装
    java 空对象
    java 动态代理(类型信息)
  • 原文地址:https://www.cnblogs.com/liuzhen123/p/8059335.html
Copyright © 2011-2022 走看看