Files
Stirling-PDF/frontend/src/core/components/shared/AppConfigLoader.tsx
T
2025-12-10 00:09:45 +00:00

26 lines
872 B
TypeScript

import { useEffect } from 'react';
import { useAppConfig } from '@app/contexts/AppConfigContext';
import { updateSupportedLanguages } from '@app/i18n';
/**
* Component that loads app configuration and applies it to the application.
* This includes:
* - Filtering available languages based on config.languages
*
* Place this component high in the component tree, after i18n has initialized.
*/
export default function AppConfigLoader() {
const { config, loading } = useAppConfig();
useEffect(() => {
if (!loading && config) {
// Update supported languages and apply default locale from server config
// Priority: localStorage > config.defaultLocale > browser detection > fallback
updateSupportedLanguages(config.languages, config.defaultLocale);
}
}, [config, loading]);
// This component doesn't render anything
return null;
}