定制 ez-php/i18n 二次开发

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

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

ez-php/i18n

Composer 安装命令:

composer require ez-php/i18n

包简介

Internationalisation module for the ez-php framework — file-based translations with dot-notation keys and locale fallback

README 文档

README

Internationalisation module for the ez-php framework — file-based translations with dot-notation keys and locale fallback.

CI

Requirements

  • PHP 8.5+
  • ez-php/framework 0.*

Installation

composer require ez-php/i18n

Setup

Register the service provider:

$app->register(\EzPhp\I18n\TranslatorServiceProvider::class);

Add translation files under lang/{locale}/:

lang/
  en/
    messages.php   → ['welcome' => 'Welcome, :name!']
  de/
    messages.php   → ['welcome' => 'Willkommen, :name!']

Usage

$translator = $app->make(\EzPhp\I18n\Translator::class);

echo $translator->get('messages.welcome', ['name' => 'Alice']);
// Welcome, Alice!

$translator->setLocale('de');
echo $translator->get('messages.welcome', ['name' => 'Alice']);
// Willkommen, Alice!

Locale formatting

LocaleFormatter wraps PHP's ext-intl extension to format numbers, currencies, and dates in a locale-aware way:

use EzPhp\I18n\LocaleFormatter;

$fmt = new LocaleFormatter('de_DE');

echo $fmt->number(1234567.89);         // '1.234.567,89'
echo $fmt->currency(9.99, 'EUR');      // '9,99 €'
echo $fmt->date(new \DateTimeImmutable('2024-06-15')); // '15.06.2024'
echo $fmt->dateTime(new \DateTimeImmutable('2024-06-15 14:30:00')); // '15.06.2024, 14:30:00'

Requires PHP's ext-intl extension.

License

MIT — Andreas Uretschnig

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固