MediaWiki master
LazyLocalizationContext.php
Go to the documentation of this file.
1<?php
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 if ( !$this->context ) {
28 $this->context = ( $this->instantiator )();
29 }
30
31 return $this->context;
32 }
33
35 public function getLanguageCode() {
36 return $this->resolve()->getLanguageCode();
37 }
38
40 public function msg( $key, ...$params ) {
41 return $this->resolve()->msg( $key, ...$params );
42 }
43}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:69
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.