MediaWiki master
LazyLocalizationContext.php
Go to the documentation of this file.
1<?php
6
7namespace MediaWiki\Language;
8
16
18 private $instantiator;
19
20 private ?LocalizationContext $context = null;
21
22 public function __construct( callable $instantiator ) {
23 $this->instantiator = $instantiator;
24 }
25
26 private function resolve(): LocalizationContext {
27 $this->context ??= ( $this->instantiator )();
28 // @phan-suppress-next-line PhanTypeMismatchReturnNullable
29 return $this->context;
30 }
31
33 public function getLanguageCode() {
34 return $this->resolve()->getLanguageCode();
35 }
36
38 public function msg( $key, ...$params ) {
39 return $this->resolve()->msg( $key, ...$params );
40 }
41}
Wrapper for injecting a LocalizationContext with lazy initialization.
msg( $key,... $params)
This is the method for getting translated interface messages.https://www.mediawiki....
getLanguageCode()
Returns the target language for UI localization.Bcp47Code
Interface supporting message localization in MediaWiki.