57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
class SetupLanguages extends Command
|
|
{
|
|
protected $signature = 'lang:setup';
|
|
protected $description = 'Membuat dan mengisi file bahasa Indonesia dan Inggris secara otomatis';
|
|
|
|
public function handle()
|
|
{
|
|
$langPath = resource_path('lang');
|
|
|
|
// Buat folder lang kalau belum ada
|
|
if (!File::exists($langPath)) {
|
|
File::makeDirectory($langPath, 0755, true);
|
|
$this->info('📁 Folder "resources/lang" berhasil dibuat.');
|
|
}
|
|
|
|
// Isi default Bahasa Indonesia
|
|
$idData = [
|
|
"Welcome" => "Selamat Datang",
|
|
"Search" => "Pencarian",
|
|
"Book Collection" => "Koleksi Buku",
|
|
"Language" => "Bahasa",
|
|
"Filter" => "Filter",
|
|
"Apply" => "Terapkan",
|
|
"Reset" => "Atur Ulang",
|
|
"Available" => "Tersedia",
|
|
"Borrowed" => "Dipinjam"
|
|
];
|
|
|
|
// Isi default Bahasa Inggris
|
|
$enData = [
|
|
"Welcome" => "Welcome",
|
|
"Search" => "Search",
|
|
"Book Collection" => "Book Collection",
|
|
"Language" => "Language",
|
|
"Filter" => "Filter",
|
|
"Apply" => "Apply",
|
|
"Reset" => "Reset",
|
|
"Available" => "Available",
|
|
"Borrowed" => "Borrowed"
|
|
];
|
|
|
|
// Simpan file JSON
|
|
File::put($langPath . '/id.json', json_encode($idData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
|
File::put($langPath . '/en.json', json_encode($enData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
|
|
|
$this->info('✅ File bahasa "id.json" dan "en.json" berhasil dibuat dan diisi.');
|
|
}
|
|
}
|
|
|