PocketMine-MP 5.39.2 git-7ad037014ecec1ddc7a9bba215beb03e659ea931
Loading...
Searching...
No Matches
pocketmine\lang\Language Class Reference
+ Collaboration diagram for pocketmine\lang\Language:

Public Member Functions

 __construct (string $lang, ?string $path=null, string $fallback=self::FALLBACK_LANGUAGE)
 
 get (string $id)
 
 getAll ()
 
 getLang ()
 
 getName ()
 
 translate (Translatable $c)
 
 translateString (string $str, array $params=[], ?string $onlyPrefix=null, int &$untranslatedParameterCount=0)
 

Static Public Member Functions

static getLanguageList (string $path="")
 

Public Attributes

const FALLBACK_LANGUAGE = "eng"
 

Protected Member Functions

 internalGet (string $id)
 
 parseTranslation (string $text, ?string $onlyPrefix=null, int &$parameterCount=0)
 

Static Protected Member Functions

static loadLang (string $path, string $languageCode)
 

Protected Attributes

array $fallbackLang = []
 
array $lang = []
 
string $langName
 

Detailed Description

Definition at line 49 of file Language.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\lang\Language::__construct ( string $lang,
?string $path = null,
string $fallback = self::FALLBACK_LANGUAGE )
Exceptions
LanguageNotFoundException

Definition at line 108 of file Language.php.

Member Function Documentation

◆ get()

pocketmine\lang\Language::get ( string $id)

Definition at line 195 of file Language.php.

◆ getAll()

pocketmine\lang\Language::getAll ( )
Returns
string[] @phpstan-return array<string, string>

Definition at line 203 of file Language.php.

◆ getLang()

pocketmine\lang\Language::getLang ( )

Definition at line 123 of file Language.php.

◆ getLanguageList()

static pocketmine\lang\Language::getLanguageList ( string $path = "")
static
Returns
string[] @phpstan-return array<string, string>
Exceptions
LanguageNotFoundException

Definition at line 59 of file Language.php.

◆ getName()

pocketmine\lang\Language::getName ( )

Definition at line 119 of file Language.php.

◆ internalGet()

pocketmine\lang\Language::internalGet ( string $id)
protected

Definition at line 191 of file Language.php.

◆ loadLang()

static pocketmine\lang\Language::loadLang ( string $path,
string $languageCode )
staticprotected
Returns
string[] @phpstan-return array<string, string>

Definition at line 131 of file Language.php.

◆ parseTranslation()

pocketmine\lang\Language::parseTranslation ( string $text,
?string $onlyPrefix = null,
int & $parameterCount = 0 )
protected

Replaces translation keys embedded inside a string with their raw values. Embedded translation keys must be prefixed by a "%" character.

This is used to allow the "text" field of a Translatable to contain formatting (e.g. colour codes) and multiple embedded translation keys.

Normal translations whose "text" is just a single translation key don't need to use this method, and can be processed via get() directly.

Parameters
string | null$onlyPrefixIf non-null, only translation keys with this prefix will be replaced. This is used to allow a client to do its own translating of vanilla strings.

Definition at line 235 of file Language.php.

◆ translate()

pocketmine\lang\Language::translate ( Translatable $c)

Definition at line 177 of file Language.php.

◆ translateString()

pocketmine\lang\Language::translateString ( string $str,
array $params = [],
?string $onlyPrefix = null,
int & $untranslatedParameterCount = 0 )
Parameters
(float|int|string|Translatable)[]$params

Definition at line 156 of file Language.php.

Member Data Documentation

◆ $fallbackLang

array pocketmine\lang\Language::$fallbackLang = []
protected

Definition at line 103 of file Language.php.

◆ $lang

array pocketmine\lang\Language::$lang = []
protected

Definition at line 98 of file Language.php.

◆ $langName

string pocketmine\lang\Language::$langName
protected

Definition at line 93 of file Language.php.

◆ FALLBACK_LANGUAGE

const pocketmine\lang\Language::FALLBACK_LANGUAGE = "eng"

Definition at line 51 of file Language.php.


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