From 1e77fa68b694e484d4633696cf29dc62d32cf19b Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 4 Aug 2021 09:53:17 +0200 Subject: [PATCH] Client - init locales files ('en' and 'fr') --- .../src/components/HelloI18n.vue | 30 ------------------- fittrackee_client/src/components/NavBar.vue | 22 ++++++++------ fittrackee_client/src/i18n.ts | 8 ++--- fittrackee_client/src/locales/en.json | 3 -- .../src/locales/en/administration.json | 3 ++ .../src/locales/en/dashboard.json | 3 ++ fittrackee_client/src/locales/en/en.ts | 13 ++++++++ .../src/locales/en/statistics.json | 3 ++ fittrackee_client/src/locales/en/user.json | 5 ++++ .../src/locales/en/workouts.json | 4 +++ .../src/locales/fr/administration.json | 3 ++ .../src/locales/fr/dashboard.json | 3 ++ fittrackee_client/src/locales/fr/fr.ts | 13 ++++++++ .../src/locales/fr/statistics.json | 3 ++ fittrackee_client/src/locales/fr/user.json | 5 ++++ .../src/locales/fr/workouts.json | 4 +++ fittrackee_client/tsconfig.json | 1 + 17 files changed, 78 insertions(+), 48 deletions(-) delete mode 100644 fittrackee_client/src/components/HelloI18n.vue delete mode 100644 fittrackee_client/src/locales/en.json create mode 100644 fittrackee_client/src/locales/en/administration.json create mode 100644 fittrackee_client/src/locales/en/dashboard.json create mode 100644 fittrackee_client/src/locales/en/en.ts create mode 100644 fittrackee_client/src/locales/en/statistics.json create mode 100644 fittrackee_client/src/locales/en/user.json create mode 100644 fittrackee_client/src/locales/en/workouts.json create mode 100644 fittrackee_client/src/locales/fr/administration.json create mode 100644 fittrackee_client/src/locales/fr/dashboard.json create mode 100644 fittrackee_client/src/locales/fr/fr.ts create mode 100644 fittrackee_client/src/locales/fr/statistics.json create mode 100644 fittrackee_client/src/locales/fr/user.json create mode 100644 fittrackee_client/src/locales/fr/workouts.json diff --git a/fittrackee_client/src/components/HelloI18n.vue b/fittrackee_client/src/components/HelloI18n.vue deleted file mode 100644 index 6dcfaa83..00000000 --- a/fittrackee_client/src/components/HelloI18n.vue +++ /dev/null @@ -1,30 +0,0 @@ - - - - - -{ - "en": { - "hello": "Hello i18n in SFC!" - } -} - diff --git a/fittrackee_client/src/components/NavBar.vue b/fittrackee_client/src/components/NavBar.vue index ee370af0..7e5b1222 100644 --- a/fittrackee_client/src/components/NavBar.vue +++ b/fittrackee_client/src/components/NavBar.vue @@ -17,17 +17,19 @@ > @@ -36,18 +38,20 @@ diff --git a/fittrackee_client/src/i18n.ts b/fittrackee_client/src/i18n.ts index 8b9a71b6..37f4ad56 100644 --- a/fittrackee_client/src/i18n.ts +++ b/fittrackee_client/src/i18n.ts @@ -7,17 +7,13 @@ import { createI18n, LocaleMessages, VueMessageType } from 'vue-i18n' * See: https://github.com/intlify/vue-i18n-loader#rocket-i18n-resource-pre-compilation */ function loadLocaleMessages(): LocaleMessages { - const locales = require.context( - './locales', - true, - /[A-Za-z0-9-_,\s]+\.json$/i - ) + const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.ts$/i) const messages: LocaleMessages = {} locales.keys().forEach((key) => { const matched = key.match(/([A-Za-z0-9-_]+)\./i) if (matched && matched.length > 1) { const locale = matched[1] - messages[locale] = locales(key) + messages[locale] = locales(key).default } }) return messages diff --git a/fittrackee_client/src/locales/en.json b/fittrackee_client/src/locales/en.json deleted file mode 100644 index d9669836..00000000 --- a/fittrackee_client/src/locales/en.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "message": "hello i18n !!" -} \ No newline at end of file diff --git a/fittrackee_client/src/locales/en/administration.json b/fittrackee_client/src/locales/en/administration.json new file mode 100644 index 00000000..c19cfcab --- /dev/null +++ b/fittrackee_client/src/locales/en/administration.json @@ -0,0 +1,3 @@ +{ + "ADMIN": "Admin" +} diff --git a/fittrackee_client/src/locales/en/dashboard.json b/fittrackee_client/src/locales/en/dashboard.json new file mode 100644 index 00000000..a261f46f --- /dev/null +++ b/fittrackee_client/src/locales/en/dashboard.json @@ -0,0 +1,3 @@ +{ + "DASHBOARD": "Dashboard" +} diff --git a/fittrackee_client/src/locales/en/en.ts b/fittrackee_client/src/locales/en/en.ts new file mode 100644 index 00000000..1428c936 --- /dev/null +++ b/fittrackee_client/src/locales/en/en.ts @@ -0,0 +1,13 @@ +import AdministrationTranslations from './administration.json' +import DashboardTranslations from './dashboard.json' +import StatisticsTranslations from './statistics.json' +import UserTranslations from './user.json' +import WorkoutsTranslations from './workouts.json' + +export default { + administration: AdministrationTranslations, + dashboard: DashboardTranslations, + statistics: StatisticsTranslations, + user: UserTranslations, + workouts: WorkoutsTranslations, +} diff --git a/fittrackee_client/src/locales/en/statistics.json b/fittrackee_client/src/locales/en/statistics.json new file mode 100644 index 00000000..9aa392e0 --- /dev/null +++ b/fittrackee_client/src/locales/en/statistics.json @@ -0,0 +1,3 @@ +{ + "STATISTICS": "Statistics" +} diff --git a/fittrackee_client/src/locales/en/user.json b/fittrackee_client/src/locales/en/user.json new file mode 100644 index 00000000..2b8381d2 --- /dev/null +++ b/fittrackee_client/src/locales/en/user.json @@ -0,0 +1,5 @@ +{ + "LOGIN": "Login", + "LOGOUT": "Logout", + "REGISTER": "Register" +} diff --git a/fittrackee_client/src/locales/en/workouts.json b/fittrackee_client/src/locales/en/workouts.json new file mode 100644 index 00000000..64057236 --- /dev/null +++ b/fittrackee_client/src/locales/en/workouts.json @@ -0,0 +1,4 @@ +{ + "ADD_WORKOUT": "Add workout", + "WORKOUTS": "Workouts" +} diff --git a/fittrackee_client/src/locales/fr/administration.json b/fittrackee_client/src/locales/fr/administration.json new file mode 100644 index 00000000..c19cfcab --- /dev/null +++ b/fittrackee_client/src/locales/fr/administration.json @@ -0,0 +1,3 @@ +{ + "ADMIN": "Admin" +} diff --git a/fittrackee_client/src/locales/fr/dashboard.json b/fittrackee_client/src/locales/fr/dashboard.json new file mode 100644 index 00000000..5f984b93 --- /dev/null +++ b/fittrackee_client/src/locales/fr/dashboard.json @@ -0,0 +1,3 @@ +{ + "DASHBOARD": "Tableau de Bord" +} diff --git a/fittrackee_client/src/locales/fr/fr.ts b/fittrackee_client/src/locales/fr/fr.ts new file mode 100644 index 00000000..1428c936 --- /dev/null +++ b/fittrackee_client/src/locales/fr/fr.ts @@ -0,0 +1,13 @@ +import AdministrationTranslations from './administration.json' +import DashboardTranslations from './dashboard.json' +import StatisticsTranslations from './statistics.json' +import UserTranslations from './user.json' +import WorkoutsTranslations from './workouts.json' + +export default { + administration: AdministrationTranslations, + dashboard: DashboardTranslations, + statistics: StatisticsTranslations, + user: UserTranslations, + workouts: WorkoutsTranslations, +} diff --git a/fittrackee_client/src/locales/fr/statistics.json b/fittrackee_client/src/locales/fr/statistics.json new file mode 100644 index 00000000..198fb1ef --- /dev/null +++ b/fittrackee_client/src/locales/fr/statistics.json @@ -0,0 +1,3 @@ +{ + "STATISTICS": "Statistiques" +} diff --git a/fittrackee_client/src/locales/fr/user.json b/fittrackee_client/src/locales/fr/user.json new file mode 100644 index 00000000..9996d2a8 --- /dev/null +++ b/fittrackee_client/src/locales/fr/user.json @@ -0,0 +1,5 @@ +{ + "LOGIN": "Se connecter", + "LOGOUT": "Se déconnecter", + "REGISTER": "S'inscrire" +} \ No newline at end of file diff --git a/fittrackee_client/src/locales/fr/workouts.json b/fittrackee_client/src/locales/fr/workouts.json new file mode 100644 index 00000000..30f8ef54 --- /dev/null +++ b/fittrackee_client/src/locales/fr/workouts.json @@ -0,0 +1,4 @@ +{ + "ADD_WORKOUT": "Ajouter une séance", + "WORKOUTS": "Séances" +} diff --git a/fittrackee_client/tsconfig.json b/fittrackee_client/tsconfig.json index 25566f50..e5956476 100644 --- a/fittrackee_client/tsconfig.json +++ b/fittrackee_client/tsconfig.json @@ -6,6 +6,7 @@ "jsx": "preserve", "importHelpers": true, "moduleResolution": "node", + "resolveJsonModule": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true,