Skip to content

Commit f694226

Browse files
committed
Merge branch 'feature/add-typo3v14-support'
2 parents 92c96fe + f498928 commit f694226

File tree

3 files changed

+54
-21
lines changed

3 files changed

+54
-21
lines changed

Classes/Backend/ToolbarItems/CrowdinToolbarItem.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,19 @@ protected function createToggleSwitch(string $name, bool $enabled): string
139139

140140
$GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] = $backupDebug;
141141

142-
return $result['html'];
142+
if ($this->typo3Version >= 13) {
143+
// We need to get rid of a "form-wizards-item-element" class that is useless and
144+
// breaks or hand-crafted layout by enforcing a 120px minimum width (backend.css)
145+
// for the toggle usually part of a TCA form
146+
$checkboxHtml = str_replace('<div class="form-wizards-item-element">', '<div>', $result['html']);
147+
} else {
148+
// We need to get rid of a "form-wizards-element" class that is useless and
149+
// breaks or hand-crafted layout by enforcing a 120px minimum width (backend.css)
150+
// for the toggle usually part of a TCA form
151+
$checkboxHtml = str_replace('<div class="form-wizards-element">', '<div>', $result['html']);
152+
}
153+
154+
return $checkboxHtml;
143155
}
144156

145157
protected function getExtensionsCompatibleWithCrowdin(): array

Classes/ViewHelpers/Override/V14/TranslateViewHelper.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,24 +157,31 @@ private static function overrideLocale(Locale|string|null $locale, string $id, s
157157
self::$userConfiguration = GeneralUtility::makeInstance(UserConfiguration::class);
158158
}
159159

160+
if (str_contains($extensionName, '.')) {
161+
[$extensionName,] = explode('.', $extensionName, 2);
162+
}
163+
160164
if (self::$userConfiguration->usedForCore) {
161-
$isCoreExt = false;
162-
foreach (LanguageServiceXclassed::CORE_EXTENSIONS as $extension) {
163-
if (str_contains($id, 'EXT:' . $extension)) {
164-
$isCoreExt = true;
165+
$isCoreExt = in_array($extensionName, LanguageServiceXclassed::CORE_EXTENSIONS, true);
166+
if (!$isCoreExt) {
167+
foreach (LanguageServiceXclassed::CORE_EXTENSIONS as $extension) {
168+
if (str_contains($id, 'EXT:' . $extension)) {
169+
$isCoreExt = true;
170+
break;
171+
}
165172
}
166173
}
167174
if ($isCoreExt) {
168175
$locale = 't3';
169176
} else {
170-
$locale = 'default';
177+
$locale = 'en';
171178
}
172179
} elseif (self::$userConfiguration->crowdinIdentifier) {
173180
if ($extensionName === self::$userConfiguration->extensionKey
174181
|| str_contains($id, 'EXT:' . self::$userConfiguration->extensionKey)) {
175182
$locale = 't3';
176183
} else {
177-
$locale = 'default';
184+
$locale = 'en';
178185
}
179186
}
180187

Classes/Xclass/LanguageServiceXclassed.php

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ public function sL($input): string
6363
return parent::sL($input);
6464
}
6565

66-
protected function includeLanguageFileRaw($fileRef)
67-
{
68-
$this->reinitLanguage($fileRef);
69-
70-
return parent::includeLanguageFileRaw($fileRef);
71-
}
72-
7366
protected function readLLfile($fileRef): array
7467
{
7568
$this->reinitLanguage($fileRef);
@@ -84,18 +77,34 @@ protected function reinitLanguage($path): void
8477
}
8578
$typo3Version = (new Typo3Version())->getMajorVersion();
8679

80+
// TYPO3 v14 switched from "default" to "en" as default language, which makes more sense
81+
$defaultLanguageCode = $typo3Version >= 14 ? 'en' : 'default';
82+
$resetLanguageCode = null;
83+
8784
$this->loadUserConfiguration();
8885
if ($this->userConfiguration->usedForCore) {
8986
$isCoreExt = false;
90-
foreach (self::CORE_EXTENSIONS as $extension) {
91-
if (str_contains($path, 'EXT:' . $extension)) {
92-
$isCoreExt = true;
87+
$extensionName = null;
88+
if ($typo3Version >= 14) {
89+
if (!str_contains($path, ':') && str_contains($path, '.')) {
90+
// This looks like a domain string
91+
[$extensionName,] = explode('.', $path, 2);
92+
}
93+
}
94+
if ($extensionName !== null) {
95+
$isCoreExt = in_array($extensionName, self::CORE_EXTENSIONS, true);
96+
} else {
97+
foreach (self::CORE_EXTENSIONS as $extension) {
98+
if (str_contains($path, 'EXT:' . $extension)) {
99+
$isCoreExt = true;
100+
break;
101+
}
93102
}
94103
}
95104
if ($isCoreExt) {
96-
$this->lang = 't3';
105+
$resetLanguageCode = 't3';
97106
} else {
98-
$this->lang = $typo3Version >= 14 ? 'en' : 'default';
107+
$resetLanguageCode = $defaultLanguageCode;
99108
}
100109
} elseif ($this->userConfiguration->crowdinIdentifier) {
101110
$useT3 = str_contains($path, 'EXT:' . $this->userConfiguration->extensionKey);
@@ -104,11 +113,16 @@ protected function reinitLanguage($path): void
104113
$useT3 = str_starts_with($path, $this->userConfiguration->extensionKey . '.');
105114
}
106115
if ($useT3) {
107-
$this->lang = 't3';
116+
$resetLanguageCode = 't3';
108117
} else {
109-
$this->lang = $typo3Version >= 14 ? 'en' : 'default';
118+
$resetLanguageCode = $defaultLanguageCode;
110119
}
111120
}
121+
122+
// Actually reinitialize if needed
123+
if ($resetLanguageCode !== null) {
124+
$this->init($resetLanguageCode);
125+
}
112126
}
113127

114128
protected function loadUserConfiguration(): void

0 commit comments

Comments
 (0)