From c26e004f4a05f231242587c1265a620b7fcd873a Mon Sep 17 00:00:00 2001 From: secondl1ght <85003930+secondl1ght@users.noreply.github.com> Date: Tue, 16 Aug 2022 10:59:19 -0600 Subject: run format --- src/components/LandingHeader.svelte | 29 +++++++++--------- src/components/LocaleSelector.svelte | 12 ++++---- src/lib/i18n.js | 55 +++++++++++++++++------------------ src/locales/en.json | 17 +++++------ src/locales/fr.json | 17 +++++------ src/routes/[username]/settings.svelte | 8 ++--- src/routes/__layout.svelte | 12 ++++---- 7 files changed, 72 insertions(+), 78 deletions(-) (limited to 'src') diff --git a/src/components/LandingHeader.svelte b/src/components/LandingHeader.svelte index 544e2a9d..b6519ca9 100644 --- a/src/components/LandingHeader.svelte +++ b/src/components/LandingHeader.svelte @@ -3,7 +3,7 @@ import { scroll } from '$lib/utils'; import { Icon, LocaleSelector } from '$comp'; import { user } from '$lib/store'; - import { _ } from 'svelte-i18n'; + import { _ } from 'svelte-i18n'; export let howItWorks; export let faq; @@ -18,17 +18,15 @@
diff --git a/src/components/LocaleSelector.svelte b/src/components/LocaleSelector.svelte index 3f173109..2ae65986 100644 --- a/src/components/LocaleSelector.svelte +++ b/src/components/LocaleSelector.svelte @@ -1,10 +1,10 @@ - + {#each $locales as locale} + + {/each} diff --git a/src/lib/i18n.js b/src/lib/i18n.js index fdf5de3c..3105c709 100644 --- a/src/lib/i18n.js +++ b/src/lib/i18n.js @@ -2,41 +2,40 @@ import { register, init, getLocaleFromNavigator } from 'svelte-i18n'; // The list of locales to look for // ADD ALL NEW LANGUAGE CODES TO THIS LIST -const localeCodes = ["en", "fr"]; +const localeCodes = ['en', 'fr']; // the default locale to use if none was found -const defaultLocale = "en"; +const defaultLocale = 'en'; // Adds a new locale based on its code function addLocale(localeCode) { - register(localeCode, () => import(`../locales/${localeCode}.json`)); + register(localeCode, () => import(`../locales/${localeCode}.json`)); } // Picks the default locale based on navigator locale and the list of available locales function pickLocale(navigatorLocale, availableLocales) { - // locale can be null the first time you load this - // return the default locale in that case - reloading should fix this - if (!navigatorLocale) - return defaultLocale; - - // determine langugage part of locale - // (e.g. if navigatorLocale is 'en-US', languageCode is 'en') - let dashIndex = navigatorLocale ? navigatorLocale.indexOf("-") : -1; - let languageCode; // navigator locale without the regional part - if (dashIndex === -1) { - languageCode = navigatorLocale; - } else { - languageCode = navigatorLocale.slice(0, dashIndex); - } - - // get locale - if (availableLocales.includes(navigatorLocale)) { - return navigatorLocale; - } else if (availableLocales.includes(languageCode)) { - return languageCode; - } else { - return navigatorLocale; - } + // locale can be null the first time you load this + // return the default locale in that case - reloading should fix this + if (!navigatorLocale) return defaultLocale; + + // determine langugage part of locale + // (e.g. if navigatorLocale is 'en-US', languageCode is 'en') + let dashIndex = navigatorLocale ? navigatorLocale.indexOf('-') : -1; + let languageCode; // navigator locale without the regional part + if (dashIndex === -1) { + languageCode = navigatorLocale; + } else { + languageCode = navigatorLocale.slice(0, dashIndex); + } + + // get locale + if (availableLocales.includes(navigatorLocale)) { + return navigatorLocale; + } else if (availableLocales.includes(languageCode)) { + return languageCode; + } else { + return navigatorLocale; + } } // add locales @@ -44,6 +43,6 @@ localeCodes.forEach(addLocale); let initialLocale = pickLocale(getLocaleFromNavigator(), localeCodes); init({ - fallbackLocale: defaultLocale, - initialLocale: initialLocale, + fallbackLocale: defaultLocale, + initialLocale: initialLocale }); diff --git a/src/locales/en.json b/src/locales/en.json index c5c36c4b..a44c202f 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1,11 +1,10 @@ { - "langname": "English", - "nav": { - "howItWorks": "How It Works", - "faq": "FAQ", - "about": "About", - "startInSeconds": "Start in Seconds", - "signIn": "Sign In" -} - + "langname": "English", + "nav": { + "howItWorks": "How It Works", + "faq": "FAQ", + "about": "About", + "startInSeconds": "Start in Seconds", + "signIn": "Sign In" + } } diff --git a/src/locales/fr.json b/src/locales/fr.json index d2c9d758..9adc9488 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -1,11 +1,10 @@ { - "langname": "Français", -"nav": { - "howItWorks": "Comment Ça Fonctionne", - "faq": "FAQ", - "about": "À Propos", - "startInSeconds": "Commence en Secondes", - "signIn": "Connexion" -} - + "langname": "Français", + "nav": { + "howItWorks": "Comment Ça Fonctionne", + "faq": "FAQ", + "about": "À Propos", + "startInSeconds": "Commence en Secondes", + "signIn": "Connexion" + } } diff --git a/src/routes/[username]/settings.svelte b/src/routes/[username]/settings.svelte index 11e0977a..e4d7b0bf 100644 --- a/src/routes/[username]/settings.svelte +++ b/src/routes/[username]/settings.svelte @@ -44,10 +44,10 @@ {#if setting === 'account'} -
- - -
+
+ + +
diff --git a/src/routes/__layout.svelte b/src/routes/__layout.svelte index c5234c7d..5f9f1456 100644 --- a/src/routes/__layout.svelte +++ b/src/routes/__layout.svelte @@ -1,16 +1,16 @@