Feature Request: Support for Localized Message Handling in API Responses #43298
Labels
for: external-project
For an external project and not something we can fix
status: duplicate
A duplicate of another issue
Description:
I would like to propose a new feature to enhance Spring’s support for localized message handling in API responses. This feature could provide a utility or service that dynamically resolves localized messages based on message codes associated with API response objects. This functionality would streamline the process of internationalization for developers building REST APIs or web services with Spring Boot.
Proposed Solution:
The core idea of this feature is a utility class that resolves messages dynamically based on the current Locale, similar to the code below. The utility could work by:
Example Use Cases:
Context & Usage
ApiResponse Base Class:
To complement this utility, I propose a base ApiResponse class that API response objects can extend, ensuring each response object contains a message code for localization.
Extending classes
Advantages:
Conclusion:
This feature could greatly improve the developer experience by providing a robust and reusable solution for handling localized messages in API responses, reducing the overhead of managing message resolution in every response handler.
Related Issues:
Please let me know if any similar issues or requests have been made in the past. This feature could also tie into Spring’s existing support for internationalization and message resolution.
The text was updated successfully, but these errors were encountered: