diff --git a/modules/presets/category.js b/modules/presets/category.js index 05b280f05..a06605e33 100644 --- a/modules/presets/category.js +++ b/modules/presets/category.js @@ -34,6 +34,7 @@ export function presetCategory(categoryID, category, all) { _this.matchScore = () => -1; _this.name = () => t(`presets.categories.${categoryID}.name`, { 'default': categoryID }); + _this.nameLabel = () => t.html(`presets.categories.${categoryID}.name`, { 'default': categoryID }); _this.terms = () => []; diff --git a/modules/presets/preset.js b/modules/presets/preset.js index 7ad508e0b..a92fc2ed1 100644 --- a/modules/presets/preset.js +++ b/modules/presets/preset.js @@ -91,15 +91,31 @@ export function presetPreset(presetID, preset, addable, allFields, allPresets) { _this.name = () => { - if (_this.suggestion) { - let path = presetID.split('/'); - path.pop(); // remove brand name - // NOTE: insert an en-dash, not a hyphen (to avoid conflict with fr - nl names in Brussels etc) - return _this.originalName + ' – ' + t('presets.presets.' + path.join('/') + '.name'); - } return _this.t('name', { 'default': _this.originalName }); }; + _this.nameLabel = () => { + return _this.t.html('name', { 'default': _this.originalName }); + }; + + _this.subtitle = () => { + if (_this.suggestion) { + let path = presetID.split('/'); + path.pop(); // remove brand name + return t('presets.presets.' + path.join('/') + '.name'); + } + return null; + }; + + _this.subtitleLabel = () => { + if (_this.suggestion) { + let path = presetID.split('/'); + path.pop(); // remove brand name + return t.html('presets.presets.' + path.join('/') + '.name'); + } + return null; + }; + _this.terms = () => _this.t('terms', { 'default': _this.originalTerms }) .toLowerCase().trim().split(/\s*,+\s*/); diff --git a/modules/ui/feature_info.js b/modules/ui/feature_info.js index 04b605f14..4a86b769b 100644 --- a/modules/ui/feature_info.js +++ b/modules/ui/feature_info.js @@ -12,7 +12,7 @@ export function uiFeatureInfo(context) { var hiddenList = features.hidden().map(function(k) { if (stats[k]) { count += stats[k]; - return String(stats[k]) + ' ' + t('feature.' + k + '.description'); + return t('inspector.title_count', { title: t.html('feature.' + k + '.description'), count: stats[k] }); } }).filter(Boolean); diff --git a/modules/ui/fields/localized.js b/modules/ui/fields/localized.js index 567d86f5c..dc899b0b6 100644 --- a/modules/ui/fields/localized.js +++ b/modules/ui/fields/localized.js @@ -332,7 +332,9 @@ export function uiFieldLocalized(field, context) { var sTag = s.id.split('/', 2); var sKey = sTag[0]; var sValue = sTag[1]; + var subtitle = s.subtitle() var name = s.name(); + if (subtitle) name += ' – ' + subtitle; var dist = utilEditDistance(value, name.substring(0, value.length)); var matchesPreset = (pKey === sKey && (!pValue || pValue === sValue)); diff --git a/modules/ui/preset_list.js b/modules/ui/preset_list.js index 9ca315fba..c4040efea 100644 --- a/modules/ui/preset_list.js +++ b/modules/ui/preset_list.js @@ -330,7 +330,7 @@ export function uiPresetList(context) { .attr('class', 'namepart') .call(svgIcon((localizer.textDirection() === 'rtl' ? '#iD-icon-backward' : '#iD-icon-forward'), 'inline')) .append('span') - .html(function() { return preset.name() + '…'; }); + .html(function() { return preset.nameLabel() + '…'; }); box = selection.append('div') .attr('class', 'subgrid') @@ -393,9 +393,13 @@ export function uiPresetList(context) { .append('div') .attr('class', 'label-inner'); - // NOTE: split/join on en-dash, not a hyphen (to avoid conflict with fr - nl names in Brussels etc) + var nameparts = [ + preset.nameLabel(), + preset.subtitleLabel() + ].filter(Boolean); + label.selectAll('.namepart') - .data(preset.name().split(' – ')) + .data(nameparts) .enter() .append('div') .attr('class', 'namepart') @@ -462,10 +466,10 @@ export function uiPresetList(context) { if (isHiddenPreset) { var isAutoHidden = context.features().autoHidden(hiddenPresetFeaturesId); - var tooltipIdSuffix = isAutoHidden ? 'zoom' : 'manual'; - var tooltipObj = { features: t('feature.' + hiddenPresetFeaturesId + '.description') }; d3_select(this).call(uiTooltip() - .title(t.html('inspector.hidden_preset.' + tooltipIdSuffix, tooltipObj)) + .title(t.html('inspector.hidden_preset.' + (isAutoHidden ? 'zoom' : 'manual'), { + features: t.html('feature.' + hiddenPresetFeaturesId + '.description') + })) .placement(index < 2 ? 'bottom' : 'top') ); } diff --git a/modules/ui/sections/feature_type.js b/modules/ui/sections/feature_type.js index 6a88519c3..e5a138139 100644 --- a/modules/ui/sections/feature_type.js +++ b/modules/ui/sections/feature_type.js @@ -95,12 +95,14 @@ export function uiSectionFeatureType(context) { .preset(_presets.length === 1 ? _presets[0] : presetManager.item('point')) ); - // NOTE: split on en-dash, not a hyphen (to avoid conflict with hyphenated names) - var names = _presets.length === 1 ? _presets[0].name().split(' – ') : [t('inspector.multiple_types')]; + var nameparts = _presets.length === 1 ? [ + _presets[0].nameLabel(), + _presets[0].subtitleLabel() + ].filter(Boolean) : [t('inspector.multiple_types')]; var label = selection.select('.label-inner'); var nameparts = label.selectAll('.namepart') - .data(names, function(d) { return d; }); + .data(nameparts, function(d) { return d; }); nameparts.exit() .remove();