Bearsampp
2026.7.11
Toggle main menu visibility
Loading...
Searching...
No Matches
class.langproc.php
Go to the documentation of this file.
1
<?php
2
/*
3
* Copyright (c) 2021-2024 Bearsampp
4
* License: GNU General Public License version 3 or later; see LICENSE.txt
5
* Author: Bear
6
* Website: https://bearsampp.com
7
* Github: https://github.com/Bearsampp
8
*/
9
16
class
LangProc
17
{
21
private
$current
;
22
26
private
$raw
;
27
33
public
function
__construct
()
34
{
35
$this->
load
();
36
}
37
44
public
function
load
()
45
{
46
global
$bearsamppCore
,
$bearsamppConfig
;
47
$this->raw =
null
;
48
49
$this->current =
$bearsamppConfig
->getLang();
50
$langPath =
Path::getLangsPath
() .
'/'
. $this->current .
'.lang'
;
51
52
if
(file_exists($langPath)) {
53
$this->raw = parse_ini_file($langPath);
54
}
else
{
55
$this->current =
$bearsamppConfig
->getDefaultLang();
56
$this->raw = parse_ini_file(
Path::getLangsPath
() .
'/'
. $this->current .
'.lang'
);
57
}
58
}
59
65
public
function
getCurrent
()
66
{
67
return
$this->current
;
68
}
69
77
public
function
getList
()
78
{
79
global
$bearsamppCore
;
80
$result
= array();
81
82
$handle = @opendir(
Path::getLangsPath
());
83
if
(!$handle) {
84
return
$result
;
85
}
86
87
while
(
false
!== ($file = readdir($handle))) {
88
if
($file !=
"."
&& $file !=
".."
&&
UtilString::endWith
($file,
'.lang'
)) {
89
$result
[] = str_replace(
'.lang'
,
''
, $file);
90
}
91
}
92
93
closedir($handle);
94
return
$result
;
95
}
96
106
public
function
getValue
($key)
107
{
108
global
$bearsamppRoot
;
109
110
if
(!isset($this->raw[$key])) {
111
$content =
'['
. date(
'Y-m-d H:i:s'
, time()) .
'] '
;
112
$content .=
'ERROR: Lang var missing '
. $key;
113
$content .=
' for '
. $this->current .
' language.'
. PHP_EOL;
114
file_put_contents(
Path::getErrorLogFilePath
(), $content, FILE_APPEND);
115
return
$key;
116
}
117
118
// Special chars not handled by Aestan Tray Menu
119
$replace = array(
"ő"
,
"Ő"
,
"ű"
,
"Ű"
);
120
$with = array(
"o"
,
"O"
,
"u"
,
"U"
);
121
122
return
str_replace($replace, $with, $this->raw[$key]);
123
}
124
}
$result
$result
Definition
ajax.apache.php:19
$bearsamppRoot
global $bearsamppRoot
Definition
ajax.apache.php:16
$bearsamppCore
global $bearsamppCore
Definition
ajax.latestversion.php:24
LangProc
Definition
class.langproc.php:17
LangProc\__construct
__construct()
Definition
class.langproc.php:33
LangProc\$current
$current
Definition
class.langproc.php:21
LangProc\load
load()
Definition
class.langproc.php:44
LangProc\getList
getList()
Definition
class.langproc.php:77
LangProc\getValue
getValue($key)
Definition
class.langproc.php:106
LangProc\$raw
$raw
Definition
class.langproc.php:26
LangProc\getCurrent
getCurrent()
Definition
class.langproc.php:65
Path\getLangsPath
static getLangsPath($aetrayPath=false)
Definition
class.path.php:560
Path\getErrorLogFilePath
static getErrorLogFilePath($aetrayPath=false)
Definition
class.path.php:439
UtilString\endWith
static endWith($string, $search)
Definition
class.util.string.php:70
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:41
sandbox
core
classes
class.langproc.php
Generated by
1.17.0