We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2e465d8 commit 37abd10Copy full SHA for 37abd10
1 file changed
App/Models/Lang.php
@@ -0,0 +1,36 @@
1
+<?php
2
+
3
+namespace Monster\App\Models;
4
5
+class Lang
6
+{
7
+ private $language;
8
+ private $langData;
9
10
+ public function __construct($language = "en")
11
+ {
12
+ $this->language = $language;
13
+ $this->loadLanguageData();
14
+ }
15
16
+ public function loadLanguageData()
17
18
+ $langFile = __DIR__ . '/../../routes/lang/' . $this->language . '.php';
19
+ if (file_exists($langFile)) {
20
+ $this->langData = include $langFile;
21
+ } else {
22
+ throw new \Exception("Language file not found for {$this->language}");
23
24
25
26
+ public function get($key, $variables = [])
27
28
+ $value = $this->langData[$key] ?? $key;
29
30
+ foreach ($variables as $variable => $replacement) {
31
+ $value = str_replace(':' . $variable, $replacement, $value);
32
33
34
+ return $value;
35
36
+}
0 commit comments