mirror of
https://github.com/torrentpier/torrentpier-lts.git
synced 2025-02-28 15:10:54 +03:00
Display source language if no user language variable (#113)
* Display source language if no user language variable * Fixes bug with dynamic language variables https://github.com/torrentpier/torrentpier/pull/430 * undefined language variables fix * Update sessions.php
This commit is contained in:
parent
0c3304594d
commit
147879df0e
@ -568,7 +568,7 @@ class user_common
|
||||
*/
|
||||
function init_userprefs ()
|
||||
{
|
||||
global $bb_cfg, $theme, $lang, $DeltaTime;
|
||||
global $bb_cfg, $theme, $source_lang, $DeltaTime;
|
||||
|
||||
if (defined('LANG_DIR')) return; // prevent multiple calling
|
||||
|
||||
@ -594,8 +594,17 @@ class user_common
|
||||
|
||||
if (!defined('LANG_DIR')) define('LANG_DIR', DEFAULT_LANG_DIR);
|
||||
|
||||
/** Temporary place source language to the global */
|
||||
$lang = array();
|
||||
require(ENGLISH_LANG_DIR .'main.php');
|
||||
$source_lang = $lang;
|
||||
unset($lang);
|
||||
|
||||
/** Place user language to the global */
|
||||
global $lang;
|
||||
require(LANG_DIR .'main.php');
|
||||
setlocale(LC_ALL, isset($bb_cfg['lang'][$this->data['user_lang']]['locale']) ? $bb_cfg['lang'][$this->data['user_lang']]['locale'] : 'en_US.UTF-8');
|
||||
$lang += $source_lang;
|
||||
|
||||
$theme = setup_style();
|
||||
$DeltaTime = new Date_Delta();
|
||||
|
@ -245,10 +245,11 @@ class Template
|
||||
{
|
||||
$this->cur_tpl = $filename;
|
||||
|
||||
global $lang, $bb_cfg, $user, $tr_cfg;
|
||||
global $lang, $source_lang, $bb_cfg, $user, $tr_cfg;
|
||||
|
||||
$L =& $lang;
|
||||
$V =& $this->vars;
|
||||
$SL =& $source_lang;
|
||||
|
||||
if ($filename)
|
||||
{
|
||||
@ -931,7 +932,7 @@ class Template
|
||||
$code = str_replace($search, $replace, $code);
|
||||
}
|
||||
// This will handle the remaining root-level varrefs
|
||||
$code = preg_replace('#\{(L_([a-z0-9\-_]+?))\}#i', '<?php echo isset($L[\'$2\']) ? $L[\'$2\'] : $V[\'$1\']; ?>', $code);
|
||||
$code = preg_replace('#\{(L_([a-z0-9\-_]+?))\}#i', '<?php echo isset($L[\'$2\']) ? $L[\'$2\'] : (isset($SL[\'$2\']) ? $SL[\'$2\'] : $V[\'$1\']); ?>', $code);
|
||||
$code = preg_replace('#\{(\$[a-z_][a-z0-9_$\->\'\"\.\[\]]*?)\}#i', '<?php echo isset($1) ? $1 : \'\'; ?>', $code);
|
||||
$code = preg_replace('#\{(\#([a-z_][a-z0-9_]*?))\}#i', '<?php echo defined(\'$2\') ? $2 : \'\'; ?>', $code);
|
||||
$code = preg_replace('#\{([a-z0-9\-_]+?)\}#i', '<?php echo isset($V[\'$1\']) ? $V[\'$1\'] : \'\'; ?>', $code);
|
||||
|
Loading…
Reference in New Issue
Block a user