Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dmason30 committed Oct 6, 2023
1 parent bf06754 commit a5a3b8e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/Commands/UnusedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public function handle(
UnusedResultCollection $results,
UnusedTranslationLinter $linter,
): int {
foreach ($linter->execute() as $lang => $namespaces) {
foreach ($linter->execute() as $locale => $namespaces) {
foreach ($namespaces as $namespace => $translations) {
foreach ($translations as $key => $value) {
if ($filters->shouldReport($lang, $namespace, $key, $value)) {
$results->addUnusedLanguageKey($lang, $namespace, $key, $value);
if ($filters->shouldReport($locale, $namespace, $key, $value)) {
$results->addUnusedLanguageKey($locale, $namespace, $key, $value);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/LaravelTranslationLinterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function registeringPackage()
$this->app->bind(UnusedResultCollectionContract::class, UnusedResultCollection::class);
$this->app->bind(UnusedTranslationLinterContract::class, UnusedTranslationLinter::class);
$this->app->when(UnusedTranslationLinter::class)
->needs('$languages')
->needs('$locales')
->giveConfig('translation-linter.lang.locales');
}

Expand Down
12 changes: 6 additions & 6 deletions src/Linters/UnusedTranslationLinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
protected LanguageFileFinder $files,
protected LanguageFileReader $translations,
protected LanguageNamespaceFinder $namespaces,
protected array $languages,
protected array $locales,
) {}

public function execute(): Collection
Expand All @@ -29,11 +29,11 @@ public function execute(): Collection
$used = $this->used->execute();
$namespaces = $this->namespaces->execute();

foreach ($this->languages as $language) {
$unused[$language] = [];
foreach ($this->locales as $locale) {
$unused[$locale] = [];

foreach ($namespaces as $namespace => $path) {
$unused[$language][$namespace] = [];
$unused[$locale][$namespace] = [];

// TODO: Support json files
$files = $this->files->execute($path, ['php']);
Expand All @@ -43,7 +43,7 @@ public function execute(): Collection
$translations = $this->translations->execute($file);

foreach ($translations as $field => $children) {
$group = $this->getLanguageKey($file, $language, $field);
$group = $this->getLanguageKey($file, $locale, $field);

foreach (Arr::dot(Arr::wrap($children)) as $key => $value) {
$groupedKey = Str::of($group)
Expand All @@ -56,7 +56,7 @@ public function execute(): Collection
->toString();

if ($used->doesntContain($namespacedKey)) {
$unused[$language][$namespace][$groupedKey] = $value;
$unused[$locale][$namespace][$groupedKey] = $value;
}
}
}
Expand Down

0 comments on commit a5a3b8e

Please sign in to comment.