Live data from Hacker News

Localization Failure: Temperature Is Hard

randomascii.wordpress.com

151–157 of 157 posts

Re: Localization Failure: Temperature Is Hard

#151
post #48

A bit related, but I hate how many errors I get because I want my system language to be English instead of my native language (Norwegian) on my laptop, phone etc. Because I don't want a badly translated experience. However, I still want units in meters, Celsius, dates written sensibly, time in 24h format etc. But not all apps understand this, which is quite annoying. It's like they only look at the language and make…

I usually set my system to English / Ireland. I get English but with normal units and € as a default currency.

Many software also have a "English/Belgium", "English/Germany", or "English/Europe" locale.

A fun trick is that if you install Windows 11 with the "English/Europe" locale, it doesn't install a lot of the bloatware because it's not defined for that location.

Re: Localization Failure: Temperature Is Hard

#152

Earlier quoted context omitted.

To be fair, imperial gallons are based on 10 lbs of water (with very specific atmospheric conditions), which while a nice round number, isn’t as easy to recreate as the U.S. gallon, which is 231 cubic inches. Of course, liters make way more sense than either of these.

Out of curiosity, how dit it end up being that weird 231 number? Why not 230? Or a nice 200?

Wikipedia says it was defined as cylinder of d=6” and h=7”, and they later redefined it to use the approximation of pi as 22/7. 22/7 * 7” * (7”/2)^2 = 231 in^3. Not approximately equal, precisely equal. It’s an interesting math oddity that I hope someone else will explain.

Also, I’ve no idea if that history is true, but it sounds plausible.

Re: Localization Failure: Temperature Is Hard

#153

Delta's like temperature are standard issue to resolve in globalization. Another fun one are complex units that are a combination of more base units like luminance (nits = candela / m*2 or mph. I worked on a package to globalize a consumer-oriented fintech reporting product. With ESG reporting this has become increasingly important to get the unit conversions and Delta's right. You end up mapping the data source unit…

How do frameworks deal with the miles/gallon -> liters/100km conversion? I've always found that one particularly interesting as one that requires inverting the units also.

In Pint you can define custom units in a unit registry. So you make your complex unit out of predefined units and the underlying unit conversion is built-in. Pint also works with pandas/numpy so you you get vectorized operations too for performance.

Re: Localization Failure: Temperature Is Hard

#154

Earlier quoted context omitted.

How do frameworks deal with the miles/gallon -> liters/100km conversion? I've always found that one particularly interesting as one that requires inverting the units also.

In Pint you can define custom units in a unit registry. So you make your complex unit out of predefined units and the underlying unit conversion is built-in. Pint also works with pandas/numpy so you you get vectorized operations too for performance.

Well, I get how mathematically you do it, I'm talking about how to make it contextually aware like the OP. A sentence like "The latest generation doubled MPG from 15 MPG to 30 MPG" should be localized to "The latest generation halved L/100km from 16 L/100km to 7.8 L/100km".

Re: Localization Failure: Temperature Is Hard

#155
post #90

Earlier quoted context omitted.

If you included non-native speakers, the stats would be much more lopsided than nearly 50:50.

You're absolutely right and I concede that I misspoke initially. However, I think the main thrust of my point is correct: that the US represents a huge chunk of the Guardian's target audience and therefore suggesting that the Guardian not localize its articles for Americans is absurd.

Why would it be absurd? What exactly prevents an American from reading British English?

Re: Localization Failure: Temperature Is Hard

#156

Earlier quoted context omitted.

In Pint you can define custom units in a unit registry. So you make your complex unit out of predefined units and the underlying unit conversion is built-in. Pint also works with pandas/numpy so you you get vectorized operations too for performance.

Well, I get how mathematically you do it, I'm talking about how to make it contextually aware like the OP. A sentence like "The latest generation doubled MPG from 15 MPG to 30 MPG" should be localized to "The latest generation halved L/100km from 16 L/100km to 7.8 L/100km".

The unit registry maps units to locales (eg EN_US, DE_DE, NL_BE) you pass the configured locale to your getter call for the unit. If you need unit strings, you can pass the locale to the string formatter.

Re: Localization Failure: Temperature Is Hard

#157

Earlier quoted context omitted.

Well, I get how mathematically you do it, I'm talking about how to make it contextually aware like the OP. A sentence like "The latest generation doubled MPG from 15 MPG to 30 MPG" should be localized to "The latest generation halved L/100km from 16 L/100km to 7.8 L/100km".

The unit registry maps units to locales (eg EN_US, DE_DE, NL_BE) you pass the configured locale to your getter call for the unit. If you need unit strings, you can pass the locale to the string formatter.

I feel like we're talking cross purposes. A sentence like "MPG increased by 20%" should be translated to "L/100km decreased by 16.6%", a sentence like "MPG increase by 5" is untranslatable without more context.

I understand if you are getting a human to translate each sentence you can just point them to the right phrases but my understanding is that you're translating text in bulk via machine translation. For scales in which the conversion is linear and the starting point is zero, this task is relatively trivial. For scales like temp where the zero points are different, you need to treat deltas different from absolute values. For scales where one is the inverse of the other, there's a lot of very tricky edge cases that make machine translation hard.

Post reply on HN