MediaWiki  master
PageLangLogFormatter.php
Go to the documentation of this file.
1 <?php
27 
34  protected function getMessageParameters() {
35  // Get the user language for displaying language names
36  $userLang = $this->context->getLanguage()->getCode();
37  $params = parent::getMessageParameters();
38 
39  // Get the language codes from log
40  $oldLang = $params[3];
41  $kOld = strrpos( $oldLang, '[' );
42  if ( $kOld ) {
43  $oldLang = substr( $oldLang, 0, $kOld );
44  }
45 
46  $newLang = $params[4];
47  $kNew = strrpos( $newLang, '[' );
48  if ( $kNew ) {
49  $newLang = substr( $newLang, 0, $kNew );
50  }
51 
52  // Convert language codes to names in user language
53  $languageNameUtils = MediaWikiServices::getInstance()->getLanguageNameUtils();
54  $logOld = $languageNameUtils->getLanguageName( $oldLang, $userLang )
55  . ' (' . $oldLang . ')';
56  $logNew = $languageNameUtils->getLanguageName( $newLang, $userLang )
57  . ' (' . $newLang . ')';
58 
59  // Add the default message to languages if required
60  $params[3] = !$kOld ? $logOld : $logOld . ' [' . $this->msg( 'default' ) . ']';
61  $params[4] = !$kNew ? $logNew : $logNew . ' [' . $this->msg( 'default' ) . ']';
62  return $params;
63  }
64 }
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:157
PageLangLogFormatter
This class formats language change log entries.
Definition: PageLangLogFormatter.php:33
PageLangLogFormatter\getMessageParameters
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
Definition: PageLangLogFormatter.php:34
LogFormatter
Implements the default log formatting.
Definition: LogFormatter.php:40
LogFormatter\msg
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
Definition: LogFormatter.php:775