Skip to content

Commit

Permalink
webapp: Remove duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody committed May 29, 2024
1 parent df80953 commit ea4e7b7
Showing 1 changed file with 9 additions and 82 deletions.
91 changes: 9 additions & 82 deletions webapp/src/locales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,11 @@ export const LOCALES = [
{ value: Locales.FR, caption: 'Français' },
]

export const dateTimeFormats: I18nOptions["datetimeFormats"] = {
[Locales.EN]: {
'datetime': {
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour12: false
}
},
[Locales.DE]: {
'datetime': {
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour12: false
}
},
[Locales.FR]: {
export const dateTimeFormats: I18nOptions["datetimeFormats"] = {};
export const numberFormats: I18nOptions["numberFormats"] = {};

LOCALES.forEach((locale) => {
dateTimeFormats[locale.value] = {
'datetime': {
hour: 'numeric',
minute: 'numeric',
Expand All @@ -45,37 +26,9 @@ export const dateTimeFormats: I18nOptions["datetimeFormats"] = {
day: 'numeric',
hour12: false
}
}
};
};

export const numberFormats: I18nOptions["numberFormats"] = {
[Locales.EN]: {
decimal: {
style: 'decimal',
},
decimalNoDigits: {
style: 'decimal', minimumFractionDigits: 0, maximumFractionDigits: 0
},
decimalTwoDigits: {
style: 'decimal', minimumFractionDigits: 2, maximumFractionDigits: 2
},
percent: {
style: 'percent',
},
byte: {
style: 'unit', unit: 'byte',
},
kilobyte: {
style: 'unit', unit: 'kilobyte',
},
megabyte: {
style: 'unit', unit: 'megabyte',
},
celsius: {
style: 'unit', unit: 'celsius', maximumFractionDigits: 1,
},
},
[Locales.DE]: {
numberFormats[locale.value] = {
decimal: {
style: 'decimal',
},
Expand All @@ -100,33 +53,7 @@ export const numberFormats: I18nOptions["numberFormats"] = {
celsius: {
style: 'unit', unit: 'celsius', maximumFractionDigits: 1,
},
},
[Locales.FR]: {
decimal: {
style: 'decimal',
},
decimalNoDigits: {
style: 'decimal', minimumFractionDigits: 0, maximumFractionDigits: 0
},
decimalTwoDigits: {
style: 'decimal', minimumFractionDigits: 2, maximumFractionDigits: 2
},
percent: {
style: 'percent',
},
byte: {
style: 'unit', unit: 'byte',
},
kilobyte: {
style: 'unit', unit: 'kilobyte',
},
megabyte: {
style: 'unit', unit: 'megabyte',
},
celsius: {
style: 'unit', unit: 'celsius', maximumFractionDigits: 1,
},
},
};
};
});

export const defaultLocale = Locales.EN;

0 comments on commit ea4e7b7

Please sign in to comment.