mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-22 16:19:48 +02:00
add new method to reuse localized text span, closes #8994
This commit is contained in:
@@ -399,6 +399,24 @@ export function coreLocalizer() {
|
||||
return ret;
|
||||
};
|
||||
|
||||
// Adds or updates a localized text wrapped as an HTML span element with locale info to the DOM
|
||||
localizer.t.addOrUpdate = function(stringId, replacements, locale) {
|
||||
const ret = function(selection) {
|
||||
const info = localizer.tInfo(stringId, replacements, locale);
|
||||
const span = selection.selectAll('span.localized-text').data([info]);
|
||||
const enter = span.enter()
|
||||
.append('span')
|
||||
.classed('localized-text', true);
|
||||
span.merge(enter)
|
||||
.attr('lang', info.locale || 'und')
|
||||
.text((replacements && replacements.prefix || '')
|
||||
+ info.text
|
||||
+ (replacements &&replacements.suffix || ''));
|
||||
};
|
||||
ret.stringId = stringId;
|
||||
return ret;
|
||||
};
|
||||
|
||||
localizer.languageName = (code, options) => {
|
||||
|
||||
if (_languageNames && _languageNames[code]) { // name in locale language
|
||||
|
||||
@@ -371,13 +371,11 @@ export function uiNoteEditor(context) {
|
||||
|
||||
buttonSection.select('.status-button') // select and propagate data
|
||||
.attr('disabled', (hasAuth ? null : true))
|
||||
.text('')
|
||||
.each(function(d) {
|
||||
var action = (d.status === 'open' ? 'close' : 'open');
|
||||
var andComment = (d.newComment ? '_comment' : '');
|
||||
t.append('note.' + action + andComment)(d3_select(this));
|
||||
});
|
||||
buttonSection.select('.status-button')
|
||||
t.addOrUpdate('note.' + action + andComment)(d3_select(this));
|
||||
})
|
||||
.on('click.status', clickStatus);
|
||||
|
||||
buttonSection.select('.comment-button') // select and propagate data
|
||||
|
||||
Reference in New Issue
Block a user