Commit d49ce171 authored by Aria Givi's avatar Aria Givi
Browse files

LanguageFile zu Languagedata umbenannt, Hilfsmethoden hinzugefügt,...

LanguageFile zu Languagedata umbenannt, Hilfsmethoden hinzugefügt, createSynopticEditPage weiter ausgebaut
parent 1a206db4
......@@ -3,7 +3,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\LanguageFile;
use App\Models\LanguageData;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
......@@ -88,12 +88,11 @@ class LanguageController extends Controller
$langTexts[$dir] += count($this->getValues([$key => $value]));
}
$filePath[basename($filename)] = preg_replace("/lang\/.*?\//si", "lang/$to/", substr($filename, strpos($filename, "lang")));
}
}
}
die();
$langs = [];
$fn = "";
$t = [];
......@@ -101,6 +100,8 @@ class LanguageController extends Controller
if ($exclude !== "") {
try {
$ex = unserialize(base64_decode($exclude));
// var_dump($ex);
// die();
} catch (\ErrorException $e) {
$ex = ['files' => [], 'new' => 0];
}
......@@ -144,78 +145,50 @@ class LanguageController extends Controller
}
}
//die();
$t = $this->htmlEscape($t, $to);
$t = $this->createHints($t, $to);
return view('languages.edit')
->with('texts', $t)
->with('filename', $fn)
->with('title', trans('titles.languages.edit'))
->with('langs', $langs)
->with('to', $to)
->with('langTexts', $langTexts)
->with('sum', $sum)
->with('new', $ex["new"])
->with('email', $email);
->with('texts', $t) //Array mit vorhandenen Übersetzungen der Datei $fn in beiden Sprachen
->with('filename', $fn) //Pfad zur angezeigten Datei
->with('title', trans('titles.languages.edit'))
->with('langs', $langs) //Ausgangssprache (1 Element)
->with('to', $to) //zu bearbeitende Sprache
->with('langTexts', $langTexts) //Anzahl der vorhandenen Übersetzungen
->with('sum', $sum) //Alle vorhandenen Texte (in allen Dateien) in beiden Sprachen in einem Array
->with('new', $ex["new"]) //
->with('email', $email); //Email-Adresse des Benutzers
}
public function createSynopticEditPage(Request $request, $exclude = "")
{
$languageFilePath = resource_path() . "/lang/";
$languageFolders = scandir($languageFilePath); #relativer Pfad
$languageFolders = scandir($languageFilePath);
#Enthält zu jeder Sprache ein Objekt mit allen Daten
$languageFiles = [];
#Zusammensetzen zu absolutem Pfad
#Erstelle LanguageData-Objekte
foreach ($languageFolders as $folder) {
if (is_dir($languageFilePath . $folder) && $folder !== "." && $folder !== "..") {
$languageFiles[$folder] = new LanguageFile($languageFilePath.$folder);
$languageFiles[$folder] = new LanguageData($folder, $languageFilePath.$folder);
}
}
foreach ($languageFiles as $folderName => $languageFile) {
}
/*
$texts = [];
$langTexts = [];
$sum = [];
$filePath = [];
foreach ($dirs as $dir) {
# Wir überprüfen nun für jede Datei die Anzahl der vorhandenen Übersetzungen
$di = new RecursiveDirectoryIterator($languageFilePath . $dir);
$langTexts[$dir] = 0;
foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
//var_dump($filename." - ".$file."<br>");
if (!$this->endsWith($filename, ".")) {
#Speichere Daten in LanguageData-Objekten
foreach ($languageFiles as $folder => $languageData) {
$di = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($languageData->filePath));
foreach($di as $filename => $file) {
if(!$this->endsWith($filename, ".")) {
$tmp = include $filename;
foreach ($tmp as $key => $value) {
var_dump($key." - ".$value."<br>");
$sum = array_merge($sum, $this->getValues([$key => $value], basename($filename)));
$texts[basename($filename)][$key][$dir] = $value;
$langTexts[$dir] += count($this->getValues([$key => $value]));
$languageData->saveData(basename($filename), $key, $value);
}
//$filePath[basename($filename)] = preg_replace("/lang\/.*?\//si", "lang/$to/", substr($filename, strpos($filename, "lang")));
}
}
}*/
die();
/* foreach($texts as $a => $text) {
foreach($text as $b => $k) {
foreach($k as $c => $d) {
die(var_dump($a." - ".$b." - ".$c." - ".$d));
}
}
}
*/
/*
$langs = [];
$fn = "";
$t = [];
$ex = ['files' => [], 'new' => 0];
if ($exclude !== "") {
try {
......@@ -224,7 +197,20 @@ class LanguageController extends Controller
$ex = ['files' => [], 'new' => 0];
}
}
die();
/*
return view('languages.edit')
->with('texts', $t) //Array mit
->with('filename', $fn) //Pfad zur angezeigten Datei
->with('title', trans('titles.languages.edit'))
->with('langs', $langs) //Ausgangssprache (1 Element)
->with('to', $to) //zu bearbeitende Sprache
->with('langTexts', $langTexts) //Anzahl der vorhandenen Übersetzungen
->with('sum', $sum) //Alle vorhandenen Texte in beiden Sprachen in einem Array
->with('new', $ex["new"]) //
->with('email', $email); //Email-Adresse des Benutzers
*/
/*
foreach ($texts as $filename => $text) {
$has = false;
foreach ($ex['files'] as $file) {
......@@ -266,7 +252,7 @@ class LanguageController extends Controller
$t = $this->htmlEscape($t, $to);
$t = $this->createHints($t, $to);
*/
*/
return view('languages.synoptic');
}
......
<?php
namespace App\Models;
/*
* Beinhaltet zu je einer Sprache Angaben zum Pfad der jeweiligen Datei, sowie die vorhandenen Übersetzungen
*/
class LanguageData
{
public $language = "";
public $filePath = "";
public $stringMap = [[]];
public function __construct($lang, $path)
{
$this->language = $lang;
$this->filePath = $path;
}
public function saveData($filename, $key, $value)
{
if(is_array($value)) {
$this->deMultiDimensionalize($filename, $key, $value);
} else {
$this->stringMap[$filename][$key] = $value;
}
}
private function deMultiDimensionalize($filename, $key, $value)
{
foreach($value as $key2 => $value2) {
$this->saveData($filename, $key."#".$key2, $value2);
}
}
}
\ No newline at end of file
<?php
namespace App\Models;
/*
* Beinhaltet zu je einer Sprache Angaben zum Pfad der jeweiligen Datei, sowie die vorhandenen Übersetzungen
*/
class LanguageFile
{
public $filePath = "";
public $stringMap = [];
public function __construct($path)
{
$this->filePath = $path;
}
}
\ No newline at end of file
@extends('layouts.subPages')
@section('title', $title )
@section('content')
<h1>{{ trans('languages.header') }}</h1>
<p>{{ trans('languages.beschreibung.1') }}</p>
<p>{{ trans('languages.beschreibung.2') }}</p>
<!--
<div class="progress">
<div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="{{ round(100 * (($langTexts[$to]+$new) / count($sum))) }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ round(100 * (($langTexts[$to]+$new) / count($sum))) }}%">
{{ trans('languages.progress', ['uebersetzteTexte'=> ($langTexts[$to]+$new), 'textCount'=>count($sum), 'percentage'=>round(100 * (($langTexts[$to]+$new) / count($sum)))]) }}
</div>
</div>
-->
<h1>{{$filename}}</h1>
<form id="submit" method="POST">
<input type="hidden" name="filename" value="{{$filename}}" />
</form>
<table class="table">
<thead>
<tr>
<th>#ID</th>
<th>{{$to}}</th>
@foreach($langs as $lang => $value)
<th>{{$lang}}</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach($texts as $name => $langValues)
@if($langValues === "")
<tr>
<td class="name language-name">{{preg_replace("/(\s*).*#(.*)$/si", "$1$2", $name)}}</td>
<td></td>
<td></td>
</tr>
@else
<tr> <!--Key -->
<td class="name language-name">{{preg_replace("/(\s*).*#(.*)$/si", "$1$2", $name)}}</td>
<td>
@if(isset($langValues[$to]))
<textarea class="language-text-area" type="text" rows="1" cols="50" form="submit" name="{{ base64_encode($name) }}">{{$langValues[$to]}}</textarea>
@else
<textarea class="language-text-area" rows="1" cols="50" form="submit" name="{{base64_encode("_new_" . $name)}}"></textarea>
@endif
</td>
@foreach($langs as $lang => $value)
<td>{!! $langValues[$lang] or "" !!}</td>
@endforeach
</tr>
@endif
@endforeach
</tbody>
</table>
<!--
<p>{{ trans('languages.hinweis.1') }}</p>
<p>{!! trans('languages.hinweis.2') !!}</p>
<p>{!! trans('languages.hinweis.3') !!}</p>
<p>{!! trans('languages.email') !!}</p>
-->
<p><input type="email" name="email" form="submit" value="{{$email}}"/></p>
<button class="btn btn-success" type="submit" form="submit">Daten übermitteln</button>
<script type="text/javascript" src="{{ elixir('js/lib.js') }}"></script>
<script type="text/javascript" src="{{ elixir('js/editLanguage.js') }}"></script>
@endsection
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment