MediaWiki master
LazyLocalizationContext.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Language;
22
30
32 private $instantiator;
33
34 private ?LocalizationContext $context = null;
35
36 public function __construct( callable $instantiator ) {
37 $this->instantiator = $instantiator;
38 }
39
40 private function resolve(): LocalizationContext {
41 if ( !$this->context ) {
42 $this->context = ( $this->instantiator )();
43 }
44
45 return $this->context;
46 }
47
48 public function getLanguageCode() {
49 return $this->resolve()->getLanguageCode();
50 }
51
52 public function msg( $key, ...$params ) {
53 return $this->resolve()->msg( $key, ...$params );
54 }
55}
array $params
The job parameters.
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81
Wrapper for injecting a LocalizationContext with lazy initialization.
msg( $key,... $params)
This is the method for getting translated interface messages.
getLanguageCode()
Returns the target language for UI localization.
Interface supporting message localization in MediaWiki.