Review main Abandoned

77253[WIP][FEATURE] Add Locale to Context API

Benni Mack CR 0 V 0 Normal +190 −28 updated 01/24/23, 13:58

Commit message

A new locale class is added in order to migrate the
code base and the configuration towards real locales in
form of RFC 5646 language tag (en-AT) and optional
script code ("Hans") and optional country / region
based on ISO 3166-1.
This unifies handling of locales instead of dealing
with "default" or other TYPO3-specific namings in
user-land code and configuration.

This locale functionality at first serves
to handle "label files" (XLF), but will
be further extended to also work with the locale
to be used in the SiteLanguage object to simplify
configuration.

Thus, the first and foremost topic is
to allow to create custom "LanguageService"
objects out of the Context API for example.

Concept:
1) The locale class contains the actual
   locale (such as "de-AT" or "en") but
   also allows to use the Typo3Language
   for the labels internally. It also
   contains the dependencies, so they
   do not need to be evaluated in various places

2) The locale is attached the Context API
   as "locale" aspect, making it easier
   in the future to move away from TSFE->sL()
   and BE_USER->lang properties. The
   LanguageServiceFactory can now be
   created by the Context API
   As a default locale Aspect = "en" (= default)
   is always added.

3) Translations should not be bound to TYPO3-mighty-power classes
   such as $GLOBALS[TSFE] and $GLOBALS[BE_USER] in the future anymore.

4) The SiteLanguage.locale now uses the Locale
   object, as Locale uses a Stringable interface.

Next to the introcution of the Locale and LocaleAspect
objects, this patch also adapts various places which touch
current LanguageService instantiations to use the Locale,
and also populates the Context API in Frontend (SiteLanguage),
Backend (BE_USER) and CLI (BE_USER).

Further ToDos:
* Reduce optional settings in Site Language object and editing interface
* A new languageService ($GLOBALS[LANG]) could and
   should be instantiated where it is needed, and not
   by re-using the same $GLOBALS[LANG] as this is needed
   This Reduce usages on $GLOBALS[LANG] by building
   a new LanguageService object based on the Context everywhere.
* Ideally deprecate $GLOBALS[LANG] in TYPO3 v12 LTS.

Review

  • Code review CR 0

    Imported before Forger kept the single votes, the next import adds them.

  • Verified V 0

    Imported before Forger kept the single votes, the next import adds them.

Issues 1

Files 14