Skip to content

Conversation

@calien666
Copy link
Member

Since php 8.4 the ext-intl class NumberFormatter expects a strict locale string and throws a ValueError if the given value cannot get parsed.

Together with the uc of TYPO3, which holds the backend language for the currently logged-in user, this could be set to default, which is no valid locale. New TYPO3 instances will write a uc['lang']='', if the person uses englisch, which is the default, but older used to write us['lang']='default', which is still correct.

This throws the ValueError if the NumberFormatter should format with this setting.

Introduce the Locales class as a constructor argument to the UsageService and use the static methods converting the given uc-value to a correct language string ensuring NumberFormatter doing his job.

Fixes #486

Since php 8.4 the ext-intl class `NumberFormatter` expects a strict
locale string and throws a `ValueError` if the given value cannot get
parsed.

Together with the `uc` of TYPO3, which holds the backend language for
the currently logged-in user, this could be set to `default`, which is
no valid locale. New TYPO3 instances will write a `uc['lang']=''`, if
the person uses `englisch`, which is the default, but older used to
write `us['lang']='default'`, which is still correct.

This throws the `ValueError` if the NumberFormatter should format with
this setting.

Introduce the `Locales` class as a constructor argument to the
`UsageService` and use the static methods converting the given uc-value
to a correct language string ensuring NumberFormatter doing his job.

Fixes #486
@calien666 calien666 requested a review from sbuerk September 21, 2025 10:37
calien666 added a commit that referenced this pull request Sep 21, 2025
Since php 8.4 the ext-intl class `NumberFormatter` expects a strict
locale string and throws a `ValueError` if the given value cannot get
parsed.

Together with the `uc` of TYPO3, which holds the backend language for
the currently logged-in user, this could be set to `default`, which is
no valid locale. New TYPO3 instances will write a `uc['lang']=''`, if
the person uses `englisch`, which is the default, but older used to
write `us['lang']='default'`, which is still correct.

This throws the `ValueError` if the NumberFormatter should format with
this setting.

The Locales usage is not used here (other than on #491), as TYPO3 11
does not provide the necessary functions here.

Fixes #486
sbuerk pushed a commit that referenced this pull request Sep 23, 2025
Since php 8.4 the ext-intl class `NumberFormatter` expects a strict
locale string and throws a `ValueError` if the given value cannot get
parsed.

Together with the `uc` of TYPO3, which holds the backend language for
the currently logged-in user, this could be set to `default`, which is
no valid locale. New TYPO3 instances will write a `uc['lang']=''`, if
the person uses `englisch`, which is the default, but older used to
write `us['lang']='default'`, which is still correct.

This throws the `ValueError` if the NumberFormatter should format with
this setting.

The Locales usage is not used here (other than on #491), as TYPO3 11
does not provide the necessary functions here.

Fixes #486
@sbuerk sbuerk merged commit db52057 into main Sep 23, 2025
9 checks passed
@sbuerk sbuerk deleted the bugfix/issue-486 branch September 23, 2025 06:16
sbuerk pushed a commit that referenced this pull request Sep 23, 2025
Since php 8.4 the ext-intl class `NumberFormatter` expects a strict
locale string and throws a `ValueError` if the given value cannot get
parsed.

Together with the `uc` of TYPO3, which holds the backend language for
the currently logged-in user, this could be set to `default`, which is
no valid locale. New TYPO3 instances will write a `uc['lang']=''`, if
the person uses `englisch`, which is the default, but older used to
write `us['lang']='default'`, which is still correct.

This throws the `ValueError` if the NumberFormatter should format with
this setting.

The Locales usage is not used here (other than on #491), as TYPO3 11
does not provide the necessary functions here.

Fixes #486
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] NumberFormatter::__construct(): Argument #1 ($locale) "default" is invalid

3 participants