trt
This commit is contained in:
@ -10,13 +10,14 @@ function getScript($path)
|
||||
return '';
|
||||
}
|
||||
|
||||
//Функция для перевода текста без применения GetText
|
||||
//Функция для перевода текста без применения GetText "trt("
|
||||
function trt($text)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$result='';
|
||||
$sql='select translation from main._translations where del=false and language_id=(select id from main._languages where short_name=\''.$_SESSION["LNG"].'\') and identifier=\''.$text.'\';';
|
||||
$sql='select translation from main._translations where del=false and language_id='.$_SESSION["LNG"].' and identifier=\''.$text.'\';';
|
||||
//$sql='select translation from main._translations where del=false and language_id=(select id from main._languages where short_name=\''.$_SESSION["LNG"].'\') and identifier=\''.$text.'\';';
|
||||
$res = NULL;
|
||||
try
|
||||
{
|
||||
@ -38,6 +39,62 @@ function trt($text)
|
||||
return $result;
|
||||
}
|
||||
|
||||
//Перевод для строки в которой встречаются подстроки вида: trt('')
|
||||
function trts($text)
|
||||
{
|
||||
$result='';
|
||||
$pLen=4; //Длина преамбулы trt(
|
||||
$cut=0;
|
||||
$from = 0; // Позиция поиска для итерации
|
||||
while (true)
|
||||
{
|
||||
$pos1 = strpos($text, 'trt(', $from);
|
||||
if($pos1 !== false)
|
||||
{
|
||||
$from = $pos1+$pLen+1;
|
||||
$pos2 = false;
|
||||
if($text[$pos1+$pLen] == '"') $pos2 = strpos($text, '")', $from);
|
||||
if($text[$pos1+$pLen] == '\'') $pos2 = strpos($text, '\')', $from);
|
||||
if($pos2 !== false)
|
||||
{
|
||||
$result.=substr($text, $cut, $pos1 - $cut );
|
||||
$toTranslate=substr($text, $pos1+$pLen+1, $pos2 - $pos1 - $pLen-1 );
|
||||
$result.=trt($toTranslate);
|
||||
$cut=$pos2+2;
|
||||
$from = $pos2 + $pLen;
|
||||
}
|
||||
}else break;
|
||||
}
|
||||
$result.=substr($text, $cut); //Копируем остатки
|
||||
return $result;
|
||||
}
|
||||
|
||||
//Выбираю из текста ${конкретные} слова для перевода
|
||||
function trs($text)
|
||||
{
|
||||
$pos1=0;
|
||||
while(true)
|
||||
{
|
||||
$pos1 = strpos($text, '${',$pos1);
|
||||
if($pos1 !== false)
|
||||
{
|
||||
$pos2 = strpos($text, '}', $pos1);
|
||||
if($pos1 !== false)
|
||||
{
|
||||
$sub=substr($text,$pos1+2,$pos2-$pos1-2);
|
||||
$text=substr($text,0, $pos1).trt($sub).substr($text,$pos2+1);
|
||||
}else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
//Получить разрешения для текущего пользователя
|
||||
function getAccess($key)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user