conveyal / otp.js

OTP Javascript Client & Data Bindings
MIT License
19 stars 20 forks source link

can only get one accept-language #54

Closed abyrd closed 4 years ago

abyrd commented 9 years ago

In Javascript there is a navigator.language property that returns the preferred language. Depending on the browser and settings, this can be either the most preferred language set by the user in the browser, or the language set on the operating system. The problem is that it returns only one language, so using navigator.language we cannot fall back on the user's second or third choice. There is an experimental navigator.languages property that returns all the languages in order.

One solution is to add an endpoint to OTP that echos the accept-language headers. This seems like a hack. The other solution is to use navigator.languages when it is available, and fall back on navigator.language otherwise.

The user can always manually change the language if they end up with the wrong one by default.