v1
This commit is contained in:
@ -1,93 +1,105 @@
|
||||
<?php
|
||||
|
||||
require_once '../session_init.php';
|
||||
require_once 'config.inc.php';
|
||||
|
||||
$fisrt_line = false;
|
||||
$fh = fopen("../lang/9mfo-traduction.csv", "r") or die("Can't open csv");
|
||||
$fhIndex = fopen("../lang/lang.json", "w") or die("Can't open lang/lang.json");
|
||||
fwrite($fhIndex, '{');
|
||||
$first_line = true;
|
||||
$first_column_line = true;
|
||||
$first_object = true;
|
||||
while( $line = fgets($fh))
|
||||
if ( isset($_GET["ok"] ))
|
||||
{
|
||||
echo $line . EOLH;
|
||||
$first_column = true;
|
||||
$table = explode('|', $line);
|
||||
$i =0;
|
||||
foreach ( $table as $column )
|
||||
$fisrt_line = false;
|
||||
$fh = fopen("../lang/9mfo-traduction.csv", "r") or die("Can't open csv");
|
||||
$fhIndex = fopen("../lang/lang.json", "w") or die("Can't open lang/lang.json");
|
||||
fwrite($fhIndex, '{');
|
||||
$first_line = true;
|
||||
$first_column_line = true;
|
||||
$first_object = true;
|
||||
while( $line = fgets($fh))
|
||||
{
|
||||
|
||||
$column = trim($column, " \n\r\t\0\"" );
|
||||
|
||||
if ($first_line == true)
|
||||
echo $line . EOLH;
|
||||
$first_column = true;
|
||||
$table = explode('|', $line);
|
||||
$i =0;
|
||||
foreach ( $table as $column )
|
||||
{
|
||||
//echo "first_line =>";
|
||||
if ( $first_column_line == true )
|
||||
|
||||
$column = trim($column, " \n\r\t\0\"" );
|
||||
|
||||
if ($first_line == true)
|
||||
{
|
||||
//echo "first_column";
|
||||
$first_column_line = false;
|
||||
//echo "first_line =>";
|
||||
if ( $first_column_line == true )
|
||||
{
|
||||
//echo "first_column";
|
||||
$first_column_line = false;
|
||||
}else
|
||||
{
|
||||
|
||||
$index = explode("/",$column);
|
||||
echo "opening ../lang/" . $index[0] . EOLH;
|
||||
$fhl[++$i] = fopen("../lang/" . $index[0], "wb") or die("can't open lang/" . $index[0]);
|
||||
fwrite($fhl[$i], '{');
|
||||
if ( $first_column == true )
|
||||
{
|
||||
$first_column = false;
|
||||
}else
|
||||
{
|
||||
fwrite($fhIndex, ",");
|
||||
}
|
||||
fwrite($fhIndex, '"' . $index[0] . '":"' . $index[1] . '"');
|
||||
}
|
||||
echo EOLH;
|
||||
}else
|
||||
{
|
||||
|
||||
$index = explode("/",$column);
|
||||
echo "opening ../lang/" . $index[0] . EOLH;
|
||||
|
||||
$fhl[++$i] = fopen("../lang/" . $index[0], "wb") or die("can't open lang/" . $index[0]);
|
||||
fwrite($fhl[$i], '{');
|
||||
if (!empty($fhIndex))
|
||||
{
|
||||
fwrite($fhIndex, '}');
|
||||
fclose($fhIndex);
|
||||
unset($fhIndex);
|
||||
}
|
||||
//echo "not first_line =>";
|
||||
if ( $first_column == true )
|
||||
{
|
||||
$first_column = false;
|
||||
$index = $column;
|
||||
//echo "first_column = ". $index . "=>";
|
||||
}else
|
||||
{
|
||||
fwrite($fhIndex, ",");
|
||||
}
|
||||
fwrite($fhIndex, '"' . $index[0] . '":"' . $index[1] . '"');
|
||||
}
|
||||
echo EOLH;
|
||||
}else
|
||||
{
|
||||
if (!empty($fhIndex))
|
||||
{
|
||||
fwrite($fhIndex, '}');
|
||||
fclose($fhIndex);
|
||||
unset($fhIndex);
|
||||
}
|
||||
//echo "not first_line =>";
|
||||
if ( $first_column == true )
|
||||
{
|
||||
$first_column = false;
|
||||
$index = $column;
|
||||
//echo "first_column = ". $index . "=>";
|
||||
}else
|
||||
{
|
||||
$i++;
|
||||
if ($first_object == false) // insère la virgule
|
||||
{
|
||||
//echo "not first_object =>";
|
||||
fwrite($fhl[$i], ", ");
|
||||
}
|
||||
$text = '"' . $index . '":"' . $column .'"';
|
||||
fwrite($fhl[$i], $text ); //écrit l'objet json
|
||||
echo "writing ***" . $text .'***' . EOLH;
|
||||
fflush($fhl[$i]);
|
||||
$i++;
|
||||
if ($first_object == false) // insère la virgule
|
||||
{
|
||||
//echo "not first_object =>";
|
||||
fwrite($fhl[$i], ", ");
|
||||
}
|
||||
$text = '"' . $index . '":"' . $column .'"';
|
||||
fwrite($fhl[$i], $text ); //écrit l'objet json
|
||||
echo "writing ***" . $text .'***' . EOLH;
|
||||
fflush($fhl[$i]);
|
||||
|
||||
}
|
||||
echo EOLH;
|
||||
}
|
||||
echo EOLH;
|
||||
//echo EOLH;
|
||||
}
|
||||
//echo EOLH;
|
||||
if ($first_line == false)
|
||||
{
|
||||
$first_object = false;
|
||||
}
|
||||
$first_line = false;
|
||||
}
|
||||
if ($first_line == false)
|
||||
fclose($fh);
|
||||
foreach( $fhl as $fhx)
|
||||
{
|
||||
$first_object = false;
|
||||
fwrite($fhx, '}');
|
||||
fclose($fhx);
|
||||
}
|
||||
$fh = fopen("lang/lang.json","r");
|
||||
$str = fgets($fh);
|
||||
fclose($fh);
|
||||
$lang = json_decode( $str, true);
|
||||
foreach ($lang as $key => $value)
|
||||
{
|
||||
getLang( $key );
|
||||
print $key;
|
||||
print json_last_error_msg() .EOL;
|
||||
}
|
||||
$first_line = false;
|
||||
}
|
||||
fclose($fh);
|
||||
foreach( $fhl as $fhx)
|
||||
{
|
||||
fwrite($fhx, '}');
|
||||
fclose($fhx);
|
||||
}
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user