PocketMine-MP
5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
Translatable.php
1
<?php
2
3
/*
4
*
5
* ____ _ _ __ __ _ __ __ ____
6
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10
*
11
* This program is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU Lesser General Public License as published by
13
* the Free Software Foundation, either version 3 of the License, or
14
* (at your option) any later version.
15
*
16
* @author PocketMine Team
17
* @link http://www.pocketmine.net/
18
*
19
*
20
*/
21
22
declare(strict_types=1);
23
24
namespace
pocketmine\lang;
25
26
use
pocketmine\utils\Utils
;
27
28
final
class
Translatable
{
30
protected
array $params = [];
31
35
public
function
__construct
(
36
protected
string
$text,
37
array $params = []
38
){
39
foreach
(Utils::promoteKeys($params) as $k => $param){
40
if
(!($param instanceof
Translatable
)){
41
$this->params[$k] = (string) $param;
42
}
else
{
43
$this->params[$k] = $param;
44
}
45
}
46
}
47
48
public
function
getText() : string{
49
return $this->text;
50
}
51
55
public
function
getParameters
() : array{
56
return $this->params;
57
}
58
59
public
function
getParameter(
int
|
string
$i) :
Translatable
|string|null{
60
return $this->params[$i] ?? null;
61
}
62
63
public
function
format(
string
$before,
string
$after) : self{
64
return new self(
"$before%$this->text$after"
, $this->params);
65
}
66
67
public
function
prefix(
string
$prefix) : self{
68
return new self(
"$prefix%$this->text"
, $this->params);
69
}
70
71
public
function
postfix(
string
$postfix) : self{
72
return new self(
"%$this->text"
. $postfix);
73
}
74
}
pocketmine\lang\Translatable
Definition
Translatable.php:28
pocketmine\lang\Translatable\__construct
__construct(protected string $text, array $params=[])
Definition
Translatable.php:35
pocketmine\lang\Translatable\getParameters
getParameters()
Definition
Translatable.php:55
pocketmine\utils\Utils
Definition
Utils.php:105
src
lang
Translatable.php
Generated by
1.12.0