Files
TREK/shared/src/i18n/sv/common.ts
T
Maurice 39b6d9f786 feat(client): catch render errors instead of blanking the page (#1805)
* feat(client): catch render errors instead of blanking the page

There were no error boundaries anywhere, so one throw during render unmounted the
whole tree and left the user staring at a white page with no way back.

ErrorBoundary holds the state in a class — getDerivedStateFromError has no hook
equivalent — and renders a function component for the visible half, so the panel
can translate normally. TranslationContext isn't exported, so contextType was not
an option anyway.

Two things it does beyond showing a message. A chunk that 404s after a deploy gets
one reload rather than a retry button: React.lazy caches the rejected promise, so
retrying re-throws immediately. And the reload happens once per session, or a
genuinely missing chunk would spin the tab.

The global handlers in main.tsx cover what no boundary reaches — event handlers
and async code. They filter axios errors: the interceptor already redirects on
401/403 and there are 600+ toast.error call sites, so reporting again would mean
double toasts and, for the redirects, loops.

* feat(client): isolate routes, widgets and the shell chrome

The route boundary goes on the single line where all 16 protected routes render
their content, inside MobileShell rather than around it: the navigation survives,
so a broken page is something the user can walk away from instead of a dead end.
The mobile --m-* tokens live on the shell's .m-root too, so a fallback outside it
would render invisible.

key={location.pathname}, not resetKeys — ProtectedRoute is the same component at
the same position for every protected route, so otherwise a failure could follow
the user across a navigation.

The public routes render outside ProtectedRoute and were therefore uncovered,
including /login (where people land when everything else failed) and the two
anonymous share pages. PublicRoute wraps those seven.

The five global widgets and the shell chrome get fallback={null} each: a broken
widget should disappear quietly, and if BottomNav dies the user loses the very
thing they need to leave the route.

* feat(client): isolate the GL maps and the plugin frame

Both map wrappers put the boundary outside their Suspense, not inside: Suspense
handles a pending promise, a rejected one throws straight past it. Falling back to
the Leaflet renderer keeps a usable map rather than showing an error card — the
same downgrade the Suspense fallback already does while loading.

PluginFrame is third-party code rendering in our tree; a throw there should cost
the plugin, not the page. resetKeys={[pluginId]} so switching plugins clears it.

The locale loader had no .catch (TranslationContext.tsx). After a deploy the chunk
can be gone, which produced an unhandled rejection and left the UI silently on the
previous language. It now keeps the strings it has and says so in the console.
2026-08-06 23:42:57 +02:00

78 lines
2.9 KiB
TypeScript

import type { TranslationStrings } from '../types';
const common: TranslationStrings = {
'common.datepicker.prevMonth': 'Föregående månad',
'common.datepicker.nextMonth': 'Nästa månad',
'common.datepicker.prevYear': 'Föregående år',
'common.datepicker.nextYear': 'Nästa år',
'common.datepicker.prevYears': 'Tidigare år',
'common.datepicker.nextYears': 'Senare år',
'common.datepicker.selectMonth': 'Välj månad',
'common.datepicker.selectYear': 'Välj år',
'common.datepicker.enterManually': 'Ange datum manuellt',
'common.datepicker.typeDate': 'Skriv ett datum',
'common.datepicker.dialog': 'Datumväljare',
'common.datepicker.clearDate': 'Rensa datum',
'common.save': 'Spara',
'common.showMore': 'Visa mer',
'common.showLess': 'Visa mindre',
'common.cancel': 'Avbryt',
'common.clear': 'Rensa',
'common.delete': 'Ta bort',
'common.preview': 'Förhandsvisning',
'common.edit': 'Redigera',
'common.add': 'Lägg till',
'common.loading': 'Laddar...',
'common.import': 'Importera',
'common.select': 'Välj',
'common.selectAll': 'Välj alla',
'common.deselectAll': 'Avmarkera alla',
'common.error': 'Fel',
'common.success': 'Klart',
'common.unknownError': 'Okänt fel',
'common.tooManyAttempts': 'För många försök. Försök igen senare.',
'common.back': 'Tillbaka',
'common.all': 'Alla',
'common.close': 'Stäng',
'common.open': 'Öppen',
'common.upload': 'Ladda upp',
'common.search': 'Sök',
'common.confirm': 'Godkänn',
'common.ok': 'OK',
'common.yes': 'Ja',
'common.no': 'Nej',
'common.or': 'eller',
'common.none': 'Ingen',
'common.date': 'Datum',
'common.rename': 'Döp om',
'common.discardChanges': 'Ångra ändringar',
'common.discard': 'Ångra',
'common.name': 'Namn',
'common.email': 'E-post',
'common.password': 'Lösenord',
'common.saving': 'Sparar...',
'common.justNow': 'just nu',
'common.hoursAgo': '{count}h sedan',
'common.daysAgo': '{count}d sedan',
'common.saved': 'Sparad',
'common.update': 'Uppdatera',
'common.change': 'Ändra',
'common.uploading': 'Laddar upp…',
'common.backToPlanning': 'Tillbaka till planering',
'common.reset': 'Återställ',
'common.expand': 'Expandera',
'common.collapse': 'Dölj',
'common.copy': 'Kopiera',
'common.copied': 'Kopierad',
'common.errorTitle': 'Något gick fel',
'common.errorBody': 'Den här delen av appen slutade fungera. Dina data är säkra.',
'common.errorPanelTitle': 'Det här avsnittet kunde inte visas',
'common.errorPanelBody': 'Resten av sidan fungerar fortfarande.',
'common.errorRetry': 'Försök igen',
'common.errorReload': 'Ladda om sidan',
'common.errorUpdateTitle': 'En ny version är tillgänglig',
'common.errorUpdateBody': 'TREK uppdaterades medan den här fliken var öppen. Ladda om för att hämta den nya versionen.',
'common.errorPluginTitle': 'Det här tillägget kunde inte visas',
};
export default common;