Format the memory

@param  int    $memory Memory in bytes
@param  string $locale
@return string
972940
public function format($memory, $params = null, $locale = null) {
		if ($memory == 0) {
			return 0;
		}

		if ($memory < 1024) {
			return round($memory) . 'b';
		}

		if ($memory < 1048576) {
			return round($memory / 1024, 2) . 'K';
		}

		if ($memory < 10485760) {
			return round($memory / 1024, 1) . 'K';
		}

		if ($memory < 104857600) {
			return round($memory / 1048576, 2) . 'M';
		}

		if ($memory < 1073741824) {
			return round($memory / 1048576, 1) . 'M';
		}

		if ($memory < 10737418240) {
			return round($memory / 1073741824, 2) . 'G';
		}
		
		return round($memory / 1073741824, 1) . 'G';
	}
275871
protected static function formatMessage(string $locale, string $message, array $args): string
    {
        // underlying `format` method cannot work with arguments that are not convertible to string
        // therefore we have to check that only those that actually can be used
        assert(call_user_func(function () use ($args) : bool {
            $result = true;
            foreach ($args as $arg) {
                $result = $result &&
                    is_scalar($arg) === true ||
                    $arg === null ||
                    (is_object($arg) === true && method_exists($arg, '__toString') === true);
            }

            return $result;
        }));

        $formatter = MessageFormatter::create($locale, $message);
        $message   = $formatter->format($args);
        assert($message !== false, $formatter->getErrorMessage());

        return $message;
    }
541902
public function load($locale, $filename)
    {
        $textDomain = parent::load($locale, $filename);

        $localeInfo = Language::getById($locale);
        if ($localeInfo !== null) {
            $this->fixPlurals($filename, $textDomain, $localeInfo);
        }

        return $textDomain;
    }
1370889
public function formatPrice($price, $currency, $locale = null)
    {
        return $this->priceManager->getFormattedPrice($price, $currency, $locale);
    }
1326448
protected function getCurrentLocale($locale = null)
    {
        return null !== $locale
            ? LocaleUtils::formatLocale($locale)
            : $this->getLocale();
    }
1185231
public function locale($locale = null)
    {
        if ($locale) {
            // Normalize the language
            self::$locale = strtolower(str_replace([' ', '_'], '-', $locale));
        }

        return self::$locale;
    }
174743
public function formatToWholeNumbers(
        $float,
        $locale = null
    ) {
        if (is_null($locale)) {
            $locale = $this->defaultLocale;
        }

        $formatter = $this->retrieveDecimalFormatter($locale);

        return $formatter->format($float);
    }
290735
public static function setLocale(string $locale)
    {
        self::$runtimeLocale = self::getCompatibleLocale($locale);
        Response::setCookieHttpOnly(Language::LANGUAGE_COOKIE_NAME, self::$runtimeLocale);
    }
1154585
protected function getFormatter($locale, $digits)
    {
        $formatter = $this->retrieveDecimalFormatter($locale);
        $formatter->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, $digits);
        $formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, $digits);
        $formatter->setAttribute(NumberFormatter::DECIMAL_ALWAYS_SHOWN, 1);

        return $formatter;
    }
348157
public function getDeliveryCostFormatted($locale = null)
    {
        $formatter = $this->getFormatter($locale);

        return $formatter->format((float)$this->entity->getDeliveryCost());
    }
505079
public function localizedSystemName($name, $locale)
    {
        if (null === $locale) {
            throw new InvalidLocaleException($locale);
        }

        return $this->formatLocalizedName('system_localized', $name, $locale);
    }
56366
protected function lookupLocale(array $locales, string $locale, string $defaultLocale): string
    {
        // for some odd reason locale_lookup returns empty string but not default locale if input locales are empty
        return empty($locales) === true ? $defaultLocale : locale_lookup($locales, $locale, false, $defaultLocale);
    }
569527
public function setLocale($locale = null)
    {
        $locale = self::_prepareLocale($locale);

        if (isset(self::$_localeData[(string) $locale]) === false) {
            $region = substr((string) $locale, 0, 3);
            if (isset($region[2]) === true) {
                if (($region[2] === '_') or ($region[2] === '-')) {
                    $region = substr($region, 0, 2);
                }
            }

            if (isset(self::$_localeData[(string) $region]) === true) {
                $this->_locale = $region;
            } else {
                $this->_locale = 'root';
            }
        } else {
            $this->_locale = $locale;
        }
    }
6343
protected static function createFormatter(
        ContainerInterface $container,
        string $namespace,
        string $locale = null
    ): FormatterInterface {
        /** @var FormatterFactoryInterface $factory */
        $factory   = $container->get(FormatterFactoryInterface::class);
        $formatter = $locale === null ?
            $factory->createFormatter($namespace) : $factory->createFormatterForLocale($namespace, $locale);

        return $formatter;
    }
230089
public function setLocale($locale)
    {
        $this->locale = $locale;

        $this->getContentRoute()->setLocale($locale);

        return $this;
    }
1190523
public static function getLanguageFromLocale($locale)
    {
        if (strpos($locale, '_')) {
            $parts = explode('_', $locale);

            return strtolower($parts[0]);
        }

        return $locale;
    }
626705
public String formatAsString(final Cell cell, final Locale locale) {
        return format(cell, locale).getText();
    }