1
0
This repository has been archived on 2023-11-30. You can view files and clone it, but cannot push or open issues or pull requests.
dtux__avion-poeme/gestion/genere_lang.php

114 lines
2.7 KiB
PHP
Raw Permalink Normal View History

<?php
2021-04-29 10:32:58 +02:00
require_once '../session_init.php';
require_once 'config.inc.php';
2021-05-31 12:27:51 +02:00
require_once 'fonctions.inc.php';
2021-04-29 10:32:58 +02:00
if ( isset($_GET["ok"] ))
{
2021-04-29 10:32:58 +02:00
$fisrt_line = false;
2021-06-17 18:35:51 +02:00
$fh = fopen("../lang/9mfo-traduction.csv", "r") or die( __FILE__ ." ligne: " . __LINE__ . " Can't open csv");
$fhIndex = fopen("../lang/lang.json", "w") or die( __FILE__ ." ligne: " . __LINE__ . " Can't open lang/lang.json");
2021-04-29 10:32:58 +02:00
fwrite($fhIndex, '{');
$first_line = true;
$first_column_line = true;
$first_object = true;
while( $line = fgets($fh))
{
2021-04-29 10:32:58 +02:00
echo $line . EOLH;
$first_column = true;
$table = explode('|', $line);
$i =0;
foreach ( $table as $column )
{
2021-03-24 08:26:10 +01:00
2021-04-29 10:32:58 +02:00
$column = trim($column, " \n\r\t\0\"" );
2021-04-29 10:32:58 +02:00
if ($first_line == true)
{
//echo "first_line =>";
if ( $first_column_line == true )
2021-03-24 08:26:10 +01:00
{
2021-04-29 10:32:58 +02:00
//echo "first_column";
$first_column_line = false;
2021-03-24 08:26:10 +01:00
}else
{
2021-04-29 10:32:58 +02:00
$index = explode("/",$column);
echo "opening ../lang/" . $index[0] . EOLH;
2021-06-17 18:35:51 +02:00
$fhl[++$i] = fopen("../lang/" . $index[0], "wb") or die( __FILE__ ." ligne: " . __LINE__ . " can't open lang/" . $index[0]);
2021-04-29 10:32:58 +02:00
fwrite($fhl[$i], '{');
if ( $first_column == true )
{
$first_column = false;
}else
{
fwrite($fhIndex, ",");
}
fwrite($fhIndex, '"' . $index[0] . '":"' . $index[1] . '"');
2021-03-24 08:26:10 +01:00
}
2021-04-29 10:32:58 +02:00
echo EOLH;
}else
{
2021-04-29 10:32:58 +02:00
if (!empty($fhIndex))
{
2021-04-29 10:32:58 +02:00
fwrite($fhIndex, '}');
fclose($fhIndex);
unset($fhIndex);
}
2021-04-29 10:32:58 +02:00
//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]);
2021-04-07 21:08:08 +02:00
2021-04-29 10:32:58 +02:00
}
echo EOLH;
}
2021-04-29 10:32:58 +02:00
//echo EOLH;
}
2021-04-29 10:32:58 +02:00
if ($first_line == false)
{
$first_object = false;
}
$first_line = false;
}
2021-04-29 10:32:58 +02:00
fclose($fh);
foreach( $fhl as $fhx)
{
2021-04-29 10:32:58 +02:00
fwrite($fhx, '}');
fclose($fhx);
}
2021-06-17 18:35:51 +02:00
$fh = fopen("../lang/lang.json","r") or die("Can't open ../lang/lang.json" . __FILE__ ." ligne: " . __LINE__);
2021-04-29 10:32:58 +02:00
$str = fgets($fh);
fclose($fh);
2021-06-17 18:35:51 +02:00
$langArray = json_decode( $str, true);
foreach ($langArray as $key => $value)
2021-04-29 10:32:58 +02:00
{
2021-06-17 18:35:51 +02:00
$lang = getLang($key, true);
if ( $lang != false )
2021-05-31 12:27:51 +02:00
{
2021-06-17 18:35:51 +02:00
print $key ." : ";
2021-05-31 12:27:51 +02:00
print json_last_error_msg() . EOLH;
}else
{
2021-06-17 18:35:51 +02:00
print __FILE__ ." ligne: " . __LINE__ . " erreur à l'ouverture du fichier";
2021-05-31 12:27:51 +02:00
}
}
}
?>