Reputation: 1661
I have a program that displays the Weather in the current region of the users' computer.
The problem is that I want to automate the metrics conversion.
so for example in Europe, we measure the heat with Celsius and in the USA we measure it with Fahrenheit same goes for Km/H and M/H in speed respectively.
I want to know if there is a way to know the metric system of a country without having to write a hardcoded table for every country in the world.
Upvotes: 0
Views: 274
Reputation: 9182
Some operating systems expose an API to find the preferred measurement standard.
LocaleData.MeasurementSystem
CFPreferencesCopyValue
(guide)GetLocaleInfo
NSLocaleUsesMetricSystem
(guide)Otherwise, if you know their location, you can default to Imperial in the United States, Liberia or Myanmar and use Metric in other locations:
Regardless, you should still allow users to manually choose their preference.
Upvotes: 4