Numbers
Curating patterns to your user's cultural expectations will always provide a better experience. However, knowing all the distinctions between groups of people and their behaviors are very challenging.
The table below has a list of most of the possible combinations of locales.
Counting
Use numerals when counting, do not spell numbers unless they are larger than 6 digits. In this exception, you may used named numbers. Some names are localized depending on the scale.
- 3 apples
- 100 large ducks
- 1 million people
Unit measurement
Localization of units is typically in Metric, except for a few countries. Please refer to the list of metricified countries to determine if special changes must be made based on locale. Abbreviations are permitted as long as they are non-ambiguous to other units.
fr-FR
10 metersen-US
3 inmy
3 လမု
Decimals
Use numerals when providing percentages, pay attention to localization methods of using the percent sign (%).
en-US
50%tr-TR
%50fr-FR
50 %
Datetime
Use a localized long form of dates where appropriate. If there is limited space, follow the format of YYYY-MM-DD (ISO-8601).
fi-FI
20. joulukuuta 2012en-PH
20 December 2012es-AR
20 de diciembre de 2012
Telephone
Use a localized format for telephone numbers, this can be a combination of spaces, hyphens, and/or parenthesis. There is no ISO standard, the ITU E.164 recommendation is acceptable.
en-PH
+63 (XXX) YYY ZZZZtr-TR
0BBB AAA AA AAen-US
NPA-NXX-XXXX
Currency
Use a localized format for displaying currencies. Position of the currency symbol may differ between locales. Refer to decimal reference above. Negative numbers are also formatted differently between locales.
pt-BR
R$ 1.234,56tr-TR
1,234.56 ₺en-NZ
$ 1,234.56
engineer Info
A simple method of localizing most of the above numbers can be done using the Intl
constructor found in modern browsers.
const date = new Date(Date.UTC(2012, 11, 21, 4, 0, 0));
const formatted = new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
}).format(date);
console.log(formatted); // "December 20, 2012" (varies by UTC timezone)
This method is especially recommended to provide solutions for displaying currency.
const number = 123456.789;
const formatted = new Intl.NumberFormat('ja-JP', {
style: 'currency',
currency: 'JPY'
}).format(number);
console.log(formatted); // "¥123,457"