From 1df36987d94d44a683e5cd930d9fb78508f91d0f Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 23 Jul 2025 23:18:52 +0200 Subject: [PATCH] translate editevent 50% --- covas_mobile/lib/l10n/app_en.arb | 13 ++++- covas_mobile/lib/l10n/app_fr.arb | 13 ++++- covas_mobile/lib/pages/EditEvent.dart | 68 +++++++++++++++++++-------- 3 files changed, 72 insertions(+), 22 deletions(-) diff --git a/covas_mobile/lib/l10n/app_en.arb b/covas_mobile/lib/l10n/app_en.arb index 04f7294..1f2224d 100644 --- a/covas_mobile/lib/l10n/app_en.arb +++ b/covas_mobile/lib/l10n/app_en.arb @@ -55,5 +55,16 @@ "error_format": "Data format error given by AI", "display_picture": "Display the Picture", "analyze_image": "Image Analyze in progress", -"loading_progress": "Loading progress" +"loading_progress": "Loading progress", +"error_event": "Event error", +"no_future_event": "No future event", +"error_user": "Error user", +"empty_input": "Empty input", +"info_event": "Event info", +"event_already": "Event already exists", +"picture_error": "Picture error", +"no_picture_published": "No picture published", +"event_update": "Event updated", +"location": "Location", +"add_event": "Add or Update a event" } \ No newline at end of file diff --git a/covas_mobile/lib/l10n/app_fr.arb b/covas_mobile/lib/l10n/app_fr.arb index 228edb4..9074e35 100644 --- a/covas_mobile/lib/l10n/app_fr.arb +++ b/covas_mobile/lib/l10n/app_fr.arb @@ -55,6 +55,17 @@ "error_format": "Erreur de format de donnée fourni par l'IA", "display_picture": "Display the Picture", "analyze_image": "Analyse de l'image en cours", -"loading_progress": "Chargement en cours" +"loading_progress": "Chargement en cours", +"error_event": "Erreur de l'évènement", +"no_future_event": "Évènement non futur", +"error_user": "Erreur de l'utilisateur", +"empty_input": "Champ vide", +"info_event": "Event info", +"event_already": "Event already exists", +"picture_error": "Erreur image", +"no_picture_published": "Image non publiée", +"event_update": "Évènement modifié", +"location": "Lieu", +"add_event": "Ajouter ou modifier un évènement" } \ No newline at end of file diff --git a/covas_mobile/lib/pages/EditEvent.dart b/covas_mobile/lib/pages/EditEvent.dart index 6b9494b..578b50c 100644 --- a/covas_mobile/lib/pages/EditEvent.dart +++ b/covas_mobile/lib/pages/EditEvent.dart @@ -170,13 +170,19 @@ class _EditEventState extends State Future _updateEvent(BuildContext context) async { if (!_isEventInFuture()) { - _showErrorDialog(context, "Erreur evenement", "Evenement non futur"); + _showErrorDialog( + context, + AppLocalizations.of(context)?.error_event ?? "Event error", + AppLocalizations.of(context)?.no_future_event ?? "No future event"); return; } final accessToken = await _getAccessToken(); if (accessToken.isEmpty) { - _showErrorDialog(context, "Erreur utilisateur", "Champ vide"); + _showErrorDialog( + context, + AppLocalizations.of(context)?.error_user ?? "User error", + AppLocalizations.of(context)?.empty_input ?? "Empty input"); return; } @@ -185,27 +191,41 @@ class _EditEventState extends State final geolocation = await _fetchGeolocation(); if (geolocation == null) { _showErrorDialog( - context, "Erreur serveur", "Aucune donnée geographique"); + context, + AppLocalizations.of(context)?.error ?? "Error", + AppLocalizations.of(context)?.no_data_geo ?? + "No geographical data"); return; } if (await _isDuplicateEvent(accessToken, geolocation)) { - _showErrorDialog(context, "Info evenement", "Evenement deja existant"); + _showErrorDialog( + context, + AppLocalizations.of(context)?.info_event ?? "Event info", + AppLocalizations.of(context)?.event_already ?? + "Event already exists"); return; } if (widget.imgPath.isNotEmpty) { imgUrl = await _uploadImage(widget.imgPath); if (imgUrl.isEmpty) { - _showErrorDialog(context, "Erreur image", "Image non postée"); + _showErrorDialog( + context, + AppLocalizations.of(context)?.picture_error ?? "Error picture", + AppLocalizations.of(context)?.no_picture_published ?? + "No picture published"); return; } } await _updateEventData(accessToken, geolocation); - showEventDialog(context, "Evenement ${inputName.text} modifie"); + String message = + AppLocalizations.of(context)?.event_update ?? "Event updated"; + showEventDialog(context, "${message} : ${inputName.text}"); } catch (e) { - _showErrorDialog(context, "Erreur serveur", "$e"); + _showErrorDialog( + context, AppLocalizations.of(context)?.error ?? "Error", "$e"); } } @@ -301,15 +321,22 @@ class _EditEventState extends State void _handleErrorResponse(BuildContext context, int statusCode) { final messages = { - 400: "Requête mal construite", - 406: "Mot de passe incorrect", - 404: "Utilisateur inconnu", - 403: "Utilisateur désactivé", - 410: "Token invalide", - 500: "Problème interne du serveur" + 400: AppLocalizations.of(context)?.request_error ?? + "Poorly constructed query", + 406: AppLocalizations.of(context)?.incorrect_password ?? + "Incorrect password", + 404: AppLocalizations.of(context)?.unknown_user ?? "Unknown user", + 403: AppLocalizations.of(context)?.disabled_user ?? "Disabled user", + 410: AppLocalizations.of(context)?.invalid_token ?? "Invalid token", + 500: AppLocalizations.of(context)?.internal_error_server ?? + "Internal error server" }; - _showErrorDialog(context, "Erreur serveur", - messages[statusCode] ?? "Problème d'authentification inconnu"); + _showErrorDialog( + context, + AppLocalizations.of(context)?.error ?? "Error", + messages[statusCode] ?? + AppLocalizations.of(context)?.unknown_error_auth ?? + "Unknown error auth"); } void _showErrorDialog(BuildContext context, String title, String message) { @@ -353,7 +380,9 @@ class _EditEventState extends State final _formKey = GlobalKey(); String? _validateField(String? value) { - return value!.isEmpty ? 'Champ requis' : null; + return value!.isEmpty + ? AppLocalizations.of(context)?.required_input ?? "Required input" + : null; } Future searchSuggestions(String input) async { @@ -364,11 +393,9 @@ class _EditEventState extends State 'https://api.mapbox.com/geocoding/v5/mapbox.places/${input}.json?access_token=${mapboxAccessToken}&types=poi,address,place'; var encoded = Uri.encodeFull(url); final response = await http.get(Uri.parse(encoded)); - print("response code suggesttion : ${response.statusCode}"); if (response.statusCode == 200) { final data = json.decode(response.body); - print("data suggestion : ${data}"); setState(() { suggestions = (data['features'] as List) .map((feature) => { @@ -393,7 +420,7 @@ class _EditEventState extends State TextField( controller: inputGeo, decoration: InputDecoration( - labelText: 'Lieu', + labelText: AppLocalizations.of(context)?.location ?? "Location", border: OutlineInputBorder(), suffixIcon: IconButton( icon: const Icon(Icons.clear), @@ -463,7 +490,8 @@ class _EditEventState extends State backgroundColor: Colors.white, drawer: MyDrawer(), appBar: AppBar( - title: Text("Add or Update a event"), + title: Text(AppLocalizations.of(context)?.add_event ?? + "Add or Update a event"), backgroundColor: Colors.blue, foregroundColor: Colors.white, ),