Skip to content

Commit 9f26b1e

Browse files
committed
Update ImportTranslationsCommand.php
1 parent 384bd55 commit 9f26b1e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Console/Commands/ImportTranslationsCommand.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ImportTranslationsCommand extends Command
1616
{
1717
public TranslationsManager $manager;
1818

19-
protected $signature = 'translations:import {--F|fresh : Truncate all translations and phrases before importing}';
19+
protected $signature = 'translations:import {--F|fresh : Truncate all translations and phrases before importing} {--force : Force the operation to run when in production}';
2020

2121
protected $description = 'Sync translation all keys from the translation files to the database';
2222

@@ -40,7 +40,11 @@ public function handle(): void
4040
{
4141
$this->importLanguages();
4242

43-
if ($this->option('fresh') && $this->confirm('Are you sure you want to truncate all translations and phrases?')) {
43+
if ($this->option('force') && $this->option('fresh')) {
44+
$this->info('Truncating translations and phrases...' . PHP_EOL);
45+
46+
$this->truncateTables();
47+
} elseif ($this->option('fresh') && $this->confirm('Are you sure you want to truncate all translations and phrases?')) {
4448
$this->info('Truncating translations and phrases...' . PHP_EOL);
4549

4650
$this->truncateTables();
@@ -132,7 +136,7 @@ public function syncPhrases(Translation $source, $key, $value, $locale, $file):
132136
protected function importLanguages(): void
133137
{
134138
if (!Schema::hasTable('ltu_languages') || Language::count() === 0) {
135-
if ($this->confirm('The ltu_languages table does not exist or is empty, would you like to install the default languages?', true)) {
139+
if ($this->option('force') || $this->confirm('The ltu_languages table does not exist or is empty, would you like to install the default languages?', true)) {
136140
$this->callSilent('db:seed', ['--class' => LanguagesTableSeeder::class]);
137141
} else {
138142
$this->error('The ltu_languages table does not exist or is empty, please run the translations:install command first.');

0 commit comments

Comments
 (0)