I tried the following code:
let units: [ByteCountFormatter.Units] = [.useBytes, .useKB, .useMB, .useGB, .useTB, .usePB, .useEB, .useZB, .useYBOrHigher]
let localizedDescriptions = units.map { (unit) -> String in
let formatter = ByteCountFormatter()
formatter.includesCount = false
formatter.includesUnit = true
formatter.allowedUnits = [unit]
formatter.countStyle = .file
return formatter.string(fromByteCount: .max)
}
And expect it to be localized according to the documentation.
Class
ByteCountFormatter
A formatter that converts a byte count value into a localized description that is formatted with the appropriate byte modifier (KB, MB, GB and so on).
But unfortunately, I got only:
["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
I tested:
- Switch system locale and reload my mac(Saw different file size format in finder: "КБ", "МБ"... instead of "KB", "MB")
- Playground/macOS template project.
- Switched "Application language" in macOS template project.
PS
In any case thanks for reading this...