jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
693 stars 124 forks source link

Implement REST Messages API Accept-Language support #3868

Open dvaschenko opened 1 week ago

dvaschenko commented 1 week ago

In accordance with the Jmix documentation, before version 2+, it was possible to receive localized (translated) values for at least enums. To achieve this, it was enough to add the Accept-Language header to the server, as shown below:

curl --location 'http://localhost:8080/rest/messages/enums/ENUM_FQN' \

--header 'Accept-Language: de-DE' \

--header 'Authorization: Bearer token_here' \ 

After this, if the locale is present in the application, localized values are returned. In the example above, this would be in German. I think it would be nice to add this support, since our application already has everything we need, and it seems reasonable for cases where the user interface or mobile application uses Jmix REST. At the same time, there will be no need to re-localize the values on the REST client side.

Perhaps it would be a good solution to return localized values not only for enumerations, but also for entities. It is not clear from the documentation whether this was possible before.

dtaimanov commented 13 hours ago

Fix tests too: see [jmix-framework/jmix#3868] comments