Fix field placeholders

This commit is contained in:
John Firebaugh
2013-05-28 11:29:31 -07:00
parent 182849cbe6
commit e913d564d9
2 changed files with 18 additions and 6 deletions
+2 -1
View File
@@ -15,8 +15,9 @@ iD.presets.Field = function(id, field) {
return field.t('label', {'default': id});
};
var placeholder = field.placeholder;
field.placeholder = function() {
return field.t('placeholder', {'default': field.placeholder});
return field.t('placeholder', {'default': placeholder});
};
return field;
+16 -5
View File
@@ -19,10 +19,21 @@ function t(s, o, loc) {
if (o) for (var k in o) rep = rep.replace('{' + k + '}', o[k]);
return rep;
} else {
var missing = 'Missing translation: ' + s;
if (typeof console !== "undefined") console.error(missing);
if (loc !== 'en') return t(s, o, 'en');
if (o && 'default' in o) return o['default'];
return missing;
function missing() {
var missing = 'Missing ' + loc + ' translation: ' + s;
if (typeof console !== "undefined") console.error(missing);
return missing;
}
if (loc !== 'en') {
missing();
return t(s, o, 'en');
}
if (o && 'default' in o) {
return o['default'];
}
return missing();
}
}