From e86fd96ae3b5787252d41b8c49491bb4011d4527 Mon Sep 17 00:00:00 2001 From: Corentin THOMASSET Date: Wed, 1 Nov 2023 15:38:19 +0100 Subject: [PATCH] feat(i18n): language selector (#710) --- components.d.ts | 2 + locales/en.yml | 20 +++++- locales/fr.yml | 48 +++++++++++++- src/App.vue | 7 ++ src/components/CollapsibleToolMenu.vue | 4 +- src/layouts/base.layout.vue | 18 +++-- .../command-palette/command-palette.vue | 2 +- .../i18n/components/locale-selector.vue | 28 ++++++++ src/pages/Home.page.vue | 3 +- src/tools/tools.store.ts | 65 +++++++++++-------- src/ui/c-select/c-select.demo.vue | 15 +++++ src/ui/c-select/c-select.vue | 16 +++-- 12 files changed, 182 insertions(+), 46 deletions(-) create mode 100644 src/modules/i18n/components/locale-selector.vue diff --git a/components.d.ts b/components.d.ts index 669e1339..be80e56e 100644 --- a/components.d.ts +++ b/components.d.ts @@ -98,6 +98,7 @@ declare module '@vue/runtime-core' { IconMdiRecord: typeof import('~icons/mdi/record')['default'] IconMdiRefresh: typeof import('~icons/mdi/refresh')['default'] IconMdiSearch: typeof import('~icons/mdi/search')['default'] + IconMdiTranslate: typeof import('~icons/mdi/translate')['default'] IconMdiVideo: typeof import('~icons/mdi/video')['default'] InputCopyable: typeof import('./src/components/InputCopyable.vue')['default'] IntegerBaseConverter: typeof import('./src/tools/integer-base-converter/integer-base-converter.vue')['default'] @@ -114,6 +115,7 @@ declare module '@vue/runtime-core' { JwtParser: typeof import('./src/tools/jwt-parser/jwt-parser.vue')['default'] KeycodeInfo: typeof import('./src/tools/keycode-info/keycode-info.vue')['default'] ListConverter: typeof import('./src/tools/list-converter/list-converter.vue')['default'] + LocaleSelector: typeof import('./src/modules/i18n/components/locale-selector.vue')['default'] LoremIpsumGenerator: typeof import('./src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue')['default'] MacAddressGenerator: typeof import('./src/tools/mac-address-generator/mac-address-generator.vue')['default'] MacAddressLookup: typeof import('./src/tools/mac-address-lookup/mac-address-lookup.vue')['default'] diff --git a/locales/en.yml b/locales/en.yml index 1f31b68a..5500f8b8 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -28,7 +28,7 @@ home: about: h1: 'About IT-Tools' h1p1: 'This wonderful website, made with ❤ by' - h1p2: ', aggregates useful tools for developer and people working in IT. If you find it useful, please feel free to share it to people you think may find it useful too and don''''t forget to bookmark it in your shortcut bar!' + h1p2: ", aggregates useful tools for developer and people working in IT. If you find it useful, please feel free to share it to people you think may find it useful too and don''t forget to bookmark it in your shortcut bar!" h1p3: 'IT Tools is open-source (under the MIT license) and free, and will always be, but it costs me money to host and renew the domain name. If you want to support my work, and encourage me to add more tools, please consider supporting by' h1p4: 'sponsoring me' h2: Technologies @@ -38,7 +38,7 @@ about: h3p1: 'If you need a tool that is currently not present here, and you think can be useful, you are welcome to submit a feature request in the' h3p2: 'issues section' h3p3: 'in the GitHub repository.' - h3p4: 'And if you found a bug, or something doesn''''t work as expected, please file a bug report in the' + h3p4: "And if you found a bug, or something doesn''t work as expected, please file a bug report in the" h3p5: 'issues section' h3p6: 'in the GitHub repository.' 404: @@ -48,4 +48,18 @@ about: backHome: 'Back home' toolCard: new: New - \ No newline at end of file +search: + label: Search +tools: + categories: + favorite-tools: 'Your favorite tools' + crypto: Crypto + converter: Converter + web: Web + images and videos: 'Images & Videos' + development: Development + network: Network + math: Math + measurement: Measurement + text: Text + data: Data diff --git a/locales/fr.yml b/locales/fr.yml index 2846356d..9670546c 100644 --- a/locales/fr.yml +++ b/locales/fr.yml @@ -1,3 +1,49 @@ home: categories: - newestTools: "Nouveaux outils" + newestTools: 'Les nouveaux outils' + favoriteTools: 'Vos outils favoris' + allTools: 'Tous les outils' + subtitle: 'Outils pour les développeurs' + toggleMenu: 'Menu' + home: Accueil + uiLib: 'UI Lib' + buyMeACoffee: 'Soutenez IT-Tools' + follow: + title: 'Vous aimez it-tools ?' + p1: 'Soutenez-nous avec une star sur' + githubRepository: "le dépôt GitHub d'IT-Tools" + p2: 'ou suivez-nous sur' + twitterAccount: "le compte Twitter d'IT-Tools" + thankYou: 'Merci !' + nav: + github: 'Dépôt GitHub' + githubRepository: "Dépôt GitHub d'IT-Tools" + twitter: 'Compte Twitter' + twitterAccount: "Compte Twitter d'IT-Tools" + about: "À propos d'IT-Tools" + aboutLabel: 'À propos' + darkMode: 'Mode sombre' + lightMode: 'Mode clair' + mode: 'Basculer le mode sombre/clair' +404: + notFound: '404 Not Found' + sorry: "Désolé, cette page n'existe pas" + maybe: 'Peut-être que le cache fait des siennes, essayez de forcer le rafraîchissement ?' + backHome: "Retour à l'accueil" +toolCard: + new: Nouveau +search: + label: Rechercher +tools: + categories: + favorite-tools: 'Vos outils favoris' + crypto: Cryptographie + converter: Convertisseur + web: Web + images and videos: 'Images & Vidéos' + development: Développement + network: Réseau + math: Math + measurement: Mesure + text: Texte + data: Données diff --git a/src/App.vue b/src/App.vue index fec26bf1..8e65335d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -11,6 +11,13 @@ const styleStore = useStyleStore(); const theme = computed(() => (styleStore.isDarkTheme ? darkTheme : null)); const themeOverrides = computed(() => (styleStore.isDarkTheme ? darkThemeOverrides : lightThemeOverrides)); + +const { locale } = useI18n(); + +syncRef( + locale, + useStorage('locale', locale), +); diff --git a/src/ui/c-select/c-select.vue b/src/ui/c-select/c-select.vue index fb34038d..7b3607c9 100644 --- a/src/ui/c-select/c-select.vue +++ b/src/ui/c-select/c-select.vue @@ -150,13 +150,15 @@ function onSearchInput() { @keydown="handleKeydown" >
- - - {{ selectedOption.label }} - - - {{ placeholder ?? 'Select an option' }} - + + + + {{ selectedOption.label }} + + + {{ placeholder ?? 'Select an option' }} + +