Skip to content

Commit 37d39a1

Browse files
Jade-GGactions-user
authored andcommitted
Apply fixes from Duster
1 parent a573b0b commit 37d39a1

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

check-translations.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,38 @@
44
$translationKeys = [];
55
$functions = ['@lang', '__'];
66
$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
1313
"\s*[\),]"; // Close parentheses or new parameter
1414

1515
$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
1919
"\k{quote}"; // Match " or ' previously matched
2020

2121
$files = [];
2222
$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();
2626
}
2727
}
2828

2929
foreach ($files as $file) {
3030
$contents = file_get_contents($file);
31-
if (preg_match_all("/$stringPattern/siU", $contents, $matches)) {
31+
if (preg_match_all("/{$stringPattern}/siU", $contents, $matches)) {
3232
foreach ($matches['string'] as $key) {
3333
$translationKeys[] = $key;
3434
}
3535
}
36-
if (preg_match_all("/$labelPattern/siU", $contents, $matches)) {
36+
if (preg_match_all("/{$labelPattern}/siU", $contents, $matches)) {
3737
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) {
3939
continue;
4040
}
4141
$translationKeys[] = $key;
@@ -44,13 +44,13 @@
4444
}
4545

4646
$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'));
4848

4949
$missing = 0;
50-
foreach($translationKeys as $key) {
50+
foreach ($translationKeys as $key) {
5151
if (! array_key_exists($key, $translations)) {
5252
$missing++;
53-
error_log("missing translation: \"$key\"");
53+
error_log("missing translation: \"{$key}\"");
5454
}
5555
}
5656

0 commit comments

Comments
 (0)