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
39 public function __construct( callable $instantiator ) {
40 $this->instantiator = $instantiator;
41 }
42
43 private function resolve(): LocalizationContext {
44 if ( !$this->context ) {
45 $this->context = ( $this->instantiator )();
46 }
47
48 return $this->context;
49 }
50
51 public function getLanguageCode() {
52 return $this->resolve()->getLanguageCode();
53 }
54
55 public function msg( $key, ...$params ) {
56 return $this->resolve()->msg( $key, ...$params );
57 }
58}
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.