Skip to content

Commit dd84ced

Browse files
committed
fix separators
1 parent 885e4fe commit dd84ced

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/Commands/NovaLangPublish.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
class NovaLangPublish extends Command
1111
{
12+
/**
13+
* Possible locale separators.
14+
* @var string
15+
*/
16+
const SEPARATORS = '-‑_';
17+
1218
/**
1319
* The name and signature of the console command.
1420
*
@@ -117,7 +123,8 @@ protected function getRequestedLocales(): Collection
117123
$locales = $this->getAvailableLocales();
118124
}
119125
else {
120-
$locales = collect(explode(',', $this->argument('locales')))->filter();
126+
$locales = $this->fixSeparators($this->argument('locales'));
127+
$locales = collect(explode(',', $locales))->filter();
121128
}
122129

123130
$aliases = $this->getLocaleAliases($locales->count() == 1 ? $locales->first() : false);
@@ -194,13 +201,21 @@ protected function getLocaleAliases($single = false): Collection
194201
$this->warn(sprintf('Alias for [%s] locale was declared more than once and will be overwritten by the last value.', $locale));
195202
}
196203

204+
205+
$locale = $this->fixSeparators($locale);
206+
197207
$aliases->put($locale, $alias);
198208
}
199209
}
200210

201211
return $aliases;
202212
}
203213

214+
protected function fixSeparators(string $locale)
215+
{
216+
return preg_replace('/['.static::SEPARATORS.']+/', '-', $locale);
217+
}
218+
204219
protected function isForce(): bool
205220
{
206221
return $this->option('force');

0 commit comments

Comments
 (0)