Перевод через trt(

This commit is contained in:
2020-08-17 07:20:11 +06:00
parent 643b6850df
commit d8ee87bd40
3 changed files with 116 additions and 31 deletions

View File

@ -153,6 +153,8 @@
}
//Функция для перевода текста без применения GetText
/*
закоментил так как есть в tools.php
function trt($text)
{
global $db,$lng,$Schema;
@ -182,12 +184,13 @@
$result=str_replace("_", " ", $text);
}
return $result;
}
}*/
//Перевод для строки в которой встречаются подстроки вида: trt('')
function parseGT($text)
{
$result='';
$pLen=4; //Длина преамбулы trt(
$cut=0;
$from = 0; // Позиция поиска для итерации
while (true)
@ -195,16 +198,17 @@
$pos1 = strpos($text, 'trt(', $from);
if($pos1 !== false)
{
$from = $pos1+3;
$from = $pos1+$pLen+1;
$pos2 = false;
if($text[$pos1+2] == '"') $pos2 = strpos($text, '")', $from);
if($text[$pos1+2] == '\'') $pos2 = strpos($text, '\')', $from);
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 );
$result.=trt(substr($text, $pos1+3, $pos2 - $pos1 - 3 ));
$toTranslate=substr($text, $pos1+$pLen+1, $pos2 - $pos1 - $pLen-1 );
$result.=trt($toTranslate);
$cut=$pos2+2;
$from = $pos2 + 2;
$from = $pos2 + $pLen;
}
}else break;
}