Add lang attribute to more display labels (re: #7963)

This commit is contained in:
Quincy Morgan
2020-09-23 10:10:24 -04:00
parent 7b5df1bc40
commit 4600ab596f
15 changed files with 58 additions and 43 deletions

View File

@@ -4529,13 +4529,8 @@ img.tile-debug {
height: 14px;
margin-top: -2px;
}
.ideditor[dir='ltr'] .map-footer-list a.chip .icon,
.ideditor[dir='ltr'] .map-footer-list a.chip span {
margin-right: 3px;
}
.ideditor[dir='rtl'] .map-footer-list a.chip .icon,
.ideditor[dir='rtl'] .map-footer-list a.chip span {
margin-left: 3px;
.map-footer-list a.chip span.count {
margin: 0 3px;
}
.source-switch a.chip.live {

View File

@@ -72,6 +72,12 @@ export function rendererBackgroundSource(data) {
};
source.label = function() {
var id_safe = source.id.replace(/\./g, '<TX_DOT>');
return t.html('imagery.' + id_safe + '.name', { default: _name });
};
source.description = function() {
var id_safe = source.id.replace(/\./g, '<TX_DOT>');
return t('imagery.' + id_safe + '.description', { default: _description });
@@ -538,6 +544,11 @@ rendererBackgroundSource.None = function() {
};
source.label = function() {
return t.html('background.none');
};
source.imageryUsed = function() {
return null;
};
@@ -560,6 +571,10 @@ rendererBackgroundSource.Custom = function(template) {
return t('background.custom');
};
source.label = function() {
return t.html('background.custom');
};
source.imageryUsed = function() {
// sanitize personal connection tokens - #6801

View File

@@ -6,8 +6,10 @@ import { utilGetSetValue, utilRebind, utilTriggerEvent } from '../util';
// This code assumes that the combobox values will not have duplicate entries.
// It is keyed on the `value` of the entry. Data should be an array of objects like:
// [{
// value: 'display text', // required
// title: 'hover text' // optional
// value: 'string value', // required
// display: 'label html' // optional
// title: 'hover text' // optional
// terms: ['search terms'] // optional
// }, ...]
var _comboHideTimerID;

View File

@@ -36,14 +36,14 @@ export function uiFieldCheck(field, context) {
if (options) {
for (var k in options) {
values.push(k === 'undefined' ? undefined : k);
texts.push(field.t('options.' + k, { 'default': options[k] }));
texts.push(field.t.html('options.' + k, { 'default': options[k] }));
}
} else {
values = [undefined, 'yes'];
texts = [t('inspector.unknown'), t('inspector.check.yes')];
texts = [t.html('inspector.unknown'), t.html('inspector.check.yes')];
if (field.type !== 'defaultCheck') {
values.push('no');
texts.push(t('inspector.check.no'));
texts.push(t.html('inspector.check.no'));
}
}
@@ -59,7 +59,7 @@ export function uiFieldCheck(field, context) {
for (var key in entity.tags) {
if (key in osmOneWayTags && (entity.tags[key] in osmOneWayTags[key])) {
_impliedYes = true;
texts[0] = t('presets.fields.oneway_yes.options.undefined');
texts[0] = t.html('presets.fields.oneway_yes.options.undefined');
break;
}
}

View File

@@ -151,7 +151,8 @@ export function uiFieldCombo(field, context) {
return {
key: k,
value: v,
title: v
title: v,
display: field.t.html('options.' + k, { 'default': _optstrings[k] })
};
});

View File

@@ -60,8 +60,9 @@ export function uiFormFields(context) {
if (field.keys) terms = terms.concat(field.keys);
return {
title: title,
display: field.label(),
value: title,
title: title,
field: field,
terms: terms
};

View File

@@ -59,7 +59,7 @@ export function uiInfo(context) {
title
.append('h3')
.html(function(d) { return panels[d].title; });
.html(function(d) { return panels[d].label; });
title
.append('button')

View File

@@ -9,9 +9,9 @@ import { t } from '../../core/localizer';
export function uiPanelBackground(context) {
var background = context.background();
var currSourceName = null;
var metadata = {};
var metadataKeys = [
var _currSourceName = null;
var _metadata = {};
var _metadataKeys = [
'zoom', 'vintage', 'source', 'description', 'resolution', 'accuracy'
];
@@ -23,9 +23,10 @@ export function uiPanelBackground(context) {
var isDG = (source.id.match(/^DigitalGlobe/i) !== null);
if (currSourceName !== source.name()) {
currSourceName = source.name();
metadata = {};
var sourceLabel = source.label();
if (_currSourceName !== sourceLabel) {
_currSourceName = sourceLabel;
_metadata = {};
}
selection.html('');
@@ -36,20 +37,20 @@ export function uiPanelBackground(context) {
list
.append('li')
.html(currSourceName);
.html(_currSourceName);
metadataKeys.forEach(function(k) {
_metadataKeys.forEach(function(k) {
// DigitalGlobe vintage is available in raster layers for now.
if (isDG && k === 'vintage') return;
list
.append('li')
.attr('class', 'background-info-list-' + k)
.classed('hide', !metadata[k])
.classed('hide', !_metadata[k])
.html(t.html('info_panels.background.' + k) + ':')
.append('span')
.attr('class', 'background-info-span-' + k)
.html(metadata[k]);
.html(_metadata[k]);
});
debouncedGetMetadata(selection);
@@ -103,36 +104,36 @@ export function uiPanelBackground(context) {
var tile = context.container().select('.layer-background img.tile-center'); // tile near viewport center
if (tile.empty()) return;
var sourceName = currSourceName;
var sourceName = _currSourceName;
var d = tile.datum();
var zoom = (d && d.length >= 3 && d[2]) || Math.floor(context.map().zoom());
var center = context.map().center();
// update zoom
metadata.zoom = String(zoom);
_metadata.zoom = String(zoom);
selection.selectAll('.background-info-list-zoom')
.classed('hide', false)
.selectAll('.background-info-span-zoom')
.html(metadata.zoom);
.html(_metadata.zoom);
if (!d || !d.length >= 3) return;
background.baseLayerSource().getMetadata(center, d, function(err, result) {
if (err || currSourceName !== sourceName) return;
if (err || _currSourceName !== sourceName) return;
// update vintage
var vintage = result.vintage;
metadata.vintage = (vintage && vintage.range) || t('info_panels.background.unknown');
_metadata.vintage = (vintage && vintage.range) || t('info_panels.background.unknown');
selection.selectAll('.background-info-list-vintage')
.classed('hide', false)
.selectAll('.background-info-span-vintage')
.html(metadata.vintage);
.html(_metadata.vintage);
// update other metadata
metadataKeys.forEach(function(k) {
// update other _metadata
_metadataKeys.forEach(function(k) {
if (k === 'zoom' || k === 'vintage') return; // done already
var val = result[k];
metadata[k] = val;
_metadata[k] = val;
selection.selectAll('.background-info-list-' + k)
.classed('hide', !val)
.selectAll('.background-info-span-' + k)
@@ -162,7 +163,7 @@ export function uiPanelBackground(context) {
};
panel.id = 'background';
panel.title = t('info_panels.background.title');
panel.label = t.html('info_panels.background.title');
panel.key = t('info_panels.background.key');

View File

@@ -249,7 +249,7 @@ export function uiPanelHistory(context) {
};
panel.id = 'history';
panel.title = t('info_panels.history.title');
panel.label = t.html('info_panels.history.title');
panel.key = t('info_panels.history.key');

View File

@@ -68,7 +68,7 @@ export function uiPanelLocation(context) {
};
panel.id = 'location';
panel.title = t('info_panels.location.title');
panel.label = t.html('info_panels.location.title');
panel.key = t('info_panels.location.key');

View File

@@ -217,7 +217,7 @@ export function uiPanelMeasurement(context) {
};
panel.id = 'measurement';
panel.title = t('info_panels.measurement.title');
panel.label = t.html('info_panels.measurement.title');
panel.key = t('info_panels.measurement.key');

View File

@@ -199,7 +199,7 @@ export function uiSectionBackgroundList(context) {
label
.append('span')
.html(function(d) { return d.name(); });
.html(function(d) { return d.label(); });
enter.filter(function(d) { return d.id === 'custom'; })
.append('button')

View File

@@ -81,7 +81,7 @@ export function uiSectionOverlayList(context) {
label
.append('span')
.html(function(d) { return d.name(); });
.html(function(d) { return d.label(); });
layerList.selectAll('li')

View File

@@ -89,7 +89,7 @@ export function uiSectionPhotoOverlays(context) {
.html(function(d) {
var id = d.id;
if (id === 'mapillary-signs') id = 'photo_overlays.traffic_signs';
return t(id.replace(/-/g, '_') + '.title');
return t.html(id.replace(/-/g, '_') + '.title');
});

View File

@@ -105,7 +105,7 @@ export function uiSectionValidationRules(context) {
if (d === 'unsquare_way') {
params.val = '<span class="square-degrees"></span>';
}
return t('issues.' + d + '.title', params);
return t.html('issues.' + d + '.title', params);
});
// Update