mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-21 07:46:58 +02:00
Add lang attribute to more display text (re: #7963)
This commit is contained in:
@@ -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 = () => [];
|
||||
|
||||
|
||||
@@ -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*/);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user