|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace HexMakina\kadro\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use HexMakina\LocalFS\Text\JSON; |
|
6
|
|
|
|
|
7
|
|
|
class Traduko extends \HexMakina\kadro\Controllers\ORM |
|
8
|
|
|
{ |
|
9
|
|
|
|
|
10
|
|
|
const JSON_FILENAME = 'user_interface_{LANGUAGE}.json'; |
|
11
|
|
|
|
|
12
|
|
|
public function authorize($permission = null): bool |
|
13
|
|
|
{ |
|
14
|
|
|
return parent::authorize('group_admin'); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
public function route_back($route_name = null, $route_params = []): string |
|
18
|
|
|
{ |
|
19
|
|
|
return $this->router()->hyp('traduko'); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function update_file($lang = 'fra') |
|
23
|
|
|
{ |
|
24
|
|
|
try { |
|
25
|
|
|
$locale_path = $this->get('settings.locale.directory_path') . '/' . $this->get('settings.locale.file_name'); |
|
26
|
|
|
self::create_file($locale_path, $lang); |
|
27
|
|
|
|
|
28
|
|
|
$this->logger()->nice($this->l('KADRO_SYSTEM_FILE_UPDATED')); |
|
29
|
|
|
} catch (\Exception $e) { |
|
30
|
|
|
$this->logger()->notice($this->l('KADRO_SYSTEM_FILE_UPDATED')); |
|
31
|
|
|
} |
|
32
|
|
|
$this->router()->hop('traduko'); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public static function create_file($locale_path, $lang) |
|
36
|
|
|
{ |
|
37
|
|
|
$res = Traduko::filter(['lang' => $lang]); |
|
|
|
|
|
|
38
|
|
|
$assoc = []; |
|
39
|
|
|
foreach ($res as $id => $trad) { |
|
40
|
|
|
if (!isset($assoc[$trad->kategorio])) { |
|
41
|
|
|
$assoc[$trad->kategorio] = []; |
|
42
|
|
|
} |
|
43
|
|
|
if (!isset($assoc[$trad->kategorio][$trad->sekcio])) { |
|
44
|
|
|
$assoc[$trad->kategorio][$trad->sekcio] = []; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
$assoc[$trad->kategorio][$trad->sekcio][$trad->referenco] = $trad->$lang; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
$file_path = str_replace('{LANGUAGE}', $lang, $locale_path); |
|
51
|
|
|
|
|
52
|
|
|
$file = new JSON($file_path, 'w+'); |
|
53
|
|
|
$file->set_content(JSON::from_php($assoc)); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public static function init($locale_path) |
|
57
|
|
|
{ |
|
58
|
|
|
$languages = array_keys(array_slice(Traduko::inspect(Traduko::table_name())->columns(), 4)); |
|
|
|
|
|
|
59
|
|
|
foreach ($languages as $l) { |
|
60
|
|
|
self::create_file($locale_path, $l); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
return $languages; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.