55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Database\Seeders\Concerns\SeedsSiteTranslations;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class SiteTranslationsSeeder extends Seeder
|
|
{
|
|
use SeedsSiteTranslations;
|
|
|
|
/**
|
|
* @var list<string>
|
|
*/
|
|
protected array $dataFiles = [
|
|
'home_menu_translations.php',
|
|
'home_menu_locale_patch.php',
|
|
'neler_yapariz_translations.php',
|
|
'app_development_translations.php',
|
|
'web_development_translations.php',
|
|
'corporate_translations.php',
|
|
'misc_site_translations.php',
|
|
];
|
|
|
|
public function run(): void
|
|
{
|
|
foreach ($this->dataFiles as $file) {
|
|
$path = database_path('data/' . $file);
|
|
|
|
if (! is_file($path)) {
|
|
$this->command?->warn("Translation data file not found: {$file}");
|
|
|
|
continue;
|
|
}
|
|
|
|
/** @var array{site?: array<string, array<string, string>>, pages?: array<string|int, array<string, array<string, string>>>} $data */
|
|
$data = require $path;
|
|
|
|
if (! empty($data['site'])) {
|
|
$this->seedSiteTranslations($data['site']);
|
|
}
|
|
|
|
if (! empty($data['pages'])) {
|
|
$this->seedPageTranslations($data['pages']);
|
|
}
|
|
|
|
$this->command?->info("Applied translations from {$file}");
|
|
}
|
|
|
|
$this->flushTranslationCache();
|
|
|
|
$this->command?->info('All site translations applied successfully.');
|
|
}
|
|
}
|