MediaWiki master
MediaWiki\Language\SimpleLocalizationContext Class Reference

An implementation of LocalizationContext that implements only the methods defined in the interface. More...

Inherits MediaWiki\Language\LocalizationContext.

Collaboration diagram for MediaWiki\Language\SimpleLocalizationContext:

Public Member Functions

 __construct (private readonly MessageLocalizer $messageLocalizer, private readonly Bcp47Code $language,)
 
 getLanguageCode ()
 Returns the target language for UI localization.
Returns
Bcp47Code

 
 msg ( $key,... $params)
 This is the method for getting translated interface messages.
See also
https://www.mediawiki.org/wiki/Manual:Messages_API
Message::__construct
Parameters
string | string[] | MessageSpecifier$keyMessage key, or array of keys, or a MessageSpecifier.
MessageParam|MessageSpecifier|string|int|float|list<MessageParam|MessageSpecifier|string|int|float>...$params See Message::params()
Returns
Message

 

Detailed Description

An implementation of LocalizationContext that implements only the methods defined in the interface.

Intended for use where you don't have access to a LocalizationContext but have access to a Bcp47Code and MessageLocalizer.

Callers should usually ensure the languages are the same for the Bcp47Code and the MessageLocalizer.

Stability: newable
Since
1.47

Definition at line 24 of file SimpleLocalizationContext.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Language\SimpleLocalizationContext::__construct ( private readonly MessageLocalizer $messageLocalizer,
private readonly Bcp47Code $language )

Definition at line 26 of file SimpleLocalizationContext.php.

Member Function Documentation

◆ getLanguageCode()

MediaWiki\Language\SimpleLocalizationContext::getLanguageCode ( )

Returns the target language for UI localization.

Returns
Bcp47Code

Implements MediaWiki\Language\LocalizationContext.

Definition at line 33 of file SimpleLocalizationContext.php.

◆ msg()

MediaWiki\Language\SimpleLocalizationContext::msg ( $key,
$params )

This is the method for getting translated interface messages.

See also
https://www.mediawiki.org/wiki/Manual:Messages_API
Message::__construct
Parameters
string | string[] | MessageSpecifier$keyMessage key, or array of keys, or a MessageSpecifier.
MessageParam|MessageSpecifier|string|int|float|list<MessageParam|MessageSpecifier|string|int|float>...$params See Message::params()
Returns
Message

Implements MediaWiki\Language\MessageLocalizer.

Definition at line 38 of file SimpleLocalizationContext.php.


The documentation for this class was generated from the following file: