changed translations textfile export/import format
This commit is contained in:
@ -672,12 +672,14 @@ function xmlimport3()
|
|||||||
$tpl->redirect('translate.php?translang=' . $translang);
|
$tpl->redirect('translate.php?translang=' . $translang);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2012-08-24 following - changed output format from tab-separated lines to multiple lines
|
||||||
|
// for better readability, and delimiter from *nix \n to canonical \r\n
|
||||||
function textexport($translang, $all)
|
function textexport($translang, $all)
|
||||||
{
|
{
|
||||||
global $opt;
|
global $opt;
|
||||||
|
|
||||||
header('Content-type:application/octet-stream');
|
header('Content-type: text/plain');
|
||||||
header('Content-Disposition:attachment;filename="translation.txt"');
|
header('Content-Disposition: attachment; filename="translation.txt"');
|
||||||
|
|
||||||
$rs = sql("SELECT `id`, `text` FROM `sys_trans` ORDER BY `id` ASC");
|
$rs = sql("SELECT `id`, `text` FROM `sys_trans` ORDER BY `id` ASC");
|
||||||
while ($r = sql_fetch_assoc($rs))
|
while ($r = sql_fetch_assoc($rs))
|
||||||
@ -686,9 +688,10 @@ function textexport($translang, $all)
|
|||||||
if (($all) || (mb_strlen($translated)==0))
|
if (($all) || (mb_strlen($translated)==0))
|
||||||
{
|
{
|
||||||
$thisline = $r['text'];
|
$thisline = $r['text'];
|
||||||
$thisline .= "\t";
|
$thisline .= "\r\n";
|
||||||
$thisline .= $translated;
|
$thisline .= $translated;
|
||||||
$thisline .= "\n";
|
$thisline .= "\r\n";
|
||||||
|
$thisline .= "\r\n";
|
||||||
echo($thisline);
|
echo($thisline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -697,6 +700,7 @@ function textexport($translang, $all)
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2012-08-24 following - changed input format from tab-separated lines to multiple lines
|
||||||
function textimport($lang)
|
function textimport($lang)
|
||||||
{
|
{
|
||||||
global $translate, $tpl, $opt;
|
global $translate, $tpl, $opt;
|
||||||
@ -717,15 +721,12 @@ function textimport($lang)
|
|||||||
*/
|
*/
|
||||||
$saTexts = array();
|
$saTexts = array();
|
||||||
|
|
||||||
for ($i=0;$i<count($lines);$i++)
|
for ($i=0; $i+1 < count($lines); $i += 3)
|
||||||
{
|
{
|
||||||
$cols = explode("\t", $lines[$i]); //create array separate by new line
|
$sCodeText = trim($lines[$i]);
|
||||||
|
$sLangText = trim($lines[$i+1]);
|
||||||
|
|
||||||
$sCodeText = $cols[0];
|
if ($sCodeText . $sLangText != '')
|
||||||
if (mb_strlen($sCodeText)>0)
|
|
||||||
{
|
|
||||||
$sLangText = $cols[1];
|
|
||||||
if (mb_strlen($sLangText)>0)
|
|
||||||
{
|
{
|
||||||
$transId = sql_value("SELECT `id` FROM `sys_trans` WHERE `text`='&1'", 0, $sCodeText);
|
$transId = sql_value("SELECT `id` FROM `sys_trans` WHERE `text`='&1'", 0, $sCodeText);
|
||||||
if ($transId == 0)
|
if ($transId == 0)
|
||||||
@ -768,7 +769,6 @@ echo($saTexts[$sCodeText]);
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$tpl->assign('texts', $saTexts);
|
$tpl->assign('texts', $saTexts);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user