mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-02 00:32:33 +00:00
add languages
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
export const languages: Record<string, string> = {
|
export const languages: Record<string, string> = {
|
||||||
'en': 'English',
|
'en': 'English',
|
||||||
|
'es': 'Español',
|
||||||
|
'fr': 'Français',
|
||||||
|
'nl': 'Nederlands',
|
||||||
|
'pt-BR': 'Português (Brasil)',
|
||||||
};
|
};
|
@@ -1,28 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import '../app.pcss';
|
import '../app.pcss';
|
||||||
import { ModeWatcher } from 'mode-watcher';
|
import { ModeWatcher } from 'mode-watcher';
|
||||||
import { isLoading, locale, _ } from 'svelte-i18n';
|
import { isLoading, _ } from 'svelte-i18n';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import Head from '$lib/components/Head.svelte';
|
import Head from '$lib/components/Head.svelte';
|
||||||
import Nav from '$lib/components/Nav.svelte';
|
import Nav from '$lib/components/Nav.svelte';
|
||||||
import Footer from '$lib/components/Footer.svelte';
|
import Footer from '$lib/components/Footer.svelte';
|
||||||
import { languages } from '$lib/languages';
|
|
||||||
import { browser } from '$app/environment';
|
|
||||||
import { goto } from '$app/navigation';
|
|
||||||
import { base } from '$app/paths';
|
|
||||||
|
|
||||||
$: if ($page.params.language === '' && $locale !== 'en') {
|
|
||||||
locale.set('en');
|
|
||||||
} else if ($page.params.language) {
|
|
||||||
let lang = $page.params.language.replace('/', '');
|
|
||||||
if ($locale !== lang) {
|
|
||||||
if (languages.hasOwnProperty(lang)) {
|
|
||||||
locale.set(lang);
|
|
||||||
} else if (browser) {
|
|
||||||
goto(`${base}/404`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const appRoutes = ['/[...language]/app', '/[...language]/embed'];
|
const appRoutes = ['/[...language]/app', '/[...language]/embed'];
|
||||||
|
|
||||||
|
23
website/src/routes/[...language]/+layout.svelte
Normal file
23
website/src/routes/[...language]/+layout.svelte
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { locale, _ } from 'svelte-i18n';
|
||||||
|
import { page } from '$app/stores';
|
||||||
|
import { languages } from '$lib/languages';
|
||||||
|
import { browser } from '$app/environment';
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
import { base } from '$app/paths';
|
||||||
|
|
||||||
|
$: if ($page.params.language === '' && $locale !== 'en') {
|
||||||
|
locale.set('en');
|
||||||
|
} else if ($page.params.language) {
|
||||||
|
let lang = $page.params.language.replace('/', '');
|
||||||
|
if ($locale !== lang) {
|
||||||
|
if (languages.hasOwnProperty(lang)) {
|
||||||
|
locale.set(lang);
|
||||||
|
} else if (browser) {
|
||||||
|
goto(`${base}/404`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<slot />
|
Reference in New Issue
Block a user