Project

General

Profile

Actions

Task #91971

closed

Add language ISO information to the Language Aspect

Added by Xavier Perseguers over 4 years ago. Updated 12 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Localization
Target version:
-
Start date:
2020-08-11
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

Until TYPO3 v8 a developer could get the 2-letter ISO code of the current language by accessing:

$GLOBALS['TSFE']->lang

In TYPO3 v9, this information is still freely available (not deprecated), although marked as internal but it changed to default instead of en. The change is logical since it was always supposed to be a TYPO3 language and not an ISO code but this is a breaking change and forces developers to adapt.

In TYPO3 v9, the official way to access (current) $GLOBALS['TSFE']->lang is to do

$GLOBALS['TYPO3_REQUEST']->getAttribute('language')->getTypo3Language()

and the only way to get the former content, the real ISO code, is to do

$GLOBALS['TYPO3_REQUEST']->getAttribute('language')->getTwoLetterIsoCode()

Both of them are bad since it means replacing a $GLOBALS[] by another one.

I would expect to be able to read that information using the Language Aspect introduced in TYPO3 v9 (https://usetypo3.com/9lts-api-classes.html#c717) for example like that:

GeneralUtility::makeInstance(Context::class)->getAspect('language')->getTwoLetterIsoCode()

So in my opinion, the language aspect should be extended to provide really useful ISO information as well.

Actions #1

Updated by Xavier Perseguers over 4 years ago

  • Subject changed from Add language ISO information to the aspects to Add language ISO information to the Language Aspect
Actions #2

Updated by Benni Mack over 3 years ago

  • Status changed from New to Needs Feedback

Question is: do you want the ISO code or the TYPO3 System Language (as you had in TYPO3 v8)?

The Language Aspect in general was built when querying records from the database. However, IF we'd ever decide on moving to "sys_language" independent records, I assume we should use the two-letter-iso code in favor of TYPO3-internal system language?

Actions #3

Updated by Benni Mack 12 months ago

In the meantime, we've migrated to a new Locale system for labels in v12, which uses https://www.rfc-editor.org/rfc/bcp/bcp47.txt BCP-47 under-the-hood with language codes and country codes in combination. Does this solve your issue?

Actions #4

Updated by Xavier Perseguers 12 months ago

  • Status changed from Needs Feedback to Closed
  • % Done changed from 0 to 100

From my point of view this has "fixed" itself in the mean time :)

Actions

Also available in: Atom PDF