conveyal / otp.js

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

Where to set metric? #58

Closed buma closed 4 years ago

buma commented 9 years ago

I see in a lot of places that it is checked if options have metric to show distances in metric but I'm not so sure where to set it so that it would be read correctly.

I'm adding internationalization and localization and changing units is one of the things I need to do.

abyrd commented 9 years ago

@trevorgerhardt, can you shed some light on this?

trevorgerhardt commented 9 years ago

It looks like it's not changeable anywhere in the UI or via configuration right now. It should probably be done in both. It should also be stored per user via cookies or localStorage.

I'd say let's do it via configuration first, via an option in the form second, and then store it in the browser per user third.

buma commented 9 years ago

I see in a code that there is possibility to change it. I changed in in distance function https://github.com/buma/otp.js/commit/cc87ba9cd154dc866d3b1655577108b0d52d8165 and in dropdowns https://github.com/buma/otp.js/commit/fb75f55c714e2b68b6f8b038aead59dd8b2ddf2d but I'm sure this isn't preferred way to do it. It should probably be somehow added in client.js into options.

I just want to know where is the best way to add it. Change itself would then be based on local settings. Because each locale also has metric/imperial settings and date/time formats. At least that is how it worked in OTP.

trevorgerhardt commented 9 years ago

In those two instances let's swap out the boolean for window.navigator.language === 'en-US' for imperial and the rest for metric for now. That should cover 80% of the use cases.