remove svelte-i18n dependency, replace with minimalistic implementation

This commit is contained in:
vcoppe
2025-06-08 13:49:39 +02:00
parent a9ea0e223d
commit 228ad1044e
59 changed files with 121 additions and 746 deletions

View File

@@ -1,13 +0,0 @@
export const prerender = true;
import { languages } from '$lib/languages';
import { register, init } from 'svelte-i18n';
Object.keys(languages).forEach((lang) => {
register(lang, () => import(`../locales/${lang}.json`));
});
init({
fallbackLocale: 'en',
initialLocale: 'en',
});

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import '../app.pcss';
import { ModeWatcher } from 'mode-watcher';
import { isLoading, _, locale } from 'svelte-i18n';
import { _, locale, isLoadingInitialLocale, isLoadingLocale } from '$lib/i18n';
import { page } from '$app/stores';
import Nav from '$lib/components/Nav.svelte';
import Footer from '$lib/components/Footer.svelte';
@@ -44,7 +44,7 @@
}
}
$: if (browser && !$isLoading && $locale) {
$: if (browser && !$isLoadingLocale && $locale) {
let title = `gpx.studio — ${$_(`metadata.${$page.route.id?.replace('/[[language]]', '').split('/')[1] ?? 'home'}_title`)}`;
if ($page.params.guide) {
document.title = `${title} | ${data.guideTitles[$page.params.guide]}`;
@@ -58,7 +58,7 @@
<ModeWatcher />
<div class="flex flex-col min-h-screen">
{#if !$isLoading}
{#if !$isLoadingInitialLocale}
{#if showNavAndFooter}
<Nav />
{/if}

View File

@@ -0,0 +1 @@
export const prerender = true;

View File

@@ -3,7 +3,7 @@
import Logo from '$lib/components/Logo.svelte';
import { getURLForLanguage } from '$lib/utils';
import { Home, Map, BookOpenText } from 'lucide-svelte';
import { _, locale } from 'svelte-i18n';
import { _, locale } from '$lib/i18n';
</script>
<div class="grow px-12 my-12 flex flex-col items-center justify-center gap-6">

View File

@@ -15,7 +15,7 @@
Route,
Scale,
} from 'lucide-svelte';
import { _, locale } from 'svelte-i18n';
import { _, locale } from '$lib/i18n';
import { getURLForLanguage } from '$lib/utils';
import { exampleGPXFile } from '$lib/assets/example';
import { writable } from 'svelte/store';

View File

@@ -18,7 +18,7 @@
import { languages } from '$lib/languages';
import { getURLForLanguage } from '$lib/utils';
import { getURLForGoogleDriveFile } from '$lib/components/embedding/Embedding';
import { _ } from 'svelte-i18n';
import { _ } from '$lib/i18n';
const {
treeFileView,

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import { Button } from '$lib/components/ui/button';
import { getURLForLanguage } from '$lib/utils';
import { locale } from 'svelte-i18n';
import { locale } from '$lib/i18n';
import { page } from '$app/stores';
import { guides } from '$lib/components/docs/docs';

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import { Button } from '$lib/components/ui/button';
import { getURLForLanguage } from '$lib/utils';
import { locale } from 'svelte-i18n';
import { locale } from '$lib/i18n';
import { guides, guideIcons } from '$lib/components/docs/docs';
export let data: {

View File

@@ -5,7 +5,7 @@
import { Button } from '$lib/components/ui/button';
import { getURLForLanguage } from '$lib/utils';
import { ChevronLeft, ChevronRight, PenLine, CornerDownRight } from 'lucide-svelte';
import { _, locale } from 'svelte-i18n';
import { _, locale } from '$lib/i18n';
export let data: {
guideModule: any;