feat: localisation with en, de, fr and it
This commit is contained in:
@@ -15,6 +15,8 @@ import 'core/auth/auth_state_manager.dart';
|
||||
import 'core/utils/debug_logger.dart';
|
||||
|
||||
import 'features/onboarding/views/onboarding_sheet.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:conduit/l10n/app_localizations.dart';
|
||||
import 'features/chat/views/chat_page.dart';
|
||||
import 'features/navigation/views/splash_launcher_page.dart';
|
||||
|
||||
@@ -85,17 +87,40 @@ class _ConduitAppState extends ConsumerState<ConduitApp> {
|
||||
? AppTheme.conduitDarkTheme
|
||||
: AppTheme.conduitLightTheme;
|
||||
|
||||
final locale = ref.watch(localeProvider);
|
||||
|
||||
return AnimatedThemeWrapper(
|
||||
theme: currentTheme,
|
||||
duration: AnimationDuration.medium,
|
||||
child: ErrorBoundary(
|
||||
child: MaterialApp(
|
||||
title: 'Conduit',
|
||||
onGenerateTitle: (context) => AppLocalizations.of(context)!.appTitle,
|
||||
theme: AppTheme.conduitLightTheme,
|
||||
darkTheme: AppTheme.conduitDarkTheme,
|
||||
themeMode: themeMode,
|
||||
debugShowCheckedModeBanner: false,
|
||||
navigatorKey: NavigationService.navigatorKey,
|
||||
locale: locale,
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [
|
||||
Locale('en'),
|
||||
Locale('de'),
|
||||
Locale('fr'),
|
||||
Locale('it'),
|
||||
],
|
||||
localeResolutionCallback: (deviceLocale, supported) {
|
||||
if (locale != null) return locale; // User override wins
|
||||
if (deviceLocale == null) return const Locale('en');
|
||||
for (final loc in supported) {
|
||||
if (loc.languageCode == deviceLocale.languageCode) return loc;
|
||||
}
|
||||
return const Locale('en');
|
||||
},
|
||||
builder: (context, child) {
|
||||
// Keep a subtle fade for navigation transitions only
|
||||
final wrapped = OfflineIndicator(
|
||||
@@ -159,7 +184,7 @@ class _ConduitAppState extends ConsumerState<ConduitApp> {
|
||||
|
||||
if (authNavState == AuthNavigationState.error) {
|
||||
return _buildErrorState(
|
||||
ref.watch(authErrorProvider3) ?? 'Authentication error',
|
||||
ref.watch(authErrorProvider3) ?? AppLocalizations.of(context)!.errorMessage,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -174,7 +199,7 @@ class _ConduitAppState extends ConsumerState<ConduitApp> {
|
||||
loading: () => _buildInitialLoadingSkeleton(context),
|
||||
error: (error, stackTrace) {
|
||||
DebugLogger.error('Server provider error', error);
|
||||
return _buildErrorState('Server connection failed: $error');
|
||||
return _buildErrorState(AppLocalizations.of(context)!.unableToConnectServer);
|
||||
},
|
||||
);
|
||||
},
|
||||
@@ -268,7 +293,7 @@ class _ConduitAppState extends ConsumerState<ConduitApp> {
|
||||
),
|
||||
const SizedBox(height: Spacing.md),
|
||||
Text(
|
||||
'Initialization Failed',
|
||||
AppLocalizations.of(context)!.initializationFailed,
|
||||
style: TextStyle(
|
||||
fontSize: AppTypography.headlineLarge,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -291,7 +316,7 @@ class _ConduitAppState extends ConsumerState<ConduitApp> {
|
||||
backgroundColor: context.conduitTheme.buttonPrimary,
|
||||
foregroundColor: context.conduitTheme.buttonPrimaryText,
|
||||
),
|
||||
child: const Text('Retry'),
|
||||
child: Text(AppLocalizations.of(context)!.retry),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user