An injectable service interface for message formatting, somewhat narrowed compared to Message. Only the text format is implemented in this framework so far, with getTextFormatter() returning a formatter that converts to the text format. Other formatters could be added to MessageFormatterFactory. Bug: T226598 Change-Id: Id053074c1dbcb692e8309fdca602f94a385bca0c
29 lines
763 B
PHP
29 lines
763 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Message;
|
|
|
|
use Wikimedia\Message\IMessageFormatterFactory;
|
|
use Wikimedia\Message\ITextFormatter;
|
|
|
|
/**
|
|
* The MediaWiki-specific implementation of IMessageFormatterFactory
|
|
*/
|
|
class MessageFormatterFactory implements IMessageFormatterFactory {
|
|
private $textFormatters = [];
|
|
|
|
/**
|
|
* Required parameters may be added to this function without deprecation.
|
|
* External callers should use MediaWikiServices::getMessageFormatterFactory().
|
|
*
|
|
* @internal
|
|
*/
|
|
public function __construct() {
|
|
}
|
|
|
|
public function getTextFormatter( $langCode ): ITextFormatter {
|
|
if ( !isset( $this->textFormatters[$langCode] ) ) {
|
|
$this->textFormatters[$langCode] = new TextFormatter( $langCode );
|
|
}
|
|
return $this->textFormatters[$langCode];
|
|
}
|
|
}
|