I'm deciding how to organize URL and put locale into it. I have two choices:
From one side example.com/en/page
looks better and more compact than example.com/page?locale=en
. From other side we have two URLs example.com/en/page
and example.com/ru/page
for one resource with two representations. Of course in case example.com/page?locale=en
we have two URLs for one resource too, but it is slightly more RESTful on my taste.
What's the best practice? What are you using and why?
Localization is part of Content-Negotiation in Restful API.
So my preferred way I would do it through headers. HTTP offers standard way of defining wanted language. Have a look at Accept-Language header.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With