From e913d564d9d2aa5460ea17a6e349be284bb9b406 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 28 May 2013 11:29:31 -0700 Subject: [PATCH] Fix field placeholders --- js/id/presets/field.js | 3 ++- js/lib/locale.js | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/js/id/presets/field.js b/js/id/presets/field.js index 6e5525627..afbb9f4cb 100644 --- a/js/id/presets/field.js +++ b/js/id/presets/field.js @@ -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; diff --git a/js/lib/locale.js b/js/lib/locale.js index 4635a06e5..6813fbc6d 100644 --- a/js/lib/locale.js +++ b/js/lib/locale.js @@ -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(); } }