|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* rmarchiv.tk |
|
5
|
|
|
* (c) 2016-2017 by Marcel 'ryg' Hering |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace App\Http\Controllers; |
|
9
|
|
|
|
|
10
|
|
|
use Illuminate\Http\Request; |
|
11
|
|
|
use Waavi\Translation\Repositories\LanguageRepository; |
|
12
|
|
|
use Waavi\Translation\Repositories\TranslationRepository; |
|
13
|
|
|
|
|
14
|
|
|
class TranslationController extends Controller |
|
15
|
|
|
{ |
|
16
|
|
|
protected $languageRepository; |
|
17
|
|
|
protected $translationRepository; |
|
18
|
|
|
|
|
19
|
|
|
public function __construct(LanguageRepository $languageRepository, TranslationRepository $translationRepository) |
|
20
|
|
|
{ |
|
21
|
|
|
$this->languageRepository = $languageRepository; |
|
|
|
|
|
|
22
|
|
|
$this->translationRepository = $translationRepository; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function index() |
|
26
|
|
|
{ |
|
27
|
|
|
$locales = $this->languageRepository->availableLocales(); |
|
28
|
|
|
|
|
29
|
|
|
$list = []; |
|
30
|
|
|
|
|
31
|
|
|
foreach ($locales as $loc) { |
|
32
|
|
|
$temp['loc'] = $loc; |
|
|
|
|
|
|
33
|
|
|
$temp['perc'] = $this->languageRepository->percentTranslated($loc); |
|
34
|
|
|
$list[] = $temp; |
|
|
|
|
|
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
return view('translate.index', [ |
|
38
|
|
|
'list' => $list, |
|
39
|
|
|
]); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function edit($loc1, $loc2 = 'de', $viewtype = 'untranslated', $searchterm = '') |
|
|
|
|
|
|
43
|
|
|
{ |
|
44
|
|
|
$list = null; |
|
45
|
|
|
|
|
46
|
|
|
if ($viewtype == 'untranslated') { |
|
47
|
|
|
$list = $this->translationRepository->untranslated($loc2); |
|
48
|
|
|
} elseif ($viewtype == 'all') { |
|
49
|
|
|
$list = $this->translationRepository->allByLocale($loc2); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
return view('translate.show', [ |
|
53
|
|
|
'list' => $list, |
|
54
|
|
|
'loc1' => $loc1, |
|
55
|
|
|
'loc2' => $loc2, |
|
56
|
|
|
]); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function savestring(Request $request) |
|
60
|
|
|
{ |
|
61
|
|
|
//$this->translationRepository->translateText($request->get('transstring'), $request->get('loc2'), $request->get('loc1')); |
|
|
|
|
|
|
62
|
|
|
$trans = $this->translationRepository->find($request->get('id')); |
|
63
|
|
|
|
|
64
|
|
|
$this->translationRepository->create([ |
|
65
|
|
|
'locale' => $request->get('loc2'), |
|
66
|
|
|
'namespace' => $trans->namespace, |
|
67
|
|
|
'group' => $trans->group, |
|
68
|
|
|
'item' => $trans->item, |
|
69
|
|
|
'text' => $request->get('transstring'), |
|
70
|
|
|
]); |
|
71
|
|
|
|
|
72
|
|
|
return redirect()->action('TranslationController@edit', [$request->get('loc1'), $request->get('loc2')]); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.