MediaWiki master
TextFormatter.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Message;
4
7
11class TextFormatter implements ITextFormatter {
13 private $converter;
14
16 private $langCode;
17
19 private $format;
20
33 public function __construct(
34 string $langCode,
35 Converter $converter,
36 string $format = Message::FORMAT_TEXT
37 ) {
38 $this->langCode = $langCode;
39 $this->converter = $converter;
40 $this->format = $format;
41 }
42
43 public function getLangCode() {
44 return $this->langCode;
45 }
46
47 public function format( MessageValue $mv ) {
48 $message = $this->converter->convertMessageValue( $mv );
49 $message->inLanguage( $this->langCode );
50 return $message->toString( $this->format );
51 }
52}
Converter between Message and MessageValue.
Definition Converter.php:17
const FORMAT_TEXT
Transform {{..}} constructs but don't transform to HTML.
Definition Message.php:165
The MediaWiki-specific implementation of ITextFormatter.
getLangCode()
Get the internal language code in which format() is.
__construct(string $langCode, Converter $converter, string $format=Message::FORMAT_TEXT)
Construct a TextFormatter.
format(MessageValue $mv)
Convert a MessageValue to text.
Value object representing a message for i18n.