2019-07-15 10:24:38 +00:00
|
|
|
<?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] ) ) {
|
2019-10-18 19:32:48 +00:00
|
|
|
$this->textFormatters[$langCode] = new TextFormatter( $langCode, new Converter() );
|
2019-07-15 10:24:38 +00:00
|
|
|
}
|
|
|
|
|
return $this->textFormatters[$langCode];
|
|
|
|
|
}
|
|
|
|
|
}
|