Project

General

Profile

Actions

Bug #87101

closed

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

Added by Sebastian Mazza over 5 years ago. Updated almost 5 years ago.

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

100%

Estimated time:
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.

Actions #1

Updated by Josef Glatz over 5 years ago

  • Is Regression set to Yes
Actions #2

Updated by Gerrit Code Review over 5 years 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

Actions #3

Updated by Gerrit Code Review over 5 years 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

Actions #4

Updated by Benni Mack over 5 years 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

Actions #5

Updated by Sebastian Mazza over 5 years 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    

Actions #6

Updated by Sebastian Mazza over 5 years 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

Actions #7

Updated by Guido Schmechel over 5 years 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?

Actions #8

Updated by Benni Mack over 5 years 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.

Actions #9

Updated by Sebastian Mazza over 5 years 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.

Actions #10

Updated by Guido Schmechel over 5 years ago

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

Actions #11

Updated by Gerrit Code Review over 5 years 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

Actions #12

Updated by Gerrit Code Review over 5 years 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

Actions #13

Updated by Gerrit Code Review over 5 years 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

Actions #14

Updated by Gerrit Code Review over 5 years 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

Actions #15

Updated by Gerrit Code Review over 5 years 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

Actions #16

Updated by Guido Schmechel over 5 years ago

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

Updated by Benni Mack almost 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF