Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions frontend/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,28 @@
}, SLOW_START_MS);

try {
// Initialize i18n (loads user's preferred locale) and instance branding
// (public, no auth). Branding drives the browser tab title and the
// sidebar text on every surface, including pre-auth.
await Promise.all([
withBootstrapDeadline(i18n.init()),
brandStore.load({ timeout: BOOTSTRAP_TIMEOUT_MS }),
// Load locale, branding, and setup together. Apply startup copy and the
// title even if the setup request is still pending or has failed.
const [, setupComplete] = await Promise.all([
Promise.all([
withBootstrapDeadline(i18n.init()),
brandStore.load({ timeout: BOOTSTRAP_TIMEOUT_MS }),
]).then(() => {
if (attempt !== startupAttempt) return;
i18nReady = true;
if (typeof document !== 'undefined') {
document.title = brandStore.siteTitle;
}
}),
checkSetupStatus(),
]);
i18nReady = true;
if (typeof document !== 'undefined') {
document.title = brandStore.siteTitle;
}

// Check setup status first
await checkSetupStatus();
if (attempt !== startupAttempt) return;

setupCompleted = setupComplete;
if (!setupCompleted) {
showWelcomeAssistant = true;
}

// Only initialize auth if setup is completed. A transport error is not a
// logout: authStore returns it so the startup UI can offer a retry.
if (setupCompleted) {
Expand Down Expand Up @@ -365,10 +371,7 @@
// behind the vite proxy), making a fresh, unconfigured instance look
// already set up and silently skipping the setup wizard.
const status = await setup.getStatus({ timeout: BOOTSTRAP_TIMEOUT_MS });
setupCompleted = status.setup_completed;
if (!status.setup_completed) {
showWelcomeAssistant = true;
}
return status.setup_completed;
}

async function loadAndApplyTheme(isAuthenticated, generation) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/locales/de/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
'bookFailed': 'Der Zeiteintrag konnte nicht gebucht werden.',
'discardFailed': 'Der Entwurf konnte nicht verworfen werden.',
'menu': {
'startTimerHint': 'Verwendet das geöffnete Arbeitselement, falls vorhanden',
'startTimerHint': 'Verwendet den geöffneten Vorgang, falls vorhanden',
'logWork': 'Arbeit erfassen',
'logWorkHint': 'Arbeitszeit manuell erfassen',
},
Expand Down Expand Up @@ -204,7 +204,7 @@ export default {
title: 'Zeiteintrag',
subtitle: 'Erfassen Sie Ihre Arbeitsstunden und verwalten Sie Zeiteinträge',
addTimeEntry: 'Neuen Zeiteintrag hinzufügen',
'needWorkspace': 'Öffne einen Arbeitsbereich oder ein Arbeitselement, bevor du einen Timer startest.',
'needWorkspace': 'Öffne einen Arbeitsbereich oder einen Vorgang, bevor du einen Timer startest.',
failedToSave:
'Zeiteintrag konnte nicht gespeichert werden. Bitte überprüfen Sie Ihre Eingaben.',
confirmDelete: 'Sind Sie sicher, dass Sie diesen Zeiteintrag löschen möchten?',
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/lib/stores/brand.svelte.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ let logoFullURL = $state('');
let logoFullURLDark = $state('');
let loaded = $state(false);
let loading = $state(false);
let loadPromise = null;

function hydrate(value) {
if (!value) return;
Expand All @@ -26,8 +27,13 @@ function hydrate(value) {
}

async function load(options = {}) {
if (loaded || loading) return;
if (loaded || loading) return loadPromise;
loading = true;
loadPromise = loadBranding(options);
return loadPromise;
}

async function loadBranding(options) {
try {
hydrate(await brandingApi.get(options));
} catch (error) {
Expand Down
21 changes: 12 additions & 9 deletions frontend/src/lib/stores/i18n.svelte.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,18 @@ async function loadTranslations(localeCode) {
loading = true;

try {
if (localeCode !== DEFAULT_LOCALE) {
await loadFallbackTranslations();
}

// Dynamic import for lazy loading
const module = await import(`../locales/${localeCode}/index.js`);
translations = module.default;
if (localeCode === DEFAULT_LOCALE) {
fallbackTranslations = module.default;
// English is the fallback for missing keys in every other locale. Start
// both catalog imports together so a non-English cold start pays one round
// trip instead of awaiting English before requesting the selected locale.
const needsFallback = localeCode !== DEFAULT_LOCALE;
const [, selectedModule] = await Promise.all([
needsFallback ? loadFallbackTranslations() : Promise.resolve(),
import(`../locales/${localeCode}/index.js`),
]);

translations = selectedModule.default;
if (!needsFallback) {
fallbackTranslations = selectedModule.default;
}
locale = localeCode;
setAppLocale(localeCode);
Expand Down
Loading