Created
May 25, 2020 04:13
-
-
Save chinchang/0a5d2ba82244ab2ac6314e1a44350094 to your computer and use it in GitHub Desktop.
Handling singular/plural for number units
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Intl.NumberFormat(undefined, { | |
style: "unit", | |
unit: 'kilometer', | |
unitDisplay: 'long' | |
}).format(10) | |
//"10 kilometres" | |
new Intl.NumberFormat(undefined, { | |
style: "unit", | |
unit: 'kilometer', | |
unitDisplay: 'long' | |
}).format(1) | |
// "1 kilometre" | |
new Intl.NumberFormat('hi-EN', { | |
style: "unit", | |
unit: 'kilometer', | |
unitDisplay: 'long' | |
}).format(1) | |
// "1 किलोमीटर" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment