One question for you regarding translating validat...
# spring
d
One question for you regarding translating validation messages for a bilingual API with Spring Kotlin. I usually translate a key like this :
Copy code
@GetMapping("/")
    fun getHomePage(): String {
        val messageSource = ResourceBundleMessageSource()
        messageSource.setBasenames("lang/res")
        return messageSource.getMessage("welcome", null, Locale.FRENCH)
How can I translate the keys in my (Kotlin) Post model here :
Copy code
@Entity
data class Post (
    ...

    @get: NotBlank(message = "{title.required}")
    @get: Size(min=2, max=10, message = "{title.size}")
    val title: String = "",
? Is there a way to do something like :
Copy code
@Entity
data class Post () {
    ...
    val messageSource = ResourceBundleMessageSource()
    messageSource.setBasenames("lang/res")
   
    @get: NotBlank(message = messageSource.getMessage("title.required", null, Locale.FRENCH)
    @get: Size(min=2, max=10, message = messageSource.getMessage("title.size", null, Locale.FRENCH)
    val title: String = "", ...
?