Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Lib\LanguageNameLookup Class Reference

Service for looking up language names based on MediaWiki's Language class. More...

+ Collaboration diagram for Wikibase\Lib\LanguageNameLookup:

Public Member Functions

 __construct (LanguageNameUtils $languageNameUtils, MessageInLanguageProvider $messageInLanguageProvider, ?string $inLanguage)
 
 getName (string $languageCode)
 Get the name of a language in a general context.
 
 getNameForTerms (string $languageCode)
 Get the name of a language when it is used in a "terms" context (labels/descriptions/aliases).
 

Private Member Functions

 normalize (string $languageCode)
 

Private Attributes

LanguageNameUtils $languageNameUtils
 
MessageInLanguageProvider $messageInLanguageProvider
 
 $inLanguage
 

Detailed Description

Service for looking up language names based on MediaWiki's Language class.

Implementation note: wikibase.getLanguageNameByCode.js contains similar functionality in JS.

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\LanguageNameLookup::__construct ( LanguageNameUtils $languageNameUtils,
MessageInLanguageProvider $messageInLanguageProvider,
?string $inLanguage )
Parameters
LanguageNameUtils$languageNameUtils
MessageInLanguageProvider$messageInLanguageProvider
string | null$inLanguageLanguage code of the language in which to return the language names. Use LanguageNameUtils::AUTONYMS for autonyms (returns each language name in it's own language).

Member Function Documentation

◆ getName()

Wikibase\Lib\LanguageNameLookup::getName ( string $languageCode)

Get the name of a language in a general context.

If the language (code) is being used for terms (labels/descriptions/aliases), use self::getNameForTerms() instead. On the other hand, language codes from WikibaseContentLanguages::CONTEXT_MONOLINGUAL_TEXT, Site::getLanguageCode(), or other non-term contexts, should use this method.

◆ getNameForTerms()

Wikibase\Lib\LanguageNameLookup::getNameForTerms ( string $languageCode)

Get the name of a language when it is used in a "terms" context (labels/descriptions/aliases).

Use this method when the language code is related to WikibaseContentLanguages::CONTEXT_TERM or () WikibaseRepo::getTermsLanguages() / () WikibaseClient::getTermsLanguages().

The 'mul' language code has a special meaning for terms, and gets a distinct name in this context to communicate this meaning. For other language codes, this is equivalent to self::getName().

◆ normalize()

Wikibase\Lib\LanguageNameLookup::normalize ( string $languageCode)
private

Member Data Documentation

◆ $inLanguage

Wikibase\Lib\LanguageNameLookup::$inLanguage
private

◆ $languageNameUtils

LanguageNameUtils Wikibase\Lib\LanguageNameLookup::$languageNameUtils
private

◆ $messageInLanguageProvider

MessageInLanguageProvider Wikibase\Lib\LanguageNameLookup::$messageInLanguageProvider
private

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