MediaWiki REL1_37
TextFormatter.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Message;
4
5use Message;
8
12class TextFormatter implements ITextFormatter {
14 private $converter;
15
17 private $langCode;
18
20 private $format;
21
34 public function __construct(
35 string $langCode,
38 ) {
39 $this->langCode = $langCode;
40 $this->converter = $converter;
41 $this->format = $format;
42 }
43
44 public function getLangCode() {
45 return $this->langCode;
46 }
47
48 public function format( MessageValue $mv ) {
49 $message = $this->converter->convertMessageValue( $mv );
50 $message->inLanguage( $this->langCode );
51 return $message->toString( $this->format );
52 }
53}
Converter between Message and MessageValue.
Definition Converter.php:18
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.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:138
const FORMAT_TEXT
Transform {{..}} constructs but don't transform to HTML.
Definition Message.php:146
Value object representing a message for i18n.