Rounding numbers in locale friendly way
- From: Marcus Lundblad <ml update uu se>
- To: gnome-i18n gnome org
- Subject: Rounding numbers in locale friendly way
- Date: Sun, 09 May 2021 23:10:05 +0200
Hi!
In Maps we display population numbers in the place bubbles (typically
for places like towns, cities, states and so on) based on the
"population" tag from the OpenStreetMap database.
In a some cases, where population numbers are more like estimates, this
number can be rounded, say to the nearest 100k.
Currenly we display the number just a normal integer, using the user's
locale.
So, in a cases, where let's say a city is tagged population=1200000
it would be displayed: 1,200,000 in English (and so on, 1 200 000 e.g.
in Swedish).
I have played with the idea to try to "detect" when it's an estimate.
For example, something like:
if population "an even multiple of 1000000":
display _("%s M") where %s is population / 1000000 with one significant
digit.
if population > 1000000 and "an even mulitple of 100000"
display _("%s M") where %s is population / 1000000 with two significant
digits (e.g. one decimal digit).
otherwise just display the number locale-formatted (like is done
today).
Does this make sense? Or would this assumption that millions "M" is an
appropriate concept cause trouble in some languages?
I guess the these would also be using ngettext (with the even muliples
of one million as "n".
//Marcus
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]