Add Swedish localization for various app actions and inventory management strings
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:logging/logging.dart';
|
||||
|
||||
import '../../../core/api/api_error_mapper.dart';
|
||||
import '../../../core/forms/form_options.dart';
|
||||
import '../../../core/l10n/l10n.dart';
|
||||
import '../../../core/ui/async_state_views.dart';
|
||||
import '../../../core/ui/product_picker_field.dart';
|
||||
import '../../auth/data/auth_providers.dart';
|
||||
@@ -44,7 +45,7 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
return StatefulBuilder(
|
||||
builder: (ctx, setDialogState) {
|
||||
return AlertDialog(
|
||||
title: Text('Lägg "${item.displayName}" i inventarie'),
|
||||
title: Text(context.l10n.pantryAddToInventoryTitle(item.displayName)),
|
||||
content: SizedBox(
|
||||
width: 380,
|
||||
child: Column(
|
||||
@@ -53,18 +54,18 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
TextField(
|
||||
controller: quantityController,
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Mängd',
|
||||
border: OutlineInputBorder(),
|
||||
decoration: InputDecoration(
|
||||
labelText: context.l10n.inventoryQuantityDisplayLabel,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
DropdownButtonFormField<String>(
|
||||
initialValue: selectedUnit,
|
||||
isExpanded: true,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Enhet',
|
||||
border: OutlineInputBorder(),
|
||||
decoration: InputDecoration(
|
||||
labelText: context.l10n.unitLabel,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
items: unitOptions
|
||||
.map((option) => DropdownMenuItem<String>(
|
||||
@@ -81,14 +82,14 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
DropdownButtonFormField<String>(
|
||||
initialValue: selectedLocation,
|
||||
isExpanded: true,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Plats (valfri)',
|
||||
border: OutlineInputBorder(),
|
||||
decoration: InputDecoration(
|
||||
labelText: context.l10n.locationOptionalLabel,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
items: [
|
||||
const DropdownMenuItem<String>(
|
||||
DropdownMenuItem<String>(
|
||||
value: null,
|
||||
child: Text('Ingen plats vald'),
|
||||
child: Text(context.l10n.pantryNoLocation),
|
||||
),
|
||||
...inventoryLocationOptions.map(
|
||||
(location) => DropdownMenuItem<String>(
|
||||
@@ -114,7 +115,7 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: const Text('Avbryt'),
|
||||
child: Text(context.l10n.cancelAction),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
@@ -123,7 +124,7 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
);
|
||||
if (quantity == null || quantity <= 0) {
|
||||
setDialogState(() {
|
||||
formError = 'Ange en giltig mängd över 0.';
|
||||
formError = context.l10n.pantryInvalidQuantity;
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -133,7 +134,7 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
'location': selectedLocation,
|
||||
});
|
||||
},
|
||||
child: const Text('Lägg till'),
|
||||
child: Text(context.l10n.addAction),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -159,7 +160,7 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
ref.invalidate(inventoryProvider);
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('${item.displayName} tillagd i inventarie.')),
|
||||
SnackBar(content: Text(context.l10n.pantryItemAdded(item.displayName))),
|
||||
);
|
||||
} catch (error) {
|
||||
_logger.severe('Failed to add item to inventory: $error');
|
||||
@@ -195,16 +196,16 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('Ta bort från baslager?'),
|
||||
content: Text('Vill du ta bort "${item.displayName}"?'),
|
||||
title: Text(context.l10n.pantryRemoveTitle),
|
||||
content: Text(context.l10n.pantryRemoveContent(item.displayName)),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
child: const Text('Avbryt'),
|
||||
child: Text(context.l10n.cancelAction),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
child: const Text('Ta bort'),
|
||||
child: Text(context.l10n.deleteAction),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -233,7 +234,7 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
if (item.category != null && item.category!.trim().isNotEmpty) {
|
||||
return item.category!;
|
||||
}
|
||||
return 'Övrigt';
|
||||
return context.l10n.pantryOtherCategory;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -242,7 +243,7 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
final productsAsync = ref.watch(pantryProductsProvider);
|
||||
|
||||
if (pantryAsync.isLoading || productsAsync.isLoading) {
|
||||
return const LoadingStateView(label: 'Laddar baslager...');
|
||||
return LoadingStateView(label: context.l10n.pantryLoading);
|
||||
}
|
||||
|
||||
if (pantryAsync.hasError || productsAsync.hasError) {
|
||||
@@ -292,11 +293,11 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Produkter du alltid räknar med att ha hemma.',
|
||||
context.l10n.pantryDescription,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
IconButton(
|
||||
tooltip: 'Gå till recept',
|
||||
tooltip: context.l10n.pantryGoToRecipesTooltip,
|
||||
icon: const Icon(Icons.restaurant_menu),
|
||||
onPressed: () => context.go('/recipes'),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user