| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Message; |
| 4 |
|
| 5 |
use Wikimedia\Message\IMessageFormatterFactory; |
| 6 |
use Wikimedia\Message\ITextFormatter; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
class MessageFormatterFactory implements IMessageFormatterFactory { |
| 12 |
|
| 13 |
|
| 14 |
private $format; |
| 15 |
|
| 16 |
|
| 17 |
private $textFormatters = []; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public function __construct( string $format = Message::FORMAT_TEXT ) { |
| 27 |
$this->format = $format; |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public function getTextFormatter( $langCode ): ITextFormatter { |
| 34 |
if ( !isset( $this->textFormatters[$langCode] ) ) { |
| 35 |
$this->textFormatters[$langCode] = new TextFormatter( |
| 36 |
$langCode, $this->format ); |
| 37 |
} |
| 38 |
return $this->textFormatters[$langCode]; |
| 39 |
} |
| 40 |
} |