Localization API
See original GitHub issueI can see that your library supports some localization via separator
, symbols
and fullforms
.
I guess, for Russian it would be something like:
filesize(..., {
separator: ',',
symbols: {
B: "Б",
KB: "кБ",
MB: "мБ",
...
},
fullforms: [
'',
'кило',
'мега',
...
]
})
You could make a directory called locales
where people could submit pull requests with their languages.
import ru from 'filesize/locales/ru'
filesize(..., { locale: ru })
A similar API: https://github.com/sindresorhus/pretty-bytes#readme
// Localized output using German locale
prettyBytes(1337, {locale: 'de'});
//=> '1,34 kB'
Notice how they also use ,
in that example.
That’s because they use number.toLocaleString()
instead of separator
.
They should have also checked for number.toLocaleString
existence before using it and then fall back to a default separator.
They also don’t have kB
translated.
These are localization API ideas you might want to review in some future if you decide on adding localization to this library.
I don’t need localization, I’m using en-US
.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:16 (8 by maintainers)
Top GitHub Comments
I don’t care about what you care and don’t care. You’re a low-skill develoepr.
i don’t care if my code breaks in a deprecated browser that only runs in an OS that’s 10+ years out dated. I just don’t care. I don’t care if you want this feature to work on modern browsers and netscape 1.0.
You’re not paying me money, so I don’t care.