option('locale'); $findings = []; foreach (CmsContent::query()->orderBy('group')->orderBy('key')->get() as $row) { $translations = $row->getTranslations('value'); $label = "CMS {$row->group}.{$row->key}"; if (! array_key_exists($locale, $translations)) { $findings[] = [$label, 'keine Übersetzung']; continue; } $this->collect($translations[$locale], $label, $findings); } foreach (CmsBrand::query()->ordered()->get() as $brand) { foreach ($brand->translatable as $attribute) { $translations = $brand->getTranslations($attribute); if (filled($translations[CmsBrand::BASE_LOCALE] ?? null) && blank($translations[$locale] ?? null)) { $findings[] = ["Marke {$brand->slug}.{$attribute}", 'keine Übersetzung']; } else { $this->collect($translations[$locale] ?? null, "Marke {$brand->slug}.{$attribute}", $findings); } } foreach (CmsBrand::LOCALIZED_FIELDS as $field) { $this->collect($brand->localized($field, $locale), "Marke {$brand->slug}.{$field}", $findings); } } foreach (CmsArticle::query()->get() as $article) { foreach ($article->translatable as $attribute) { $translations = $article->getTranslations($attribute); $label = "Magazin {$article->slug}.{$attribute}"; if (filled($translations[CmsBrand::BASE_LOCALE] ?? null) && blank($translations[$locale] ?? null)) { $findings[] = [$label, 'keine Übersetzung']; } else { $this->collect($translations[$locale] ?? null, $label, $findings); } } } if ($findings === []) { $this->info("Keine deutschen oder fehlenden Texte für „{$locale}“ gefunden."); return self::SUCCESS; } $this->table(['Stelle', 'Text'], $findings); $this->warn(count($findings).' Stellen.'); return self::FAILURE; } /** * @param list $findings */ private function collect(mixed $value, string $path, array &$findings): void { if (is_array($value)) { foreach ($value as $key => $item) { $this->collect($item, "{$path}.{$key}", $findings); } return; } if (! is_string($value)) { return; } $text = trim(html_entity_decode(strip_tags($value))); if ($text !== '' && preg_match_all(self::GermanWords, $text) >= 2) { $findings[] = [$path, mb_strimwidth($text, 0, 90, '…')]; } } }