feat: add new translation files for app development, corporate, home menu, and miscellaneous site content, enhancing multilingual support and user experience
This commit is contained in:
@@ -2,58 +2,12 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Page;
|
||||
use App\Models\SiteTranslation;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class HomeMenuTranslationsSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$data = require database_path('data/home_menu_translations.php');
|
||||
|
||||
foreach ($data['site'] as $key => $translations) {
|
||||
$record = SiteTranslation::firstOrNew(['hash' => md5($key)]);
|
||||
$existing = $record->translations ?? [];
|
||||
|
||||
$merged = array_merge($existing, [
|
||||
'tr' => $key,
|
||||
], array_filter($translations));
|
||||
|
||||
SiteTranslation::updateOrCreate(
|
||||
['hash' => md5($key)],
|
||||
[
|
||||
'key' => $key,
|
||||
'translations' => $merged,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($data['pages'] as $pageId => $fields) {
|
||||
$page = Page::query()->whereKey($pageId)->first();
|
||||
|
||||
if (! $page) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($fields as $fieldName => $translations) {
|
||||
foreach ($translations as $languageCode => $value) {
|
||||
if ($value === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$page->setTranslation($fieldName, $languageCode, $value, 'published', 1);
|
||||
}
|
||||
|
||||
if (! isset($translations['tr'])) {
|
||||
$page->setTranslation($fieldName, 'tr', $page->{$fieldName}, 'published', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cache::flush();
|
||||
|
||||
$this->command?->info('Home page and menu translations applied successfully.');
|
||||
$this->call(SiteTranslationsSeeder::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user