use enabled_locales logic to handle locales (#5017)
* allow to skip locales (here: catalan) * use enabled_locales and replace app_locales with kimai_locales * added test to call all reports once for super_admin
This commit is contained in:
@@ -39,13 +39,19 @@ final class RegenerateLocalesCommand extends Command
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private array $noRegionCode = ['ar', 'id', 'pa', 'sl'];
|
||||
private array $noRegionCode = ['ar', 'id', 'pa', 'sl', 'ca'];
|
||||
/**
|
||||
* A list of locales that will be activated, no matter if translation files exist for them.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private array $addLocaleToList = ['zh_Hant_TW'];
|
||||
/**
|
||||
* A list of locales that will NOT be activated, as no translations exist by now.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private array $skipLocale = ['ca'];
|
||||
|
||||
public function __construct(
|
||||
private readonly string $projectDirectory,
|
||||
@@ -78,7 +84,11 @@ final class RegenerateLocalesCommand extends Command
|
||||
}
|
||||
$firstLevelLocales = [];
|
||||
foreach ($translationFilenames as $file) {
|
||||
$firstLevelLocales[] = explode('.', basename($file))[1];
|
||||
$l = explode('.', basename($file))[1];
|
||||
if (\in_array($l, $this->skipLocale, true)) {
|
||||
continue;
|
||||
}
|
||||
$firstLevelLocales[] = $l;
|
||||
}
|
||||
$firstLevelLocales = array_unique(array_merge($firstLevelLocales, $this->addLocaleToList));
|
||||
$io->title('First level locales found');
|
||||
@@ -185,8 +195,8 @@ final class RegenerateLocalesCommand extends Command
|
||||
|
||||
// in the future this list should be reduced to the list of available translations, but for a long time users
|
||||
// could choose from the entire list of all locales, so we likely have to keep that forever ...
|
||||
$io->title('List of app_locales for services.yaml');
|
||||
$io->writeln(implode('|', $locales));
|
||||
$io->title('List of "kimai_locales" for services.yaml');
|
||||
$io->writeln("['" . implode("', '", $locales) . "']");
|
||||
|
||||
ksort($appLocales);
|
||||
|
||||
|
||||
@@ -107,7 +107,9 @@ final class AppExtension extends Extension
|
||||
|
||||
private function setLanguageFormats(ContainerBuilder $container): void
|
||||
{
|
||||
$locales = explode('|', $container->getParameter('app_locales'));
|
||||
$locales = $container->getParameter('kimai_locales');
|
||||
// @deprecated since 2.21.0
|
||||
$container->setParameter('app_locales', implode('|', $locales));
|
||||
|
||||
$directory = $container->getParameter('kernel.project_dir');
|
||||
$settings = include $directory . DIRECTORY_SEPARATOR . 'config/locales.php';
|
||||
|
||||
Reference in New Issue
Block a user