translate editevent 50%

This commit is contained in:
Valentin CZERYBA 2025-07-23 23:18:52 +02:00
parent b4dc29aff6
commit 1df36987d9
3 changed files with 72 additions and 22 deletions

View File

@ -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"
}

View File

@ -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"
}

View File

@ -170,13 +170,19 @@ class _EditEventState extends State<EditEvent>
Future<void> _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<EditEvent>
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<EditEvent>
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<EditEvent>
final _formKey = GlobalKey<FormState>();
String? _validateField(String? value) {
return value!.isEmpty ? 'Champ requis' : null;
return value!.isEmpty
? AppLocalizations.of(context)?.required_input ?? "Required input"
: null;
}
Future<void> searchSuggestions(String input) async {
@ -364,11 +393,9 @@ class _EditEventState extends State<EditEvent>
'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<EditEvent>
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<EditEvent>
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,
),