Configuring Spring Boot to Use Custom MessageSource for Internationalization without Default Fallback
I tried several approaches but none seem to work... I'm working on a personal project and I'm relatively new to this, so bear with me..... I'm trying to set up internationalization in my Spring Boot application using a custom `MessageSource` implementation, but I'm running into issues where my application seems to fall back to the default messages instead of using my custom messages. I have defined my `MessageSource` bean like this: ```java @Bean public MessageSource messageSource() { ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); messageSource.setBasename("messages"); messageSource.setFallbackToSystemLocale(false); return messageSource; } ``` I've placed my `messages.properties` files in `src/main/resources` with entries like `greeting=Hello` and `greeting_fr=Bonjour`. When I attempt to retrieve a message for an unsupported locale, I still get the default message instead of returning null, which is what I expected. I also have this code in my controller: ```java @GetMapping("/greet") public String greet(Locale locale, Model model) { String greeting = messageSource.getMessage("greeting", null, locale); model.addAttribute("greeting", greeting); return "greet"; } ``` But when I hit the endpoint with an unsupported locale, such as `fr_FR`, I get the default `greeting` value from the `messages.properties` file instead of `null`. I have verified that the locale handling is correct by logging the `locale` variable, which shows the expected `fr_FR` value. I tried setting `setFallbackToSystemLocale(false)`, but it doesnβt seem to affect the behavior. Is there a way to completely bypass the default messages and handle missing translations gracefully? Any insights on what I might be missing would be greatly appreciated! I'm working on a CLI tool that needs to handle this. I'd really appreciate any guidance on this. How would you solve this? Any ideas how to fix this? Any feedback is welcome!