Bug #101211
closedGeneralUtility::formatSize does not use correct thousands separator
100%
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:
- Create a Site Configuration with german language (locale: de_DE.utf-8)
- Call
GeneralUtility::formatSize(1024*1024*2.5)
within your site extension code
Expected output2,50 Mi
Actual output2.50 Mi
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
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.
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
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
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
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
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
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
Updated by Susanne Moog 10 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 508c963b98abc120396d0ab026c93181da13f9d7.