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,7 +14,7 @@ class RecipeRepository {
|
||||
final data = await _api.getJson(RecipeApiPaths.list, token: token);
|
||||
if (data is! List) {
|
||||
throw const ApiException(
|
||||
type: ApiErrorType.unknown, message: 'Ogiltigt svar fran servern.');
|
||||
type: ApiErrorType.unknown, message: 'Ogiltigt svar från servern.');
|
||||
}
|
||||
return data
|
||||
.map((e) => Recipe.fromJson(e as Map<String, dynamic>))
|
||||
@@ -23,7 +23,7 @@ class RecipeRepository {
|
||||
rethrow;
|
||||
} catch (_) {
|
||||
throw const ApiException(
|
||||
type: ApiErrorType.network, message: 'Kunde inte hamta recept.');
|
||||
type: ApiErrorType.network, message: 'Kunde inte hämta recept.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,14 +32,14 @@ class RecipeRepository {
|
||||
final data = await _api.getJson(RecipeApiPaths.detail(id), token: token);
|
||||
if (data is! Map<String, dynamic>) {
|
||||
throw const ApiException(
|
||||
type: ApiErrorType.unknown, message: 'Ogiltigt svar fran servern.');
|
||||
type: ApiErrorType.unknown, message: 'Ogiltigt svar från servern.');
|
||||
}
|
||||
return Recipe.fromJson(data);
|
||||
} on ApiException {
|
||||
rethrow;
|
||||
} catch (_) {
|
||||
throw const ApiException(
|
||||
type: ApiErrorType.network, message: 'Kunde inte hamta recept.');
|
||||
type: ApiErrorType.network, message: 'Kunde inte hämta recept.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class RecipeRepository {
|
||||
await _api.postJson(RecipeApiPaths.list, body: body, token: token);
|
||||
if (data is! Map<String, dynamic>) {
|
||||
throw const ApiException(
|
||||
type: ApiErrorType.unknown, message: 'Ogiltigt svar fran servern.');
|
||||
type: ApiErrorType.unknown, message: 'Ogiltigt svar från servern.');
|
||||
}
|
||||
return Recipe.fromJson(data);
|
||||
} on ApiException {
|
||||
@@ -71,7 +71,7 @@ class RecipeRepository {
|
||||
);
|
||||
if (data is! Map<String, dynamic>) {
|
||||
throw const ApiException(
|
||||
type: ApiErrorType.unknown, message: 'Ogiltigt svar fran servern.');
|
||||
type: ApiErrorType.unknown, message: 'Ogiltigt svar från servern.');
|
||||
}
|
||||
return Recipe.fromJson(data);
|
||||
} on ApiException {
|
||||
@@ -103,7 +103,7 @@ class RecipeRepository {
|
||||
);
|
||||
if (data is! Map<String, dynamic>) {
|
||||
throw const ApiException(
|
||||
type: ApiErrorType.unknown, message: 'Ogiltigt svar fran servern.');
|
||||
type: ApiErrorType.unknown, message: 'Ogiltigt svar från servern.');
|
||||
}
|
||||
return ParsedRecipe.fromJson(data);
|
||||
} on ApiException {
|
||||
|
||||
Reference in New Issue
Block a user