Skip to content
This repository has been archived by the owner on Apr 10, 2018. It is now read-only.

Provide a way to format & localize numbers #452

Closed
1ec5 opened this issue May 6, 2016 · 4 comments
Closed

Provide a way to format & localize numbers #452

1ec5 opened this issue May 6, 2016 · 4 comments

Comments

@1ec5
Copy link
Contributor

1ec5 commented May 6, 2016

It’s possible for a style to localize string labels by choosing a language-specific field in the source. But when it comes to numeric types (elevations of peaks, for instance), the viewer is stuck with an unformatted number of the form ####.## using European digits. Ideally, it should be possible for a topo map to show elevations in #,###.## form for English, in # ###,## form for French, and in #,##,###.## form for various Indic languages. Meanwhile, an Arabic or Gujarati map would use the appropriate numeral system.

I’m not sure whether the number format should be controlled by the style (and thus defined in this specification) or determined by the system locale (and thus be implementation-specific). But I figured I’d start here because the conventional approach to localized strings involves changing style properties.

/cc @mikemorris @kkaefer @lucaswoj

@lucaswoj
Copy link

lucaswoj commented May 9, 2016

👍

While we're thinking about this, we should think about units too. A couple countries (namely Burma and Liberia (😈)) are still using imperial units.

@dpieri
Copy link

dpieri commented May 26, 2016

It would be very helpful for our use case to be able to do simple math in labels. We display feet everywhere on our map (I know, I know..) but we rely on Mapbox Terrain for elevation contours. These are in meters and people keep getting confused by this. Currently the text field on our contour labels is {ele}m, I'd love to be able to use {ele*3.28}ft

As far as I can tell, my only option is to create my own contour tileset and convert meters to feet.

Another fix would be to include something like ele_ft in the Mapbox Terrain's contour layer so each style can pick the unit it prefers. It looks like Mapbox Streets v7 takes this approach for peak labels.

@1ec5
Copy link
Contributor Author

1ec5 commented May 26, 2016

Unit customization and more general math functionality would be covered by #47. I think we should keep these two concepts separate, because (except for mixed numbers or non-positional systems like Roman or Chinese numerals) number formatting is all about text processing rather than arithmetic.

@lucaswoj lucaswoj changed the title Formatted/localized numbers Provide a way to format & localize numbers Dec 22, 2016
@lucaswoj
Copy link

lucaswoj commented Feb 1, 2017

This issue was moved to mapbox/mapbox-gl-js#4119

@lucaswoj lucaswoj closed this as completed Feb 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants