Bearsampp 2026.7.11
Loading...
Searching...
No Matches
LangProc Class Reference

Public Member Functions

 __construct ()
 getCurrent ()
 getList ()
 getValue ($key)
 load ()

Private Attributes

 $current
 $raw

Detailed Description

Class LangProc

This class handles the language processing for the Bearsampp application. It loads language files, retrieves language settings, and provides language-specific values.

Definition at line 16 of file class.langproc.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

LangProc constructor.

Initializes the LangProc object and loads the language settings.

Definition at line 33 of file class.langproc.php.

34 {
35 $this->load();
36 }

References load().

Here is the call graph for this function:

Member Function Documentation

◆ getCurrent()

getCurrent ( )

Gets the current language being used.

Returns
string The current language.

Definition at line 65 of file class.langproc.php.

66 {
67 return $this->current;
68 }

References $current.

◆ getList()

getList ( )

Retrieves the list of available languages.

This method scans the language directory and returns a list of available language files.

Returns
array The list of available languages.

Definition at line 77 of file class.langproc.php.

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 }
$result
global $bearsamppCore
static getLangsPath($aetrayPath=false)
static endWith($string, $search)

References $bearsamppCore, $result, UtilString\endWith(), and Path\getLangsPath().

Here is the call graph for this function:

◆ getValue()

getValue ( $key)

Retrieves the value for a given language key.

This method returns the value associated with the specified key in the current language. If the key is not found, it logs an error and returns the key itself.

Parameters
string$keyThe language key to retrieve the value for.
Returns
string The value associated with the key, or the key itself if not found.

Definition at line 106 of file class.langproc.php.

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 }
global $bearsamppRoot
static getErrorLogFilePath($aetrayPath=false)

References $bearsamppRoot, and Path\getErrorLogFilePath().

Here is the call graph for this function:

◆ load()

load ( )

Loads the current language settings and data.

This method retrieves the default language from the configuration, checks if it is available, and then loads the corresponding language file.

Definition at line 44 of file class.langproc.php.

45 {
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 }
global $bearsamppConfig
Definition homepage.php:41

References $bearsamppConfig, $bearsamppCore, and Path\getLangsPath().

Referenced by __construct().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ $current

$current
private

Definition at line 21 of file class.langproc.php.

Referenced by getCurrent().

◆ $raw

$raw
private

Definition at line 26 of file class.langproc.php.


The documentation for this class was generated from the following file: