feat(localization): Implement Swedish localization and error messages
- Added localization support for Swedish and English languages. - Integrated localized strings for user messages in the API error mapper. - Updated UI components to use localized strings for labels and messages. - Ensured all error messages are context-aware and utilize the localization framework. - Created regression test to prevent common ASCII fallbacks in Swedish UI text.
This commit is contained in:
@@ -14,9 +14,9 @@ class InventoryScreen extends ConsumerWidget {
|
||||
static const _locationOptions = <String>['', 'Kyl', 'Frys', 'Skafferi'];
|
||||
static const _sortOptions = <({String value, String label})>[
|
||||
(value: '', label: 'Senast tillagda'),
|
||||
(value: 'nameAsc', label: 'Namn A-O'),
|
||||
(value: 'bestBeforeAsc', label: 'Bast fore stigande'),
|
||||
(value: 'bestBeforeDesc', label: 'Bast fore fallande'),
|
||||
(value: 'nameAsc', label: 'Namn A-Ö'),
|
||||
(value: 'bestBeforeAsc', label: 'Bäst före stigande'),
|
||||
(value: 'bestBeforeDesc', label: 'Bäst före fallande'),
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -28,7 +28,7 @@ class InventoryScreen extends ConsumerWidget {
|
||||
return inventoryAsync.when(
|
||||
loading: () => const LoadingStateView(label: 'Laddar inventarie...'),
|
||||
error: (e, _) => ErrorStateView(
|
||||
message: mapErrorToUserMessage(e),
|
||||
message: mapErrorToUserMessage(e, context),
|
||||
onRetry: () => ref.invalidate(inventoryProvider),
|
||||
),
|
||||
data: (items) {
|
||||
@@ -89,7 +89,7 @@ class InventoryScreen extends ConsumerWidget {
|
||||
padding: const EdgeInsets.only(bottom: 88),
|
||||
children: [
|
||||
filterSection,
|
||||
const EmptyStateView(title: 'Inventariet ar tomt.'),
|
||||
const EmptyStateView(title: 'Inventariet är tomt.'),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
@@ -155,7 +155,7 @@ class _InventoryTile extends StatelessWidget {
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(right: 4),
|
||||
child: Chip(
|
||||
label: Text('Oppnad'),
|
||||
label: Text('Öppnad'),
|
||||
padding: EdgeInsets.zero,
|
||||
visualDensity: VisualDensity.compact,
|
||||
),
|
||||
@@ -232,7 +232,7 @@ class _DeleteInventoryButton extends ConsumerWidget {
|
||||
} catch (error) {
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(mapErrorToUserMessage(error))),
|
||||
SnackBar(content: Text(mapErrorToUserMessage(error, context))),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user