Add i18n support and integrate localized strings across modules (Login, AppShell, etc.)

This commit is contained in:
2025-09-27 12:15:57 +02:00
parent 0a0e421158
commit 140e3a7328
8 changed files with 576 additions and 71 deletions

View File

@@ -1,3 +1,4 @@
import 'package:app/core/i18n/translations.g.dart';
import 'package:app/core/ui/controller/locale_controller.dart';
import 'package:app/core/ui/controller/scale_controller.dart';
import 'package:app/core/ui/controller/theme.dart';
@@ -61,15 +62,16 @@ class _SystemBackgroundSection extends StatelessWidget {
@override
Widget build(BuildContext context) {
final t = Translations.of(context);
final vm = context.watch<AppSettingsViewModel>();
final selected = vm.themeMode;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'System-Hintergrundfarbe',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
Text(
t.settings.app.systemBackground,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
),
const SizedBox(height: 10),
@@ -94,10 +96,10 @@ class _SystemBackgroundSection extends StatelessWidget {
},
borderRadius: BorderRadius.circular(24),
constraints: const BoxConstraints(minHeight: 44, minWidth: 140),
children: const [
_SegItem(icon: Icons.phone_iphone, label: 'Systemstandard'),
_SegItem(emoji: '🌙', label: 'Dark Mode'),
_SegItem(emoji: '☀️', label: 'White Mode'),
children: [
_SegItem(icon: Icons.phone_iphone, label: t.settings.app.systemDefault),
_SegItem(emoji: '🌙', label: t.settings.app.darkMode),
_SegItem(emoji: '☀️', label: t.settings.app.lightMode),
],
),
],
@@ -134,13 +136,14 @@ class _TextScaleSection extends StatelessWidget {
@override
Widget build(BuildContext context) {
final t = Translations.of(context);
final vm = context.watch<AppSettingsViewModel>();
final selected = vm.textScale;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('Textgröße', style: TextStyle(fontWeight: FontWeight.w600)),
Text(t.settings.app.textSize, style: const TextStyle(fontWeight: FontWeight.w600)),
const SizedBox(height: 8),
ToggleButtons(
isSelected: [
@@ -167,11 +170,11 @@ class _TextScaleSection extends StatelessWidget {
},
borderRadius: BorderRadius.circular(24),
constraints: const BoxConstraints(minHeight: 44, minWidth: 120),
children: const [
_SegItem(icon: Icons.phone_android, label: 'System'),
_SegItem(icon: Icons.text_fields, label: 'Klein'),
_SegItem(icon: Icons.text_fields, label: 'Mittel'),
_SegItem(icon: Icons.text_fields, label: 'Groß'),
children: [
_SegItem(icon: Icons.phone_android, label: t.settings.app.system),
_SegItem(icon: Icons.text_fields, label: t.settings.app.small),
_SegItem(icon: Icons.text_fields, label: t.settings.app.medium),
_SegItem(icon: Icons.text_fields, label: t.settings.app.large),
],
),
],
@@ -184,25 +187,26 @@ class _LanguageSection extends StatelessWidget {
@override
Widget build(BuildContext context) {
final t = Translations.of(context);
final vm = context.watch<AppSettingsViewModel>();
final scheme = Theme.of(context).colorScheme;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Sprache', style: Theme.of(context).textTheme.titleMedium),
Text(t.settings.app.language, style: Theme.of(context).textTheme.titleMedium),
const SizedBox(height: 8),
DropdownButtonFormField<LanguagePref>(
initialValue: vm.language,
onChanged: (v) => vm.setLanguage(v ?? LanguagePref.en),
items: const [
items: [
DropdownMenuItem(
value: LanguagePref.system,
child: Text('Systemstandard'),
child: Text(t.settings.app.systemDefault),
),
DropdownMenuItem(value: LanguagePref.de, child: Text('Deutsch')),
DropdownMenuItem(value: LanguagePref.en, child: Text('Englisch')),
DropdownMenuItem(value: LanguagePref.de, child: Text(t.settings.app.german)),
DropdownMenuItem(value: LanguagePref.en, child: Text(t.settings.app.english)),
],
decoration: InputDecoration(
isDense: true,