1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the TYPO3 CMS project. |
7
|
|
|
* |
8
|
|
|
* It is free software; you can redistribute it and/or modify it under |
9
|
|
|
* the terms of the GNU General Public License, either version 2 |
10
|
|
|
* of the License, or any later version. |
11
|
|
|
* |
12
|
|
|
* For the full copyright and license information, please read the |
13
|
|
|
* LICENSE.txt file that was distributed with this source code. |
14
|
|
|
* |
15
|
|
|
* The TYPO3 project - inspiring people to share! |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace TYPO3\CMS\Core\Localization; |
19
|
|
|
|
20
|
|
|
use TYPO3\CMS\Core\Core\Environment; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Provides ItemProcFunc fields for special population of available TYPO3 system languages |
24
|
|
|
* @internal |
25
|
|
|
*/ |
26
|
|
|
class TcaSystemLanguageCollector |
27
|
|
|
{ |
28
|
|
|
private Locales $locales; |
29
|
|
|
|
30
|
|
|
public function __construct(Locales $locales) |
31
|
|
|
{ |
32
|
|
|
$this->locales = $locales; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Populate languages and group by available languages of the Language packs |
37
|
|
|
*/ |
38
|
|
|
public function populateAvailableSystemLanguagesForBackend(array &$fieldInformation): void |
39
|
|
|
{ |
40
|
|
|
$languageItems = $this->locales->getLanguages(); |
41
|
|
|
unset($languageItems['default']); |
42
|
|
|
asort($languageItems); |
43
|
|
|
$installedLanguages = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['lang']['availableLanguages'] ?? []; |
44
|
|
|
$availableLanguages = []; |
45
|
|
|
$unavailableLanguages = []; |
46
|
|
|
foreach ($languageItems as $typo3Language => $name) { |
47
|
|
|
$available = in_array($typo3Language, $installedLanguages, true) || is_dir(Environment::getLabelsPath() . '/' . $typo3Language); |
48
|
|
|
if ($available) { |
49
|
|
|
$availableLanguages[] = [$name, $typo3Language, '', 'installed']; |
50
|
|
|
} else { |
51
|
|
|
$unavailableLanguages[] = [$name, $typo3Language, '', 'unavailable']; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
// Ensure ordering of the items |
56
|
|
|
$fieldInformation['items'] = array_merge($fieldInformation['items'], $availableLanguages); |
57
|
|
|
$fieldInformation['items'] = array_merge($fieldInformation['items'], $unavailableLanguages); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|