blob: fe185ebea197061c8ff2c5b89af9a87f46ce89d6 (
plain) (
blame)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<?php
namespace Zotlabs\Module;
use App;
use Zotlabs\Lib\Apps;
use Zotlabs\Web\Controller;
class Lang extends Controller {
const MYP = 'ZIN';
const VERSION = '2.0.0';
function post() {
$re = [];
$isajax = is_ajax();
$eol = $isajax ? "\n" : EOL;
if (! Apps::system_app_installed(local_channel(), 'Language')) {
$re['msg'] = 'ZIN0202E, ' . t('Language App') . ' (' . t('Not Installed') . ')' ;
notice( $re['msg'] . EOL);
if ($isajax) {
echo json_encode( $re );
killme();
exit;
} else {
return;
}
}
$lc = x($_POST['zinlc']) && preg_match('/^\?\?|[a-z]{2,2}[x_\-]{0,1}[a-zA-Z]{0,2}$/', $_POST['zinlc'])
? $_POST['zinlc'] : '';
$lcs= x($_POST['zinlcs']) && preg_match('/^[a-z,_\-]{0,191}$/', $_POST['zinlcs'])
? $_POST['zinlcs'] : '';
if ($isajax) {
if ($lc == '??') {
$re['lc'] = get_best_language();
$re['lcs'] = language_list();
} else {
$re['lc'] = $lc;
$re['alc'] = App::$language;
$re['slc'] = $_SESSION['language'];
$_SESSION['language'] = $lc;
App::$language = $lc;
load_translation_table($lc, true);
}
echo json_encode( $re );
killme();
exit;
}
}
function get() {
if(local_channel()) {
if(! Apps::system_app_installed(local_channel(), 'Language')) {
//Do not display any associated widgets at this point
App::$pdl = '';
$papp = Apps::get_papp('Language');
return Apps::app_render($papp, 'module');
}
}
nav_set_selected('Language');
return lang_selector();
}
}
|