avalon/language 问题修复 & 功能扩展

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

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

avalon/language

Composer 安装命令:

composer require avalon/language

包简介

Avalon Language component.

README 文档

README

This package makes translating easy.

Installation

This package can be installed via composer:

composer require avalon/language

Usage

use Avalon\Language;

// Create a new translation
$myLanguage = new Language(function ($t) {
    $t->name    = 'My Language';
    $t->locale  = 'en_AU';

    // The index is what we use to fetch the string value
    $t->strings = [
        'my_string_index' => 'My String Value',
        'test_x' => 'Test {1}',
        'hello_x' => 'Hello {username}',
        'x_tickets' => "{plural:{0}, {{0} ticket|{0} tickets}}",
    ];
});

// Set our language as the current language to use by passing the `locale` value
Language::setCurrent('en_AU');

// Translate some stuff
Language::translate('my_string_index'); // => 'My String Value'
Language::translate('test_x', ['Hello']); // => 'Test Hello'
Language::translate('hello_x', ['username' => 'Admin']); // => 'Hello Admin'
Language::translate('x_tickets', [1]); // => '1 ticket'
Language::translate('x_tickets', [2]); // => 2 tickets'

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2015-02-15