The localization package provides methods to format dates, times, numbers, and prices according to the rules of a specific locale. For typography rules, see Microtypography.
#Dates
By default, we always display the date short with abbreviation
. We never use other date formats, outside of the defined ones.
- The year is not abbreviated.
- The year is displayed when, the date spans across a year change or it's stored for a longer period (timestamp).
- We always remove the leading "0" from the date numbers
- For the
short with abbreviation
format, the abbreviations dot is removed. - In EU countries the date format is always in the format of the main language of the country (e.g. all languages in France are formatted the way
fr-FR
is).
Name | Type | Default | Description | Controls |
---|---|---|---|---|
date * | string | number | Date | - | Target date to format | |
locale * | "de-AT" | "de-CH" | "de-DE" | "de-FR" | "de-NL" | "de-BE" | "de-IT" | "de-LU" | "en-AT" | "en-CH" | "en-DE" | "en-FR" | "en-NL" | "en-BE" | "en-IT" | "en-LU" | "fr-AT" | "fr-CH" | ... 21 more ... | "nl-LU" | - | Used locale for formatting | |
timeZone * | "Europe/Zurich" | "Europe/Berlin" | "Europe/Paris" | "Europe/Amsterdam" | "Europe/Brussels" | "Europe/Rome" | "Europe/Luxembourg" | "Europe/Vienna" | - | TimeZone | |
options | { variant?: "short"; weekday?: "long" | "short"; } | { variant: "medium"; } | { variant: "month-only"; } | - | Formatting options |
#Short with abbreviation
The default date format is short with abbreviation
including the abbrevated da of the week.
Sa, 31.12. | Di, 1.2. | So, 30.1. | Do, 1.12. | |
---|---|---|---|---|
de-AT | Sa, 31.12. | Di, 1.2. | So, 30.1. | Do, 1.12. |
en-AT | Sat, 31.12. | Tue, 1.2. | Sun, 30.1. | Thu, 1.12. |
de-BE | Sa, 31/12 | Di, 1/2 | So, 30/1 | Do, 1/12 |
en-BE | Sat, 31/12 | Tue, 1/2 | Sun, 30/1 | Thu, 1/12 |
fr-BE | sam, 31/12 | mar, 1/2 | dim, 30/1 | jeu, 1/12 |
nl-BE | za, 31/12 | di, 1/2 | zo, 30/1 | do, 1/12 |
de-CH | Sa, 31.12. | Di, 1.2. | So, 30.1. | Do, 1.12. |
en-CH | Sat, 31.12. | Tue, 1.2. | Sun, 30.1. | Thu, 1.12. |
fr-CH | sam, 31/12 | mar, 1/2 | dim, 30/1 | jeu, 1/12 |
it-CH | sab, 31.12. | mar, 1.2. | dom, 30.1. | gio, 1.12. |
de-DE | Sa, 31.12. | Di, 1.2. | So, 30.1. | Do, 1.12. |
en-DE | Sat, 31.12. | Tue, 1.2. | Sun, 30.1. | Thu, 1.12. |
en-FR | Sat, 31/12 | Tue, 1/2 | Sun, 30/1 | Thu, 1/12 |
fr-FR | sam, 31/12 | mar, 1/2 | dim, 30/1 | jeu, 1/12 |
en-IT | Sat, 31/12 | Tue, 1/2 | Sun, 30/1 | Thu, 1/12 |
it-IT | sab, 31/12 | mar, 1/2 | dom, 30/1 | gio, 1/12 |
de-NL | Sa, 31-12 | Di, 1-2 | So, 30-1 | Do, 1-12 |
en-NL | Sat, 31-12 | Tue, 1-2 | Sun, 30-1 | Thu, 1-12 |
nl-NL | za, 31-12 | di, 1-2 | zo, 30-1 | do, 1-12 |
#Medium date
In some cases we use the date medium
, for example if a date range is spaning over new year's eve.
- The abbreviated weekday is removed if the year is displayed
- The year is displayed when the two dates in a range span a change of year
Note: There is a shorthand method for medium dates called formatMediumDate()
.
It works exactly the same as formatDate()
but with a hardcoded
variant: medium
in the options.
31.12.2022 | 1.2.2022 | 30.1.2022 | 1.12.2022 | |
---|---|---|---|---|
de-AT | 31.12.2022 | 1.2.2022 | 30.1.2022 | 1.12.2022 |
en-AT | 31.12.2022 | 1.2.2022 | 30.1.2022 | 1.12.2022 |
de-BE | 31/12/2022 | 1/2/2022 | 30/1/2022 | 1/12/2022 |
en-BE | 31/12/2022 | 1/2/2022 | 30/1/2022 | 1/12/2022 |
fr-BE | 31/12/2022 | 1/2/2022 | 30/1/2022 | 1/12/2022 |
nl-BE | 31/12/2022 | 1/2/2022 | 30/1/2022 | 1/12/2022 |
de-CH | 31.12.2022 | 1.2.2022 | 30.1.2022 | 1.12.2022 |
en-CH | 31.12.2022 | 1.2.2022 | 30.1.2022 | 1.12.2022 |
fr-CH | 31/12/2022 | 1/2/2022 | 30/1/2022 | 1/12/2022 |
it-CH | 31.12.2022 | 1.2.2022 | 30.1.2022 | 1.12.2022 |
de-DE | 31.12.2022 | 1.2.2022 | 30.1.2022 | 1.12.2022 |
en-DE | 31.12.2022 | 1.2.2022 | 30.1.2022 | 1.12.2022 |
en-FR | 31/12/2022 | 1/2/2022 | 30/1/2022 | 1/12/2022 |
fr-FR | 31/12/2022 | 1/2/2022 | 30/1/2022 | 1/12/2022 |
en-IT | 31/12/2022 | 1/2/2022 | 30/1/2022 | 1/12/2022 |
it-IT | 31/12/2022 | 1/2/2022 | 30/1/2022 | 1/12/2022 |
de-NL | 31-12-2022 | 1-2-2022 | 30-1-2022 | 1-12-2022 |
en-NL | 31-12-2022 | 1-2-2022 | 30-1-2022 | 1-12-2022 |
nl-NL | 31-12-2022 | 1-2-2022 | 30-1-2022 | 1-12-2022 |
#Month only date
In some rare cases, day is not available in data, we use the month-only date format.
Note: In general, we avoid using this format, it's only used in defined special cases.
de-CH | en-CH | fr-FR | it-IT | nl-NL | |
---|---|---|---|---|---|
2023-01-01 | Januar 2023 | January 2023 | janvier 2023 | gennaio 2023 | januari 2023 |
2023-02-01 | Februar 2023 | February 2023 | février 2023 | febbraio 2023 | februari 2023 |
2023-03-01 | März 2023 | March 2023 | mars 2023 | marzo 2023 | maart 2023 |
2023-04-01 | April 2023 | April 2023 | avril 2023 | aprile 2023 | april 2023 |
2023-05-01 | Mai 2023 | May 2023 | mai 2023 | maggio 2023 | mei 2023 |
2023-06-01 | Juni 2023 | June 2023 | juin 2023 | giugno 2023 | juni 2023 |
2023-07-01 | Juli 2023 | July 2023 | juillet 2023 | luglio 2023 | juli 2023 |
2023-08-01 | August 2023 | August 2023 | août 2023 | agosto 2023 | augustus 2023 |
2023-09-01 | September 2023 | September 2023 | septembre 2023 | settembre 2023 | september 2023 |
2023-10-01 | Oktober 2023 | October 2023 | octobre 2023 | ottobre 2023 | oktober 2023 |
2023-11-01 | November 2023 | November 2023 | novembre 2023 | novembre 2023 | november 2023 |
2023-12-01 | Dezember 2023 | December 2023 | décembre 2023 | dicembre 2023 | december 2023 |
#Dates in React components
In react components, the useLocalization()
hook provides formatDate, by using the hook, there is no need to provide a locale.
import { useLocalization } from "@segments/localization";
const MediumDate = () => {
const { formatDate } = useLocalization();
return `Date: ${formatDate(date, { variant: "medium" })}`;
};
#Dates outside of React components
Outside of React components, the formatDate()
method requires a locale.
import { formatDate, formatMediumDate } from "@segments/localization";
// usage with shorthand method
formatMediumDate(new Date(), "de-CH", "Europe/Zurich");
// regular usage
formatDate("2023-05-26", "de-CH", "Europe/Zurich");
#Time
Currently all locales use the same time format.
Name | Type | Default | Description | Controls |
---|---|---|---|---|
date * | string | number | Date | - | Target date to format | |
locale * | "de-AT" | "de-CH" | "de-DE" | "de-FR" | "de-NL" | "de-BE" | "de-IT" | "de-LU" | "en-AT" | "en-CH" | "en-DE" | "en-FR" | "en-NL" | "en-BE" | "en-IT" | "en-LU" | "fr-AT" | "fr-CH" | ... 21 more ... | "nl-LU" | - | Used locale for formatting | |
timeZone * | string | - | TimeZone |
#Time format
01:00 | 02:00 | 11:00 | 13:05 | 00:45 | |
---|---|---|---|---|---|
de-AT | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
en-AT | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
de-BE | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
en-BE | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
fr-BE | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
nl-BE | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
de-CH | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
en-CH | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
fr-CH | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
it-CH | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
de-DE | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
en-DE | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
en-FR | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
fr-FR | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
en-IT | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
it-IT | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
de-NL | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
en-NL | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
nl-NL | 01:00 | 02:00 | 11:00 | 13:05 | 00:45 |
#Time ranges
Time ranges are connected by the en-dash character \u2013
without any spaces, example 01:00–02:35
Name | Type | Default | Description | Controls |
---|---|---|---|---|
endDate * | string | number | Date | - | End date to format | |
locale * | "de-AT" | "de-CH" | "de-DE" | "de-FR" | "de-NL" | "de-BE" | "de-IT" | "de-LU" | "en-AT" | "en-CH" | "en-DE" | "en-FR" | "en-NL" | "en-BE" | "en-IT" | "en-LU" | "fr-AT" | "fr-CH" | ... 21 more ... | "nl-LU" | - | Used locale for formatting | |
startDate * | string | number | Date | - | Start date to format | |
timeZone * | "Europe/Zurich" | "Europe/Berlin" | "Europe/Paris" | "Europe/Amsterdam" | "Europe/Brussels" | "Europe/Rome" | "Europe/Luxembourg" | "Europe/Vienna" | - | TimeZone |
#Time range format
01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 | |
---|---|---|---|---|---|
de-AT | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
en-AT | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
de-BE | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
en-BE | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
fr-BE | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
nl-BE | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
de-CH | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
en-CH | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
fr-CH | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
it-CH | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
de-DE | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
en-DE | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
en-FR | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
fr-FR | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
en-IT | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
it-IT | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
de-NL | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
en-NL | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
nl-NL | 01:00–02:00 | 02:00–03:00 | 11:00–12:00 | 13:05–14:05 | 00:45–01:45 |
#Time in React components
In React components, the useLocalization()
hook provides formatTime, formatTimeRange, by using the hook, there is no need to provide a locale.
import { useLocalization } from "@segments/localization";
const TimeRange = () => {
const { formatTimeRange } = useLocalization();
return `Time range: ${formatTimeRange(startDate, endDate)}`;
};
#Time outside of React components
Outside of React components, the formatTime()
or formatTimeRange()
method can be used directly, by providing a locale and a time zone.
formatTime(new Date(), "de-CH", "Europe/Zurich");
#Relative time
Describes the timespan between now and a past date, in a human-readable format.
- The relative time is always translated, into the current locale.
- Examples: "2 hours ago" or "10 years ago".
Name | Type | Default | Description | Controls |
---|---|---|---|---|
date * | string | number | Date | - | Target date to format | |
locale * | "de-AT" | "de-CH" | "de-DE" | "de-FR" | "de-NL" | "de-BE" | "de-IT" | "de-LU" | "en-AT" | "en-CH" | "en-DE" | "en-FR" | "en-NL" | "en-BE" | "en-IT" | "en-LU" | "fr-AT" | "fr-CH" | ... 21 more ... | "nl-LU" | - | Used locale for formatting | |
now * | string | number | Date | - | Used locale for formatting | |
timeZone * | string | - | TimeZone |
#Examples by locale
de-CH | en-CH | fr-FR | it-IT | nl-NL | |
---|---|---|---|---|---|
in 10 days | in 10 Tagen | in 10 days | dans 10 jours | tra 10 giorni | over 10 dagen |
in 2 days | übermorgen | day after tomorrow | après-demain | dopodomani | overmorgen |
in 1 day | morgen | tomorrow | demain | domani | morgen |
now, until midnight | heute | today | aujourd'hui | oggi | vandaag |
past 60 seconds | gerade eben | just now | à l'instant | proprio ora | zojuist |
minutes ago | vor einer Minute | 1 minute ago | il y a une minute | 1 minuto fa | 1 minuut geleden |
10 minutes ago | vor 10 Minuten | 10 minutes ago | il y a 10 minutes | 10 minuti fa | 10 minuten geleden |
1 hour ago | vor einer Stunde | 1 hour ago | il y a une heure | 1 ora fa | 1 uur geleden |
10 hours ago | vor 10 Stunden | 10 hours ago | il y a 10 heures | 10 ore fa | 10 uren geleden |
1 day ago | vor einem Tag | 1 day ago | il y a un jour | 1 giorno fa | 1 dag geleden |
6 days ago | vor 6 Tagen | 6 days ago | il y a 6 jours | 6 giorni fa | 6 dagen geleden |
1 week ago | vor einer Woche | 1 week ago | il y a une semaine | 1 settimana fa | 1 week geleden |
3 weeks ago | vor 3 Wochen | 3 weeks ago | il y a 3 semaines | 3 settimane fa | 3 weken geleden |
1 month ago | vor einem Monat | 1 month ago | il y a un mois | 1 mese fa | 1 maand geleden |
10 months ago | vor 10 Monaten | 10 months ago | il y a 10 mois | 10 mesi fa | 10 maanden geleden |
1 year ago | vor einem Jahr | 1 year ago | il y a un an | 1 anno fa | 1 jaar geleden |
10 years ago | vor 10 Jahren | 10 years ago | il y a 10 ans | 10 anni fa | 10 jaren geleden |
#Numbers
Numbers refer to general numerical values such as quantities, sizes, or measurements.
- Grouping numbers starts at 10 000, meaning 9999 and lower, are not grouped.
- Grouping separator is the narrow no-break space character
U+202F
, example: 15 500 - All locales use the same grouping separator.
Name | Type | Default | Description | Controls |
---|---|---|---|---|
actual * | number | - | Target number to format | |
locale * | "de-AT" | "de-CH" | "de-DE" | "de-FR" | "de-NL" | "de-BE" | "de-IT" | "de-LU" | "en-AT" | "en-CH" | "en-DE" | "en-FR" | "en-NL" | "en-BE" | "en-IT" | "en-LU" | "fr-AT" | "fr-CH" | ... 21 more ... | "nl-LU" | - | Used locale for formatting | |
options * | FormatNumberOptions<boolean> | - | Formatting options |
#Examples by locale
20 | 20.56 | 2000 | 20000 | 200000.56 | |
---|---|---|---|---|---|
de-AT | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
en-AT | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
de-BE | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
en-BE | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
fr-BE | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
nl-BE | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
de-CH | 20 | 20.56 | 2000 | 20 000 | 200 000.56 |
en-CH | 20 | 20.56 | 2000 | 20 000 | 200 000.56 |
fr-CH | 20 | 20.56 | 2000 | 20 000 | 200 000.56 |
it-CH | 20 | 20.56 | 2000 | 20 000 | 200 000.56 |
de-DE | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
en-DE | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
en-FR | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
fr-FR | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
en-IT | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
it-IT | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
de-NL | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
en-NL | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
nl-NL | 20 | 20,56 | 2000 | 20 000 | 200 000,56 |
#Numbers in React components
In React components, the useLocalization()
hook provides formatNumber, by using the hook, there is no need to provide a locale.
import { useLocalization } from "@segments/localization";
const MyNumberComponent: FunctionComponent<{ sum: number }> = ({ sum }) => {
const { formatNumber } = useLocalization();
return `Number: ${formatNumber(sum)}`;
};
#Numbers outside of React components
Outside of React components, the formatNumber()
method can be used directly, by providing a locale.
import { formatNumber } from "@segments/localization";
const formattedNumber = formatNumber(20.56, "de-CH");
#Numbers in specification tables
For specification tables of products use: { style: "specs" }
20 | 20.56 | 2000 | 20000 | 200000.56 | |
---|---|---|---|---|---|
de-AT | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
en-AT | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
de-BE | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
en-BE | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
fr-BE | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
nl-BE | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
de-CH | 20 mAh | 20.56 mAh | 2000 mAh | 20 000 mAh | 200 000.56 mAh |
en-CH | 20 mAh | 20.56 mAh | 2000 mAh | 20 000 mAh | 200 000.56 mAh |
fr-CH | 20 mAh | 20.56 mAh | 2000 mAh | 20 000 mAh | 200 000.56 mAh |
it-CH | 20 mAh | 20.56 mAh | 2000 mAh | 20 000 mAh | 200 000.56 mAh |
de-DE | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
en-DE | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
en-FR | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
fr-FR | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
en-IT | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
it-IT | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
de-NL | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
en-NL | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
nl-NL | 20 mAh | 20,56 mAh | 2000 mAh | 20 000 mAh | 200 000,56 mAh |
#In React components
import { useLocalization } from "@segments/localization";
import type { FunctionComponent } from "react";
const MyTimeComponent: FunctionComponent<{ time: Date }> = ({ time }) => {
const { formatTime } = useLocalization();
return <span>Time: {formatTime(time)}</span>;
};
#Outside of React components
import { formatNumber } from "@segments/localization";
const price = formatNumber(20.56, "de-CH", { style: "specs", unit: "mAh" });
#Price
- Currency is always prefixed to the number, example: CHF 20.56.
- Decimal places without value are always represented with .– example: CHF 50.–
- Grouping prices stars 10 000, meaning 9999 and lower, are not grouped.
- Grouping separator is narrow no-break space
U+202F
, example: CHF 15 500.56
Name | Type | Default | Description | Controls |
---|---|---|---|---|
locale * | "de-AT" | "de-CH" | "de-DE" | "de-FR" | "de-NL" | "de-BE" | "de-IT" | "de-LU" | "en-AT" | "en-CH" | "en-DE" | "en-FR" | "en-NL" | "en-BE" | "en-IT" | "en-LU" | "fr-AT" | "fr-CH" | ... 21 more ... | "nl-LU" | - | Used locale for formatting | |
options * | FormatPriceOptions<boolean> | - | Formatting options | |
price * | number | - | Target price to format |
#Prices without currency
20 | 20.56 | 2000 | 20000 | 200000.56 | -200000.56 | |
---|---|---|---|---|---|---|
de-AT | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
en-AT | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
de-BE | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
en-BE | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
fr-BE | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
nl-BE | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
de-CH | 20.– | 20.56 | 2000.– | 20 000.– | 200 000.56 | -200 000.56 |
en-CH | 20.– | 20.56 | 2000.– | 20 000.– | 200 000.56 | -200 000.56 |
fr-CH | 20.– | 20.56 | 2000.– | 20 000.– | 200 000.56 | -200 000.56 |
it-CH | 20.– | 20.56 | 2000.– | 20 000.– | 200 000.56 | -200 000.56 |
de-DE | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
en-DE | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
en-FR | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
fr-FR | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
en-IT | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
it-IT | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
de-NL | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
en-NL | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
nl-NL | 20,– | 20,56 | 2000,– | 20 000,– | 200 000,56 | -200 000,56 |
#Prices with currency
20 | 20.56 | 2000 | 20000 | 200000.56 | -200000.56 | |
---|---|---|---|---|---|---|
de-AT | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
en-AT | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
de-BE | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
en-BE | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
fr-BE | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
nl-BE | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
de-CH | CHF 20.– | CHF 20.56 | CHF 2000.– | CHF 20 000.– | CHF 200 000.56 | CHF -200 000.56 |
en-CH | CHF 20.– | CHF 20.56 | CHF 2000.– | CHF 20 000.– | CHF 200 000.56 | CHF -200 000.56 |
fr-CH | CHF 20.– | CHF 20.56 | CHF 2000.– | CHF 20 000.– | CHF 200 000.56 | CHF -200 000.56 |
it-CH | CHF 20.– | CHF 20.56 | CHF 2000.– | CHF 20 000.– | CHF 200 000.56 | CHF -200 000.56 |
de-DE | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
en-DE | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
en-FR | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
fr-FR | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
en-IT | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
it-IT | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
de-NL | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
en-NL | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
nl-NL | EUR 20,– | EUR 20,56 | EUR 2000,– | EUR 20 000,– | EUR 200 000,56 | EUR -200 000,56 |
#Prices in React components
In React components, the useLocalization()
hook provides formatPrice, by using the hook, there is no need to provide a locale.
import { useLocalization } from "@segments/localization";
const MyPriceComponent: FunctionComponent<{ price: number }> = ({ price }) => {
const { formatPrice } = useLocalization();
return `Price: ${formatPrice(price)}`;
};
#Prices outside of React components
Outside of React components, the formatPrice()
method can be used directly, by providing a locale.
import { formatPrice } from "@segments/localization";
const price = formatPrice(20.56, "de-CH", { currency: "CHF" });