25
25
use T3G \AgencyPack \FileVariants \Service \ResourcesService ;
26
26
use TYPO3 \CMS \Backend \Form \AbstractNode ;
27
27
use TYPO3 \CMS \Core \Database \ConnectionPool ;
28
+ use TYPO3 \CMS \Core \Site \Entity \SiteLanguage ;
29
+ use TYPO3 \CMS \Core \Site \SiteFinder ;
28
30
use TYPO3 \CMS \Core \Utility \GeneralUtility ;
29
31
30
32
/**
@@ -42,13 +44,6 @@ public function render(): array
42
44
{
43
45
$ result = $ this ->initializeResultArray ();
44
46
45
- $ queryBuilder = GeneralUtility::makeInstance (ConnectionPool::class)->getQueryBuilderForTable ('sys_language ' );
46
- $ languages = [];
47
- $ languageRecords = $ queryBuilder ->select ('uid ' , 'title ' , 'language_isocode ' )->from ('sys_language ' )->executeQuery ();
48
- while ($ language = $ languageRecords ->fetchAssociative ()) {
49
- $ languages [(int )$ language ['uid ' ]] = $ language ['title ' ] . ' ( ' . $ language ['language_isocode ' ] . ') ' ;
50
- }
51
-
52
47
// no parent - we are in default language
53
48
$ parentField = (int )$ this ->data ['databaseRow ' ]['l10n_parent ' ][0 ];
54
49
if ($ parentField === 0 ) {
@@ -60,8 +55,9 @@ public function render(): array
60
55
$ queryBuilder ->createNamedParameter ((int )$ this ->data ['databaseRow ' ]['uid ' ], \PDO ::PARAM_INT )
61
56
))->executeQuery ();
62
57
while ($ translation = $ translations ->fetchAssociative ()) {
58
+ $ siteLanguage = $ this ->findSiteLanguageById ((int )$ translation ['sys_language_uid ' ]);
63
59
$ result ['html ' ] .= '<p class="t3-sysfile-translation"> ' ;
64
- $ result ['html ' ] .= '<span> ' . $ languages [( int ) $ translation [ ' sys_language_uid ' ]] . '</span> ' ;
60
+ $ result ['html ' ] .= '<span> ' . $ siteLanguage -> getTitle () . '</span> ' ;
65
61
$ result ['html ' ] .= $ resourcesService ->generatePreviewImageHtml ((int )$ translation ['file ' ], 't3-tceforms-sysfile-translation-imagepreview ' );
66
62
$ result ['html ' ] .= '</p> ' ;
67
63
}
@@ -72,4 +68,17 @@ public function render(): array
72
68
73
69
return $ result ;
74
70
}
71
+
72
+ private function findSiteLanguageById (int $ siteLanguageId ): SiteLanguage
73
+ {
74
+ foreach (GeneralUtility::makeInstance (SiteFinder::class)->getAllSites () as $ site ) {
75
+ try {
76
+ return $ site ->getLanguageById ($ siteLanguageId );
77
+ } catch (\InvalidArgumentException ) {
78
+ continue ;
79
+ }
80
+ }
81
+
82
+ throw new \InvalidArgumentException (sprintf ('No site language with ID "%d" ' , $ siteLanguageId ), 1711465624 );
83
+ }
75
84
}
0 commit comments