$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
--- /dev/null
+=================================================================
+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