codecollab/i18n 问题修复 & 功能扩展

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

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

codecollab/i18n

最新稳定版本:1.0.1

Composer 安装命令:

composer require codecollab/i18n

包简介

Internationalization package of the CodeCollab project

README 文档

README

Internationalization package of the CodeCollab project

Build Status MIT License Latest Stable Version Total Downloads Latest Unstable Version

Requirements

PHP7+

Installation

Include the library in your project using composer:

{
    "require-dev": {
        "codecollab/i18n": "^1"
    }
}

Usage

This library uses simple php files containing an array of translations based on key/value pairs. The array should be named $texts.

The filename of the translations should be based on the language it targets, e.g. en_US.php. An simple example of translations in a file:

<?php

$texts = [
    'translation.title'        => 'Translation',
    'translation.description'  => 'This is an example translation.',
    'translation.variable.%'   => 'Copyright %d Some Company',
];

To use translations in your application first create an instance of the translation class by passing the directory in which the translation files are and the language to translate to:

<?php

$translator = new \CodeCollab\I18n\FileTranslator('/path/to/translations', 'en_US');

echo $translator->translate('translation.title'); // Translation
echo $translator->translate('translation.variable.%', [2015]); // Copyright 2015 Some Company

Exceptions

When a translation file could not be found a \CodeCollab\I18n\UnsupportedLanguageException will be thrown.

When loading a translation file it will be checked to ensure it has the correct format. if the file is not a valid translation file a \CodeCollab\I18n\InvalidFileException will be thrown.

Interface

When using translators in your application always hint against the \CodeCollab\I18n\Translator interface instead of the concrete implementation. This allows you to use different translation implementations later without having to change you classes.

Contributing

How to contribute

License

MIT

Security issues

If you found a security issue please contact directly by mail instead of using the issue tracker at codecollab-security@pieterhordijk.com

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: See
  • 更新时间: 2015-07-26