RepoPilot

Does this respect the user's locale for number formatting?

About sindresorhus/pretty-bytes · 2 messages · last activity 6/8/2026

Question

Does this respect the user's locale for number formatting?

RepoPilot

Yes, the pretty-bytes library does respect the user's locale for number formatting through the locale option.

According to the README, the locale option allows you to control localization:

  • false (default): Output won't be localized.
  • true: Localizes the output using the system/browser locale.
  • string: Expects a BCP 47 language tag (e.g., en, de).
  • string[]: Expects a list of BCP 47 language tags.

The README includes this example showing German locale formatting:

prettyBytes(1337, {locale: 'de'});
//=> '1,34 kB'

Notice how the decimal separator changes from . (English) to , (German), demonstrating locale-aware number formatting.

However, the index coverage for this repository is minimal (8 of 8 eligible files), and I cannot see the actual implementation details. To understand how the locale formatting is implemented under the hood, you would need to examine the source code directly—likely the main entry point file in the repository.

FOLLOW_UPS:

  • How does the library handle unsupported locale strings?
  • Can you combine locale with other options like binary or bits?
  • What's the default decimal precision across locales?

Want to ask your own question?

Open chat for sindresorhus/pretty-bytes

Public Q&A. Generated by RepoPilot from the actual source of sindresorhus/pretty-bytes. AI answers can be incomplete or stale — verify before relying on them.