Skip to content

Fix parallel command reference locales and default locales #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ Specify target locales separated by commas using the `--locale` option. For exam
php artisan ai-translator:translate-parallel --locale=ko,ja
```

If you omit the `--locale` option, the command automatically translates all available locales.

This command will:

1. Recognize all language folders in your `lang` directory
Expand Down
6 changes: 4 additions & 2 deletions src/Console/TranslateStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ public function handle()

// Select reference languages
if ($nonInteractive) {
$this->referenceLocales = $this->option('reference') ?? [];
$this->referenceLocales = $this->option('reference')
? explode(',', (string) $this->option('reference'))
: [];
if (!empty($this->referenceLocales)) {
$this->info($this->colors['green'] . "✓ Selected reference locales: " .
$this->colors['reset'] . $this->colors['bold'] . implode(', ', $this->referenceLocales) .
Expand Down Expand Up @@ -245,7 +247,7 @@ public function translate(int $maxContextItems = 100): void
foreach ($locales as $locale) {
// 소스 언어와 같거나 스킵 목록에 있는 언어는 건너뜀
if ($locale === $this->sourceLocale || in_array($locale, config('ai-translator.skip_locales', []))) {
$this->warn('Skipping locale ' . $locale .'.');
$this->warn('Skipping locale ' . $locale . '.');
continue;
}

Expand Down
9 changes: 4 additions & 5 deletions src/Console/TranslateStringsParallel.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ public function translate(int $maxContextItems = 100): void
$availableLocales = $this->getExistingLocales();

if (!$nonInteractive && empty($specifiedLocales)) {
$selected = $this->choiceLanguages(
$this->colors['yellow'] . 'Choose target locales for translation. Multiple selections with comma separator (e.g. "1,2")' . $this->colors['reset'],
true
);
$locales = is_array($selected) ? $selected : [$selected];
$locales = $availableLocales;
$this->info($this->colors['green'] . '✓ Selected locales: ' .
$this->colors['reset'] . $this->colors['bold'] . implode(', ', $locales) .
$this->colors['reset']);
} else {
$locales = !empty($specifiedLocales)
? $this->validateAndFilterLocales($specifiedLocales, $availableLocales)
Expand Down