Commit fe3deeb5 authored by Georg Ringer's avatar Georg Ringer Committed by Benni Mack

[FEATURE] Provide list of available system locales

Providing a list of available locales makes it faster
and less error prone to setup a site and its languages.

Resolves: #93651
Releases: master
Change-Id: I2a0ed64f8d5d1e97c06671550e180af238331009
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68186Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: default avatarGuido Schmechel <guido.schmechel@brandung.de>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarGuido Schmechel <guido.schmechel@brandung.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent f627a2c5
......@@ -18,6 +18,8 @@ declare(strict_types=1);
namespace TYPO3\CMS\Backend\Configuration\TCA;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* This class provides user functions for the usage in TCA definition
......@@ -88,9 +90,25 @@ class UserFunctions
$parameters['title'] = sprintf($format, ...$arguments);
}
/**
* @return LanguageService
*/
public static function getAllSystemLocales(): array
{
$disabledFunctions = GeneralUtility::trimExplode(',', (string)ini_get('disable_functions'), true);
if (in_array('exec', $disabledFunctions, true)) {
return [];
}
$rawOutput = [];
CommandUtility::exec('locale -a', $rawOutput);
ksort($rawOutput, SORT_NATURAL);
$locales = [];
foreach ($rawOutput as $item) {
$locales[] = [$item, $item];
}
return $locales;
}
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
......
......@@ -68,8 +68,12 @@ return [
'config' => [
'type' => 'input',
'eval' => 'required, trim',
'size' => 10,
'size' => 20,
'placeholder' => 'en_US.UTF-8',
'valuePicker' => [
'mode' => '',
'items' =>\TYPO3\CMS\Backend\Configuration\TCA\UserFunctions::getAllSystemLocales()
],
],
],
'iso-639-1' => [
......
.. include:: ../../Includes.txt
==========================================================
Feature: #93651 - Provide list of available system locales
==========================================================
See :issue:`93651`
Description
===========
Every language of a site requires at least one locale which is used to format times, dates,
currencies and other values. Additional locales can be added as fallback locales (comma separated).
Impact
======
Providing a list of available locales makes it faster and less error prone to setup a site and its
languages.
.. index:: Backend, ext:backend
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment