Project

General

Profile

Actions

Bug #101211

closed

GeneralUtility::formatSize does not use correct thousands separator

Added by Robert Vock 10 months ago. Updated 10 months ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2023-06-30
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.1
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

The class GeneralUtility::formatSize does not use the correct thousands separator based on the language of the current page.

This was working in TYPO3 v9 and stopped working in TYPO3 v10:
https://forge.typo3.org/issues/82491
https://forge.typo3.org/projects/typo3cms-core/repository/1749/revisions/0d6f0460798048aa22ebaf57a254ad22d52a9d88/diff/typo3/sysext/core/Classes/Utility/GeneralUtility.php

setlocale(LC_NUMERIC, 'de_DE.utf-8') is not called anymore.

Steps to reproduce:

  1. Create a Site Configuration with german language (locale: de_DE.utf-8)
  2. Call GeneralUtility::formatSize(1024*1024*2.5) within your site extension code

Expected output
2,50 Mi

Actual output
2.50 Mi


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #82491: FluidStyledContent Header/Date.html Partial should respect config.locale_all typoscript setting for date format frontend outputClosedBenni Mack2017-09-15

Actions
Actions #1

Updated by Robert Vock 10 months ago

  • Related to Bug #82491: FluidStyledContent Header/Date.html Partial should respect config.locale_all typoscript setting for date format frontend output added
Actions #2

Updated by Torben Hansen 10 months ago

Problem ist valid, however not that easy to resolve from a global perspective - see https://github.com/TYPO3/typo3/blob/v12.4.2/typo3/sysext/core/Classes/Localization/Locales.php#L379

One solution may be to set the locale manually in GeneralUtility::formatSize() again in order to get expected output, but: the function should then separate between frontend and backend requests, since the locale for frontend requests is set in Locales.php and for backend context, only some functions in TYPO3 core respect the $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale'] setting and locale ist not set globally.

Since the functions main purpose is formatting a given size in bytes, it would be an option to detach locale settings from the function and add the decimal separator as argument.

Actions #3

Updated by Susanne Moog 10 months ago

Previously, the function considered the set TSFE locale (if given), see patch that removed the functionality in https://review.typo3.org/c/Packages/TYPO3.CMS/+/64045/3/typo3/sysext/core/Classes/Utility/GeneralUtility.php

Actions #4

Updated by Gerrit Code Review 10 months ago

  • Status changed from New to Under Review

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

Actions #5

Updated by Gerrit Code Review 10 months ago

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

Actions #6

Updated by Gerrit Code Review 10 months ago

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

Actions #7

Updated by Gerrit Code Review 10 months ago

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

Actions #8

Updated by Gerrit Code Review 10 months ago

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

Actions #9

Updated by Susanne Moog 10 months ago

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

Also available in: Atom PDF