php-enspired/peekaboo

使用 ICU 的消息格式化工具,备用基本字符串模板。

v1.0 2024-03-14 22:35 UTC

This package is auto-updated.

Last update: 2024-09-14 23:56:10 UTC


README

   

peekaboo! (ICU)

peekaboo 提供使用 Unicode 国际组件进行消息格式化的工具,备用基本字符串模板。

依赖

需要 php 8.1 或更高版本。

ICU 支持 需要 intl 扩展。构建 ICU 资源包使用 genrb

安装

推荐安装方法是使用 Composer:只需 composer require php-enspired/peekaboo

入门

use at\peekaboo\ {
  HasMessages,
  MakesMessages
};

class Foo implements HasMessages {
  use MakesMessages;

  public const MESSAGES = [
    "welcome" => "welcome to the {place}, we've got fun and games"
  ];
}

echo (new Foo())->makeMessage("welcome", ["place" => "jungle"]);
// welcome to the jungle, we've got fun and games

文档

测试

使用 composer test:analyze 运行静态分析

使用 composer test:unit 运行单元测试

贡献或寻求帮助

我在 libera#php-enspired 的 IRC 上,或者在 github 上创建一个问题 (https://github.com/php-enspired/peekaboo/issues)。也欢迎反馈。