mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-31 12:19:31 +02:00
Made scale legend localizable
This commit is contained in:
+9
-6
@@ -1,10 +1,12 @@
|
||||
import { geoLonToMeters, geoMetersToLon } from '../geo';
|
||||
import { t } from '../util/locale';
|
||||
import { utilDetect } from '../util/detect';
|
||||
|
||||
|
||||
export function uiScale(context) {
|
||||
var projection = context.projection,
|
||||
isImperial = (utilDetect().locale.toLowerCase() === 'en-us'),
|
||||
locale = utilDetect().locale,
|
||||
isImperial = (locale.toLowerCase() === 'en-us'),
|
||||
maxLength = 180,
|
||||
tickHeight = 8;
|
||||
|
||||
@@ -14,7 +16,7 @@ export function uiScale(context) {
|
||||
conversion = (isImperial ? 3.28084 : 1),
|
||||
dist = geoLonToMeters(loc2[0] - loc1[0], lat) * conversion,
|
||||
scale = { dist: 0, px: 0, text: '' },
|
||||
buckets, i, val, dLon;
|
||||
buckets, i, val, dLon, textKey;
|
||||
|
||||
if (isImperial) {
|
||||
buckets = [5280000, 528000, 52800, 5280, 500, 50, 5, 1];
|
||||
@@ -39,18 +41,19 @@ export function uiScale(context) {
|
||||
if (isImperial) {
|
||||
if (scale.dist >= 5280) {
|
||||
scale.dist /= 5280;
|
||||
scale.text = String(scale.dist) + ' mi';
|
||||
textKey = 'scale.miles';
|
||||
} else {
|
||||
scale.text = String(scale.dist) + ' ft';
|
||||
textKey = 'scale.feet';
|
||||
}
|
||||
} else {
|
||||
if (scale.dist >= 1000) {
|
||||
scale.dist /= 1000;
|
||||
scale.text = String(scale.dist) + ' km';
|
||||
textKey = 'scale.kilometers';
|
||||
} else {
|
||||
scale.text = String(scale.dist) + ' m';
|
||||
textKey = 'scale.meters';
|
||||
}
|
||||
}
|
||||
scale.text = t(textKey, { quantity: scale.dist.toLocaleString(locale) });
|
||||
|
||||
return scale;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user