professional-wiki/message-builder 问题修复 & 功能扩展

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

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

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

GitHub Workflow Status Type Coverage codecov Latest Stable Version Download count License

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 support
  • FallbackMessageBuilder - Fallback message builder that delegates to multiple message builders
  • MessageBuilderSpy - 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-json dependency.

Version 1.0.0 (2025-02-20)

  • Initial release with ArrayMessageBuilder, FallbackMessageBuilder, and MessageBuilderSpy implementations.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2025-02-20