Skip to content

Commit 23f3367

Browse files
author
Kit Senior
committed
command fixes
1 parent a8a825b commit 23f3367

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

dev/Commands/AbstractDevCommand.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected function getNovaKeys(): array
9999
exit;
100100
}
101101

102-
$novaKeys = array_values(array_diff(array_keys(json_decode($this->filesystem->get($sourceFile), true)), static::IGNORED_KEYS));
102+
$novaKeys = array_values(array_diff(array_keys(json_decode($this->filesystem->get($sourceFile), true)), $this->getIgnoredNovaKeys()));
103103
$sourceKeys = [];
104104

105105
// Workaround for keys that have been forgotten by Nova
@@ -130,6 +130,19 @@ protected function getRenamedNovaKeys(): array
130130
'The action ran successfully!' => 'The action was executed successfully.',
131131
'An error occured while uploading the file.' => 'An error occurred while uploading the file.',
132132
'Select All' => 'Select all',
133+
'The image could not be loaded' => 'The image could not be loaded.',
134+
];
135+
}
136+
137+
protected function getIgnoredNovaKeys(): array
138+
{
139+
// Keys that do not need to be translated
140+
return [
141+
'*',
142+
'',
143+
'CSV (.csv)',
144+
'Excel (.xlsx)',
145+
'The image could not be loaded'
133146
];
134147
}
135148
}

dev/Commands/NovaLangCleanup.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function handleLocale(string $locale): void
4242

4343
$inputKeys = $this->loadJson($inputFile);
4444

45-
$outputKeys = array_filter($inputKeys, fn ($text) => ! empty(trim($text)) && $text !== static::MISSING_TEXT && ! empty(preg_replace('/\W+/u', '', $text)));
45+
$outputKeys = array_filter($inputKeys, fn ($text) => ! empty(trim($text)) && $text !== static::MISSING_TEXT && ! empty(preg_replace('/\s+/u', '', $text)));
4646

4747
$missingKeys = count($inputKeys) - count($outputKeys);
4848

dev/Commands/NovaLangReorder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function handleLocale(string $locale)
6262
}
6363
}
6464

65-
$localeKeys = array_diff(array_keys($localeTranslations), static::IGNORED_KEYS);
65+
$localeKeys = array_diff(array_keys($localeTranslations), $this->getIgnoredNovaKeys());
6666

6767
$extraKeys = count(array_diff($localeKeys, $this->sourceKeys));
6868

dev/Commands/NovaLangStats.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ protected function getJsonKeys(string $path): array
277277
throw new \Exception('Invalid JSON file: '.$path);
278278
}
279279

280-
return array_diff(array_keys($json), static::IGNORED_KEYS);
280+
return array_diff(array_keys($json), $this->getIgnoredNovaKeys());
281281
}
282282

283283
return [];

src/Commands/AbstractCommand.php

-10
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ abstract class AbstractCommand extends Command
1616
*/
1717
public const SEPARATORS = '-‑_';
1818

19-
/**
20-
* @var string[]
21-
*/
22-
public const IGNORED_KEYS = [
23-
'*',
24-
'',
25-
'CSV (.csv)',
26-
'Excel (.xlsx)'
27-
];
28-
2919
/**
3020
* @var Filesystem
3121
*/

0 commit comments

Comments
 (0)