|
4 | 4 | $translationKeys = []; |
5 | 5 | $functions = ['@lang', '__']; |
6 | 6 | $stringPattern = |
7 | | - "[^\w]". // Must not have an alphanum before real method |
8 | | - '('.implode('|', $functions).')'. // Must start with one of the functions |
9 | | - "\(\s*". // Match opening parenthesis |
10 | | - "(?P<quote>['\"])". // Match " or ' and store in {quote} |
11 | | - "(?P<string>(?:\\\k{quote}|(?!\k{quote}).)*)". // Match any string that can be {quote} escaped |
12 | | - "\k{quote}". // Match " or ' previously matched |
| 7 | + "[^\w]" . // Must not have an alphanum before real method |
| 8 | + '(' . implode('|', $functions) . ')' . // Must start with one of the functions |
| 9 | + "\(\s*" . // Match opening parenthesis |
| 10 | + "(?P<quote>['\"])" . // Match " or ' and store in {quote} |
| 11 | + "(?P<string>(?:\\\k{quote}|(?!\k{quote}).)*)" . // Match any string that can be {quote} escaped |
| 12 | + "\k{quote}" . // Match " or ' previously matched |
13 | 13 | "\s*[\),]"; // Close parentheses or new parameter |
14 | 14 |
|
15 | 15 | $labelPattern = |
16 | | - "label=" . // Match `label=` |
17 | | - "(?P<quote>['\"])". // Match " or ' and store in {quote} |
18 | | - "(?P<string>(?:\\\k{quote}|(?!\k{quote}).)*)". // Match any string that can be {quote} escaped |
| 16 | + 'label=' . // Match `label=` |
| 17 | + "(?P<quote>['\"])" . // Match " or ' and store in {quote} |
| 18 | + "(?P<string>(?:\\\k{quote}|(?!\k{quote}).)*)" . // Match any string that can be {quote} escaped |
19 | 19 | "\k{quote}"; // Match " or ' previously matched |
20 | 20 |
|
21 | 21 | $files = []; |
22 | 22 | $iterator = new RecursiveDirectoryIterator('resources'); |
23 | | -foreach(new RecursiveIteratorIterator($iterator) as $file) { |
24 | | - if(strpos($file , '.blade.php') !== false){ |
25 | | - $files[] = $file->getRealPath(); |
| 23 | +foreach (new RecursiveIteratorIterator($iterator) as $file) { |
| 24 | + if (strpos($file, '.blade.php') !== false) { |
| 25 | + $files[] = $file->getRealPath(); |
26 | 26 | } |
27 | 27 | } |
28 | 28 |
|
29 | 29 | foreach ($files as $file) { |
30 | 30 | $contents = file_get_contents($file); |
31 | | - if (preg_match_all("/$stringPattern/siU", $contents, $matches)) { |
| 31 | + if (preg_match_all("/{$stringPattern}/siU", $contents, $matches)) { |
32 | 32 | foreach ($matches['string'] as $key) { |
33 | 33 | $translationKeys[] = $key; |
34 | 34 | } |
35 | 35 | } |
36 | | - if (preg_match_all("/$labelPattern/siU", $contents, $matches)) { |
| 36 | + if (preg_match_all("/{$labelPattern}/siU", $contents, $matches)) { |
37 | 37 | foreach ($matches['string'] as $key) { |
38 | | - if (str_starts_with($key, '@lang(') || str_starts_with($key, '__(') || $key == 'false' || !$key) { |
| 38 | + if (str_starts_with($key, '@lang(') || str_starts_with($key, '__(') || $key == 'false' || ! $key) { |
39 | 39 | continue; |
40 | 40 | } |
41 | 41 | $translationKeys[] = $key; |
|
44 | 44 | } |
45 | 45 |
|
46 | 46 | $translationKeys = array_unique($translationKeys); |
47 | | -$translations = (array)json_decode(file_get_contents('lang/nl.json')); |
| 47 | +$translations = (array) json_decode(file_get_contents('lang/nl.json')); |
48 | 48 |
|
49 | 49 | $missing = 0; |
50 | | -foreach($translationKeys as $key) { |
| 50 | +foreach ($translationKeys as $key) { |
51 | 51 | if (! array_key_exists($key, $translations)) { |
52 | 52 | $missing++; |
53 | | - error_log("missing translation: \"$key\""); |
| 53 | + error_log("missing translation: \"{$key}\""); |
54 | 54 | } |
55 | 55 | } |
56 | 56 |
|
|
0 commit comments