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'
This commit is contained in:
Bryan Housel
2015-06-02 12:34:45 -04:00
parent 39895b4c7d
commit a7fca1be23
2 changed files with 9 additions and 3 deletions

View File

@@ -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;
};

View File

@@ -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: '' },