Bug #87101

in TYPO3 v9.5 user defined locales can not be added by an extension any more

Added by Sebastian Mazza 3 months ago. Updated 2 months ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2018-12-07
Due date:
% Done:

100%

TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

At least in TYPO3 v. 7.x ist was possible for an extension to add a new local definition to the the TYPO3 localisation system.

This was posible by adding

$GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['user']['en'] = 'English';

to the ext_localconf.php of an extension.
(See: https://docs.typo3.org/typo3cms/CoreApiReference/latest/ApiOverview/Internationalization/ManagingTranslations.html#custom-languages)

In TYPO3 v9.5 this does not work any more because the method
typo3/sysext/core/Classes/Localization/Locales.php::initialize() which inizaliazes all the locales,
is called from typo3/sysext/core/Classes/Core/Bootstrap.php in line 123 but the ext_localconf.php are included after that in line 138 of the Bootstrap.php::init() method.

Associated revisions

Revision 5668d61a (diff)
Added by Guido Schmechel 2 months ago

[BUGFIX] Reimplement custom BE languages

Because of a regression the backend does not load custom BE languages.
The loading order is changed so that custom languages are available
again.

Resolves: #87101
Releases: master, 9.5
Change-Id: I0530957abc49f775497d9644047cbb49ceffcda9
Reviewed-on: https://review.typo3.org/59068
Tested-by: TYPO3com <>
Reviewed-by: Christian Kuhn <>
Tested-by: Christian Kuhn <>
Reviewed-by: Wouter Wolters <>
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>

Revision 818f751d (diff)
Added by Guido Schmechel 2 months ago

[BUGFIX] Reimplement custom BE languages

Because of a regression the backend does not load custom BE languages.
The loading order is changed so that custom languages are available
again.

Resolves: #87101
Releases: master, 9.5
Change-Id: I0530957abc49f775497d9644047cbb49ceffcda9
Reviewed-on: https://review.typo3.org/59240
Tested-by: TYPO3com <>
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>

History

#1 Updated by Josef Glatz 2 months ago

  • Is Regression set to Yes

#2 Updated by Gerrit Code Review 2 months ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59068

#3 Updated by Gerrit Code Review 2 months ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59068

#4 Updated by Benni Mack 2 months ago

Loading order is an important here, and can likely break.

TBH, looking at Code in TYPO3 v7.6 it is exactly at the same place as in v9. AFTER AdditionalConfiguration and BEFORE ext_localconf inclusion. This means _ if _ we change something here (like "initializing Locales AFTER ext_localconf.php) this is a breaking change. because ANY extension could depend on Locales being already initialized.

In docs I did not find any place where ext_localconf.php is mentioned to add user-defined locales - in our projects we always place it in AdditionalConfiguration.php or LocalConfiguration.php, as it is project-specific.

So there are two ways to solve this:
- Re-initialize Locales after ext_localconf.php (but keep it before as well to maintain backwards compatibility) with a note to remove the first initialize() call in v10.0 (= breaking) - this has a little bit of performance drawbacks (because it is instantiated at every call).
- Call Locales::initialize() in your extensions' ext_localconf.php after adding the user-defined locales

#5 Updated by Sebastian Mazza 2 months ago

When the order of AdditionalConfiguration and ext_localconf.php inclusion in TYPO3 v7.6 was the same as in v9.5. How was it possible to use xlf files for e.g. "en" by adding $GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['user']['en'] = 'English'; to the ext_localconf.php of an extension?

I think the answer is: In TYPO3 v7.6 the Locales::initialize method is called a second time from the TypoScriptFrontendController.

Call stack of the first execution:

Classes/Localization/Locales.php.TYPO3\CMS\Core\Localization\Locales::initialize:143
Classes/Core/Bootstrap.php.TYPO3\CMS\Core\Core\Bootstrap->initializeL10nLocales:649
Classes/Core/Bootstrap.php.TYPO3\CMS\Core\Core\Bootstrap->loadConfigurationAndInitialize:405
Classes/Core/Bootstrap.php.TYPO3\CMS\Core\Core\Bootstrap->configure:171
Classes/Http/Application.php.TYPO3\CMS\Frontend\Http\Application->__construct:67
www/index.php.{closure:XXXXX/typo3_src-7.6.30/index.php:31-34}:33
www/index.php.{main}:34    

Call stack of the second execution:

Classes/Localization/Locales.php.TYPO3\CMS\Core\Localization\Locales::initialize:143
Classes/Controller/TypoScriptFrontendController.php.TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->initLLvars:4612
Classes/Controller/TypoScriptFrontendController.php.TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->settingLanguage:2694
Classes/Http/RequestHandler.php.TYPO3\CMS\Frontend\Http\RequestHandler->handleRequest:187
Classes/Core/Bootstrap.php.TYPO3\CMS\Core\Core\Bootstrap->handleRequest:308
Classes/Http/Application.php.TYPO3\CMS\Frontend\Http\Application->run:78
www/index.php.{closure:XXXXX/typo3_src-7.6.30/index.php:31-34}:33
www/index.php.{main}:34    

#6 Updated by Sebastian Mazza 2 months ago

In TYPO3 v9.5 the Locales::initialize() method is only called once.

Call Stack:

Classes/Localization/Locales.php.TYPO3\CMS\Core\Localization\Locales::initialize:139
Classes/Core/Bootstrap.php.TYPO3\CMS\Core\Core\Bootstrap::init:123
index.php.{closure:XXXX/TYPO3.CMS/index.php:21-25}:24
index.php.{main}:25

#7 Updated by Guido Schmechel 2 months ago

I think that makes sense to implement that again at the TypoScriptFrontendController. Presumably this is there, because in TypoScript also languages can be overwritten?

Benni: What do you say to that?

#8 Updated by Benni Mack 2 months ago

Guido Schmechel wrote:

I think that makes sense to implement that again at the TypoScriptFrontendController. Presumably this is there, because in TypoScript also languages can be overwritten?

Benni: What do you say to that?

Thanks for further information!

Just rechecked, seems like v8 worked the same way as v7. In order to fix this, we should add this again into v9/master at the same place, with a note why this is done.

However, we should then create a followup patch to add this AFTER ext_localconf.php in the bootstrap for master later on as a breaking change.

#9 Updated by Sebastian Mazza 2 months ago

Benni Mack wrote:

Just rechecked, seems like v8 worked the same way as v7. In order to fix this, we should add this again into v9/master at the same place, with a note why this is done.

However, we should then create a followup patch to add this AFTER ext_localconf.php in the bootstrap for master later on as a breaking change.

I think this is a good approach.

#10 Updated by Guido Schmechel 2 months ago

I will edit the current patch und build then a follow-up patch. Thanks for your feedback!

#11 Updated by Gerrit Code Review 2 months ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59068

#12 Updated by Gerrit Code Review 2 months ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59068

#13 Updated by Gerrit Code Review 2 months ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59068

#14 Updated by Gerrit Code Review 2 months ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59068

#15 Updated by Gerrit Code Review 2 months ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59240

#16 Updated by Guido Schmechel 2 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF