I'm developing a REST API and I need to implement a method which needs language and country to produce result in the correct format since the result contains numbers and dates.
I was using the HTTP Accept-Language
header to get the language. The specs define the header as a language specifier, but now I'm not sure if it is correct to use this header for getting the country. For example, I want to allow a result in Spanish language but with numbers in English format (with commas instead of dots).
Is es-US
an accepted value for the Accept-Language
header?
I was thinking that I could develop a new custom header like X-Country
for my REST API.
Any thoughts? Thanks.
There are good documents out there on how to localize your APIs. There is even a stack overflow response about it.
Mostly it revolves around content negotiation and the "Accept-Language" header. If you need to have currency managed separately, the general consensus seems to keep in in the payload rather then in headers, but if you are going to do headers I would do X-Accept-Currency
(behaving akin to the other HTTP Accept headers, but with ISO 4217 currency codes) on the request, and X-Content-Currency
on the response.
UPDATE: Things have changed - if you intend to submit your header for standardization, you should not prefix it with X.