Localized data in REST JSON responses

We are currently developing a REST interface with localized data and are wondering which approach to use to encode localized data.

Possible options:

l10n child

{"id": 1, "l10n": {"en": {"title": "English title"}, "fi": {"title": "Suomalainen otsikko"}} 

localized properties

 {"id": 1, "title": {"en": "English title", "fi": "Suomalainen otsikko"}} 

The first encoding is easier to merge, but the second approach, for example, is compatible with the JSON-LD localization encoding.

+4
source share
1 answer

I think it's better to use subdirectories like

http://server/en/users for English > http://server/ru/users for Russians

This is better than providing users with information in different languages ​​all the time.

+2
source

Source: https://habr.com/ru/post/1437346/


All Articles