3 ms·
> Instead, I check the user's preferred locales in navigator.languages, and use that to choose which currencies to list. Old answer: Excellent. That’s how it s
by nailer 4y ago
> Instead, I check the user's preferred locales in navigator.languages, and use that to choose which currencies to list.
Old answer: Excellent. That’s how it should be done. So many people seem to ignore things browsers already tell the server.
- nicbou 4y agoWhile the locale implies a country, it does not imply its currency. Many people set their conputers to en-US without ever living there. It's a hack in my book, but it's the best hack I could come up with.
- masklinn 4y ago> While the locale implies a country, it does not imply its currency. Many people set their computers to en-US without ever living there. And the relation between system and browser language is not always simple. For instance Safari on macOS doesn't (seem to) reflect all the system-configured languages, it just returns the primary (or whatever you configured for safari specifically). So if you habitually configure your system in en (-US or -GB) then add your "mother culture" as secondary, won't work, you'll get USD or GBP which may mean nothing to your day-to-day. > It's a hack in my book, but it's the best hack I could come up with. Since it's your own site, why not add a `localStorage` override? Obviously it requires additional work (a currency picker UI of some sort, and a way to get to it from the tooltip), but it should allow users to fix things up when the defaults are not right for them.
- nicbou 4y agoThe initial design (on paper) let you choose your currency, but I went for something simpler. I like that the tooltips just use :hover styling, and could even work without JavaScript if I set their value on the server side. Something more complex would be a bit more finicky (as are the current glossary tooltips).