Skip to content

Feature/localisation backend#24

Open
KenCacciabueOrif wants to merge 35 commits intodevelopfrom
feature/localisation-backend
Open

Feature/localisation backend#24
KenCacciabueOrif wants to merge 35 commits intodevelopfrom
feature/localisation-backend

Conversation

@KenCacciabueOrif
Copy link
Collaborator

Localised backend messages

KenCacciabueOrif and others added 25 commits January 28, 2026 11:43

private final HttpStatus status;
private final String messageKey;
private final Object[] messageArgs;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Au niveau de la classe AppException, on ne devrait pas se préoccuper de la langue des messages. Ces messages sont reçus en paramètres sous forme de String, sans qu'on ait besoin de se demander dans quelle langue ils sont.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this logic outside of AppException in an Interface
Localisation happens after going through the app layer in the web layer, from my understanding, and we have to pass those informations through the app layer so the web layer can use them or we end up having to fetch them from the web layer, mapping which exception correspond to which message before applying the localisation

Those are metadata and not the messages themeself which, from my understanding, can pass throug the app layer while following good practices

public class GlobalExceptionHandler {

@Autowired
private MessageSource messageSource;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comme pour la classe AppException, la classe GlobalExceptionHandler ne devrait pas avoir à se préoccuper du langage de l'utilisateur.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GlobalExceptionHandler is in the web layer so It make sense for it to handle localisation but it's positon in the app folder seem misleading

Should I move it in a "web" folder instead ?

*/
public record SignUpDto(
@NotBlank(message = "First name is required")
@NotBlank(message = "{validation.signup.firstName.required}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Les messages de validation sont prédéfinis dans Spring, aussi bien en anglais qu'en français. Sauf si c'est un besoin spécifique, il ne faut pas définir de message personnalisé pour ces validations.
C'est valable pour toutes les validations dans toutes les DTO.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed custome messages from dto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants