kuainiu/yii2-i18n-js 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kuainiu/yii2-i18n-js

最新稳定版本:3.0.0

Composer 安装命令:

composer require kuainiu/yii2-i18n-js

包简介

README 文档

README

Installation

composer require kuainiu/yii2-i18n-js
  1. Add this to your application configuration:
<?php

return [
    // ...
    'components' => [
        // ...
        'i18nJs' => [
            'class' => 'kuainiu\yii2\I18nJs',
        ],
        // ...
    ],
    // ...
];
  1. Initialize the component anywhere, for example in @app/views/layouts/main.php:
Yii::$app->i18nJs;

Note, you do not need to register the component in the places that will be processed with AJAX-requests (for example, in @app/config/web.php -> bootstrap, on afterRequest, etc), because it will be loaded twice, and it makes no sense.

Usage

window.addEventListener('DOMContentLoaded', function () {
  console.log(yii.t('app', 'Hello'));
  console.log(yii.t('app', 'Hello, World!'));
  console.log(yii.t('app', 'Hello, {username}!', {username: 'John'}));
  console.log(yii.t('app', 'Hello, {0}!', ['John']));
  console.log(yii.t('app', 'Hello, {0} {1}!', ['John', 'Doe']));
  console.log(yii.t('app', 'Hello, {0} {1}!', ['John', 'Doe'], 'en-US'));
});

统计信息

  • 总下载量: 2.16k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-24