aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace/Language.php
blob: c8a018ef7260eb610888272f03d8528332ced532 (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
45
46
47
48
<?php
class Language {
	private $language = [];
	private $template = [];

	public function __construct($lang) {
		require ROOT."core/language/{$lang}.php";
		$this->language = $LANGUAGE;
	}

	public function loadLanguage($filename) {
		require $filename;
		$this->template = $LANGUAGE;
	}

	public function template($name, $params = FALSE) {
		if(isset($this->template[$name])) {
			if($params) {
				return vsprintf($this->template[$name], $params);
			}

			return $this->template[$name];
		}

		return "{{$name}}";
	}

	private function get($name, $params = FALSE) {
		if(isset($this->language[$name])) {
			if($params) {
				return vsprintf($this->language[$name], $params);
			}

			return $this->language[$name];
		}

		return "{{$name}}";
	}

	public function text($name, $params = FALSE) {
		return $this->get($name, $params);
	}

	public function set($name, $value) {
		return $this->language[$name] = $value;
	}
}
?>