diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index 769dca7c764dd6a8fd812ba4d361d40d40f18b74..90b97c99a119f404096d5730957e57f4fe38d9fd 100644 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -960,18 +960,28 @@ class GeneralUtility { $labelArr = explode('|', $labels); // Find size: if ($sizeInBytes > 900) { + // TODO find out which locale is used for current BE user to cover the BE case as well + $locale = is_object($GLOBALS['TSFE']) ? $GLOBALS['TSFE']->config['config']['locale_all'] : ''; + $oldLocale = setlocale(LC_NUMERIC, 0); + if ($locale) { + setlocale(LC_NUMERIC, $locale); + } + $localeInfo = localeconv(); + if ($locale) { + setlocale(LC_NUMERIC, $oldLocale); + } // GB if ($sizeInBytes > 900000000) { $val = $sizeInBytes / (1024 * 1024 * 1024); - return number_format($val, ($val < 20 ? 1 : 0), '.', '') . $labelArr[3]; + return number_format($val, ($val < 20 ? 1 : 0), $localeInfo['decimal_point'], '') . $labelArr[3]; } elseif ($sizeInBytes > 900000) { // MB $val = $sizeInBytes / (1024 * 1024); - return number_format($val, ($val < 20 ? 1 : 0), '.', '') . $labelArr[2]; + return number_format($val, ($val < 20 ? 1 : 0), $localeInfo['decimal_point'], '') . $labelArr[2]; } else { // KB $val = $sizeInBytes / 1024; - return number_format($val, ($val < 20 ? 1 : 0), '.', '') . $labelArr[1]; + return number_format($val, ($val < 20 ? 1 : 0), $localeInfo['decimal_point'], '') . $labelArr[1]; } } else { // Bytes diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-60152-formatSizeAdheresLocale.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-60152-formatSizeAdheresLocale.rst new file mode 100644 index 0000000000000000000000000000000000000000..11fc73cc428f698d48ddfe6f87693cbe8f525a3c --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-60152-formatSizeAdheresLocale.rst @@ -0,0 +1,31 @@ +================================================================= +Breaking: #60152 - GeneralUtility::formatSize is now locale aware +================================================================= + +Description +=========== + +The GeneralUtility::formatSize() method now adheres to the currently set locale and +selects the correct decimal separator symbol. +This also applies to the TypoScript option stdWrap.bytes, which uses the method internally, +as well as the Filelist content element type. + +Impact +====== + +All output generated for locales, where the decimal separator is not a dot, will change to use +the correct symbol. e.g. comma for German. + +Affected installations +====================== + +Any installation that uses the formatSize() method in one of the aforementioned ways. + +Migration +========= + +If you think you get the wrong decimal separator, ensure the locale is configured correctly +and the locale really exists on the server. + +TypoScript option: config.locale +Commandline: locale -a