mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-12-02 18:12:11 +00:00
remove svelte-i18n dependency, replace with minimalistic implementation
This commit is contained in:
@@ -6,13 +6,11 @@ import { get } from 'svelte/store';
|
||||
import { map } from './stores';
|
||||
import { base } from '$app/paths';
|
||||
import { languages } from '$lib/languages';
|
||||
import { locale } from 'svelte-i18n';
|
||||
import { TrackPoint, Waypoint, type Coordinates, crossarcDistance, distance } from 'gpx';
|
||||
import mapboxgl from 'mapbox-gl';
|
||||
import tilebelt from '@mapbox/tilebelt';
|
||||
import { PUBLIC_MAPBOX_TOKEN } from '$env/static/public';
|
||||
import PNGReader from 'png.js';
|
||||
import type { DateFormatter } from '@internationalized/date';
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
@@ -219,7 +217,7 @@ export function isSafari() {
|
||||
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
||||
}
|
||||
|
||||
export function getURLForLanguage(lang: string | null | undefined, path: string): string {
|
||||
export function getURLForLanguage(lang: string, path: string): string {
|
||||
let newPath = path.replace(base, '');
|
||||
|
||||
let languageInPath = newPath.split('/')[1];
|
||||
@@ -227,13 +225,6 @@ export function getURLForLanguage(lang: string | null | undefined, path: string)
|
||||
languageInPath = 'en';
|
||||
}
|
||||
|
||||
if (lang === null || lang === undefined) {
|
||||
lang = get(locale);
|
||||
if (lang === null || lang === undefined) {
|
||||
lang = 'en';
|
||||
}
|
||||
}
|
||||
|
||||
if (newPath === '/' && lang !== 'en') {
|
||||
newPath = '';
|
||||
}
|
||||
@@ -254,15 +245,3 @@ export function getURLForLanguage(lang: string | null | undefined, path: string)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getDateFormatter(locale: string) {
|
||||
return new Intl.DateTimeFormat(locale, {
|
||||
dateStyle: 'medium',
|
||||
timeStyle: 'medium',
|
||||
});
|
||||
}
|
||||
|
||||
export let df: DateFormatter = getDateFormatter('en');
|
||||
locale.subscribe((l) => {
|
||||
df = getDateFormatter(l ?? 'en');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user