定制 koded/i18n 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

koded/i18n

Composer 安装命令:

composer require koded/i18n

包简介

Simple internationalization library with support for .po and .php translation files

README 文档

README

CI Latest Stable Version Minimum PHP Version: 8.1

A simple internationalization library with support for .po and .php translation files.

composer require koded/i18n

Requirements

  • intl
  • gettext

Usage

__(string $message, array $arguments => [], string $locale = '');

Configuration

The I18n class is static and should be configured somewhere in the beginning of your PHP code/script.

use Koded\Stdlib\Config;
use Koded\I18n\{ArrayCatalog, DefaultFormatter, I18n, I18nCatalog};

// all conf directives are optional
$config = new Config([
    'translation.catalog' => ArrayCatalog::class,
    'translation.formatter' => DefaultFormatter::class,
    'translation.dir' => '/path/to/your/translation/files',
    'translation.locale' => ['mk_MK', 'de_DE', 'it_IT'],
]);

I18n::register(I18nCatalog::new($config));

Translation files

.po files

poedit is a very good app to work with your translation files.

.php files

The translation file has a simple structure

return [
    'language' => '',
    'messages' => [
        // your translation strings goes here
        'original string' => 'translated string',
    ]
];

where messages contains key => value pairs for the translated strings.

Code quality

Code Coverage Scrutinizer Code Quality

vendor/bin/phpunit

License

Software license

The code is distributed under the terms of The 3-Clause BSD license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2022-01-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固