From a7fca1be23c5a67f41bb21fbac246a23c37f3c13 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 2 Jun 2015 12:34:45 -0400 Subject: [PATCH] Set iD.detect().locale to requested locale (closes #2672) When locale is passed in, we should use that locale in the parts of the code that are using iD.detect().locale: * tag reference * localized name display * map scale * info box The one exception is when iD detects 'en-US' and openstreetmap website tries to pass 'en', leave it as 'en-US' --- js/id/id.js | 10 ++++++++-- js/id/ui/scale.js | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/js/id/id.js b/js/id/id.js index 273a6b846..0283b6ab2 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -58,9 +58,15 @@ window.iD = function () { return context; }; - context.locale = function(_, path) { - locale = _; + context.locale = function(loc, path) { + locale = loc; localePath = path; + + // Also set iD.detect().locale (unless we detected 'en-us' and openstreetmap wants 'en').. + if (!(loc.toLowerCase() === 'en' && iD.detect().locale.toLowerCase() === 'en-us')) { + iD.detect().locale = loc; + } + return context; }; diff --git a/js/id/ui/scale.js b/js/id/ui/scale.js index d24d00fb9..f49f2ee36 100644 --- a/js/id/ui/scale.js +++ b/js/id/ui/scale.js @@ -1,11 +1,11 @@ iD.ui.Scale = function(context) { var projection = context.projection, - imperial = (iD.detect().locale.toLowerCase() === 'en-us'), maxLength = 180, tickHeight = 8; function scaleDefs(loc1, loc2) { var lat = (loc2[1] + loc1[1]) / 2, + imperial = (iD.detect().locale.toLowerCase() === 'en-us'), conversion = (imperial ? 3.28084 : 1), dist = iD.geo.lonToMeters(loc2[0] - loc1[0], lat) * conversion, scale = { dist: 0, px: 0, text: '' },