blob: a2facb08bf24cac8b95eb8a0e8df757e2450188a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
<?php
class Language {
private $code = '';
private $text = [];
public function __construct($code) {
$this->code = $code;
}
#===============================================================================
# Return the language code
#===============================================================================
public function getCode() {
return $this->code;
}
#===============================================================================
# Load another language file
#===============================================================================
public function load($filename) {
if(file_exists($filename) AND is_readable($filename)) {
require $filename;
$this->text = array_merge($this->text, $LANGUAGE ?? []);
}
}
#===============================================================================
# Set language string
#===============================================================================
public function set($name, $value) {
return $this->text[$name] = $value;
}
#===============================================================================
# Return language string with included arguments
#===============================================================================
public function text($name, $arguments = NULL): string {
if(!isset($this->text[$name])) {
return "{{$name}}";
}
return vsprintf($this->text[$name], (array) $arguments);
}
}
|