1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-11 11:49:19 +00:00

fix: fallback to primary language if no translation available for specific country

This commit is contained in:
Elias Schneider
2025-06-02 14:08:32 +02:00
parent 6c00aaa3ef
commit 2440379cd1
15 changed files with 5490 additions and 5915 deletions

View File

@@ -1,18 +1,6 @@
import { paraglideMiddleware } from '$lib/paraglide/server';
import type { Handle, HandleServerError } from '@sveltejs/kit';
import type { HandleServerError } from '@sveltejs/kit';
import { AxiosError } from 'axios';
// Handle to use the paraglide middleware
const paraglideHandle: Handle = ({ event, resolve }) => {
return paraglideMiddleware(event.request, ({ locale }) => {
return resolve(event, {
transformPageChunk: ({ html }) => html.replace('%lang%', locale)
});
});
};
export const handle: Handle = paraglideHandle;
export const handleError: HandleServerError = async ({ error, message, status }) => {
if (error instanceof AxiosError) {
message = error.response?.data.error || message;

View File

@@ -8,15 +8,16 @@
const currentLocale = getLocale();
const locales = {
'cs-CZ': 'Čeština',
'de-DE': 'Deutsch',
'en-US': 'English',
'fr-FR': 'Français',
'nl-NL': 'Nederlands',
'pl-PL': 'Polski',
cs: 'Čeština',
de: 'Deutsch',
en: 'English',
es: 'Español',
fr: 'Français',
it: 'Italiano',
nl: 'Nederlands',
pl: 'Polski',
'pt-BR': 'Português brasileiro',
'ru-RU': 'Русский',
'it-IT': 'Italiano',
ru: 'Русский',
'zh-CN': '简体中文'
};