forked from projectsend/projectsend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlanguage.php
58 lines (53 loc) · 1.49 KB
/
language.php
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
<?php
use ProjectSend\Classes\I18n;
/**
* Load the i18n class and the corresponding language files
*/
/**
* Current system language defined in the configuration file
* Loaded language falls back to this value if neither of the
* following 2 options is valid.
*
* @see sys.config.sample.php
*/
if ( !defined( 'SITE_LANG' ) ) {
define( 'SITE_LANG', 'en' );
}
$lang = SITE_LANG;
$default_domain = 'cftp_admin';
/**
* If a user selected a language on the log in form, use it
*/
if ( isset( $_SESSION['lang'] ) ) {
$lang_sess = $_SESSION['lang'];
$lang_file = ROOT_DIR . DS . 'lang' . DS . $lang_sess . '.mo';
if ( file_exists( $lang_file ) ) {
$lang = $lang_sess;
}
}
/**
* If not, check if the admin selected the option to use
* the browser's language (if available)
*/
else {
$options_object = new \ProjectSend\Classes\Options;
$browser_lang = $options_object->getOption('use_browser_lang');
if ( !empty($browser_lang) ) {
switch ( $browser_lang ) {
case '0':
default:
break;
case '1':
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$browser_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
$lang_file = ROOT_DIR . DS . 'lang' . DS . $browser_lang . '.mo';
if ( file_exists( $lang_file ) ) {
$lang = $browser_lang;
}
}
break;
}
}
}
define('LOADED_LANG', $lang);
I18n::LoadDomain(ROOT_DIR.DS."lang".DS."{$lang}.mo", 'cftp_admin' );