1 | <?php namespace Arcanedev\LaravelLang; |
||
14 | class TransChecker implements TransCheckerInterface |
||
15 | { |
||
16 | /* ----------------------------------------------------------------- |
||
17 | | Properties |
||
18 | | ----------------------------------------------------------------- |
||
19 | */ |
||
20 | |||
21 | /** |
||
22 | * Config values. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | private $configs; |
||
27 | |||
28 | /** |
||
29 | * The translator instance. |
||
30 | * |
||
31 | * @var \Illuminate\Translation\Translator |
||
32 | */ |
||
33 | private $translator; |
||
34 | |||
35 | /** |
||
36 | * The translator manager instance. |
||
37 | * |
||
38 | * @var \Arcanedev\LaravelLang\Contracts\TransManager |
||
39 | */ |
||
40 | private $manager; |
||
41 | |||
42 | /** |
||
43 | * The missing translations. |
||
44 | * |
||
45 | * @var array |
||
46 | */ |
||
47 | private $missing = []; |
||
48 | |||
49 | /* ----------------------------------------------------------------- |
||
50 | | Constructor |
||
51 | | ----------------------------------------------------------------- |
||
52 | */ |
||
53 | |||
54 | /** |
||
55 | * Make TransChecker instance. |
||
56 | * |
||
57 | * @param \Illuminate\Translation\Translator $translator |
||
58 | * @param \Arcanedev\LaravelLang\Contracts\TransManager $manager |
||
59 | * @param array $configs |
||
60 | */ |
||
61 | 12 | public function __construct( |
|
70 | |||
71 | /* ----------------------------------------------------------------- |
||
72 | | Getters & Setter |
||
73 | | ----------------------------------------------------------------- |
||
74 | */ |
||
75 | |||
76 | /** |
||
77 | * Get the default locale being used. |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | 2 | public function getDefaultLocale() |
|
85 | |||
86 | /** |
||
87 | * Get the locales to check. |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | 2 | public function getLocales() |
|
95 | |||
96 | /** |
||
97 | * Get the ignored translation attributes. |
||
98 | * |
||
99 | * @return array |
||
100 | */ |
||
101 | 2 | public function getIgnoredTranslations() |
|
105 | |||
106 | /* ----------------------------------------------------------------- |
||
107 | | Main Methods |
||
108 | | ----------------------------------------------------------------- |
||
109 | */ |
||
110 | |||
111 | /** |
||
112 | * Check the missing translations. |
||
113 | * |
||
114 | * @return array |
||
115 | */ |
||
116 | 2 | public function check() |
|
133 | |||
134 | /* ----------------------------------------------------------------- |
||
135 | | Other Methods |
||
136 | | ----------------------------------------------------------------- |
||
137 | */ |
||
138 | |||
139 | /** |
||
140 | * Get locale translations from multiple groups. |
||
141 | * |
||
142 | * @param string $locale |
||
143 | * @param array $ignored |
||
144 | * |
||
145 | * @return array |
||
146 | */ |
||
147 | 2 | private function getTranslations($locale, array $ignored) |
|
156 | |||
157 | /** |
||
158 | * Diff the missing translations. |
||
159 | * |
||
160 | * @param array $toTranslations |
||
161 | * @param array $fromTranslations |
||
162 | * @param string $locale |
||
163 | */ |
||
164 | 2 | private function diffMissing(array $toTranslations, array $fromTranslations, $locale) |
|
175 | |||
176 | /** |
||
177 | * Adding missing translation to collection. |
||
178 | * |
||
179 | * @param string $locale |
||
180 | * @param string $transKey |
||
181 | */ |
||
182 | 2 | private function addMissing($locale, $transKey) |
|
188 | |||
189 | /** |
||
190 | * Check if a missing translation exists in collection. |
||
191 | * |
||
192 | * @param string $locale |
||
193 | * @param string $transKey |
||
194 | * |
||
195 | * @return bool |
||
196 | */ |
||
197 | 2 | private function hasMissing($locale, $transKey) |
|
204 | } |
||
205 |