Skip to content

Commit

Permalink
refactor: remove number-formats from internationalization files
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwep committed May 20, 2024
1 parent c71bcf6 commit 3765a8a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 46 deletions.
15 changes: 13 additions & 2 deletions src/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createI18n } from 'vue-i18n';
import { createI18n, IntlNumberFormat } from 'vue-i18n';
import de from './locales/de.json';
import en from './locales/en.json';
import br from './locales/pt-br.json';
Expand All @@ -14,11 +14,22 @@ export const initialLocale = availableLocales.includes(browserLocale) ? browserL

export type AvailableLocale = keyof typeof messages;

const numberFormats: IntlNumberFormat = {
currency: {
minimumFractionDigits: 0,
style: 'currency'
},
percent: {
maximumFractionDigits: 0,
style: 'percent'
}
};

/* eslint-disable @typescript-eslint/no-explicit-any */
export const i18n = createI18n({
legacy: false,
fallbackLocale: 'en',
locale: initialLocale,
messages: messages as any,
numberFormats: Object.fromEntries(Object.entries(messages).map((v) => [[v[0]], v[1]._numberFormats]))
numberFormats: Object.fromEntries(availableLocales.map((locale) => [locale, numberFormats]))
});
11 changes: 0 additions & 11 deletions src/i18n/locales/de.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
{
"_numberFormats": {
"currency": {
"currency": "USD",
"minimumFractionDigits": 0,
"style": "currency"
},
"percent": {
"maximumFractionDigits": 0,
"style": "percent"
}
},
"navigation": {
"tools": {
"tools": "Werkzeuge",
Expand Down
11 changes: 0 additions & 11 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
{
"_numberFormats": {
"currency": {
"currency": "USD",
"minimumFractionDigits": 0,
"style": "currency"
},
"percent": {
"maximumFractionDigits": 0,
"style": "percent"
}
},
"navigation": {
"tools": {
"tools": "Tools",
Expand Down
11 changes: 0 additions & 11 deletions src/i18n/locales/pt-br.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
{
"_numberFormats": {
"currency": {
"currency": "USD",
"minimumFractionDigits": 0,
"style": "currency"
},
"percent": {
"maximumFractionDigits": 0,
"style": "percent"
}
},
"navigation": {
"tools": {
"tools": "Ferramentas",
Expand Down
11 changes: 0 additions & 11 deletions src/i18n/locales/tr.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
{
"_numberFormats" : {
"currency" : {
"currency" : "USD",
"minimumFractionDigits" : 0,
"style": "currency"
},
"percent": {
"maximumFractionDigits": 0,
"style": "percent"
}
},
"navigation" : {
"admin" : {
"admin" : "Yönetici",
Expand Down

0 comments on commit 3765a8a

Please sign in to comment.