professional-wiki/message-builder
最新稳定版本:1.0.1
Composer 安装命令:
composer require professional-wiki/message-builder
包简介
Mini message localization library with MessageBuilder interface and implementations
README 文档
README
Message Builder is a small message localization library for PHP.
This library was extracted from the EDTF library. It can be used together with TranslateWiki, though does not depend on it.
MessageBuilder interface
interface MessageBuilder { /** * @throws UnknownMessageKey */ public function buildMessage( string $messageKey, string ...$arguments ): string; }
Usage
$messageBuilder = new ArrayMessageBuilder( [ 'hello-something' => 'Hello, $1!', 'multi-argument-example' => 'foo $2 $1 bar $3', 'plural-example' => 'You have $1 {{plural:$1|item|items}} in your cart.', ] ); function someCode( MessageBuilder $messageBuilder ) { // Returns 'Hello, world!' $messageBuilder->getMessage( 'hello-something', [ 'world' ] ); }
For a real world usage example, see the EDTF library.
Implementations
ArrayMessageBuilder- In-memory message builder with PLURAL keyword supportFallbackMessageBuilder- Fallback message builder that delegates to multiple message buildersMessageBuilderSpy- Message builder that records all messages built for testing
Development
Start by installing the project dependencies by executing
composer install
You can run test and static analysis via Make. See Makefile for available commands. If you do not have Make, you can run the commands listed in the Makefile manually.
To run all checks run by the GitHub Actions CI, simply run make.
Release notes
Version 1.0.1 (2025-02-21)
- Removed superfluous
ext-jsondependency.
Version 1.0.0 (2025-02-20)
- Initial release with
ArrayMessageBuilder,FallbackMessageBuilder, andMessageBuilderSpyimplementations.
统计信息
- 总下载量: 2.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2025-02-20