mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 13:18:15 +02:00
Don't rely on the dataEn export for checking if a string exists
Instead use the special `default` key for supplying a fallback string
This commit is contained in:
@@ -3,7 +3,6 @@ import {
|
||||
select as d3_select
|
||||
} from 'd3-selection';
|
||||
|
||||
import { dataEn } from '../../data';
|
||||
import { modeSelect } from '../modes/select';
|
||||
import { t } from '../util/locale';
|
||||
import { utilDisplayName, utilHighlightEntities, utilEntityRoot } from '../util';
|
||||
@@ -11,26 +10,16 @@ import { utilDisplayName, utilHighlightEntities, utilEntityRoot } from '../util'
|
||||
export function uiImproveOsmDetails(context) {
|
||||
let _qaItem;
|
||||
|
||||
|
||||
function issueDetail(d) {
|
||||
const unknown = t('inspector.unknown');
|
||||
|
||||
if (!d) return unknown;
|
||||
|
||||
if (d.desc) return d.desc;
|
||||
|
||||
const itemType = d.issueKey;
|
||||
const et = dataEn.QA.improveOSM.error_types[itemType];
|
||||
|
||||
let detail;
|
||||
if (et && et.description) {
|
||||
detail = t(`QA.improveOSM.error_types.${itemType}.description`, d.replacements);
|
||||
} else {
|
||||
detail = unknown;
|
||||
}
|
||||
|
||||
return detail;
|
||||
const issueKey = d.issueKey;
|
||||
d.replacements = d.replacements || {};
|
||||
d.replacements.default = t('inspector.unknown'); // special key `default` works as a fallback string
|
||||
return t(`QA.improveOSM.error_types.${issueKey}.description`, d.replacements);
|
||||
}
|
||||
|
||||
|
||||
function improveOsmDetails(selection) {
|
||||
const details = selection.selectAll('.error-details')
|
||||
.data(
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
import { dataEn } from '../../data';
|
||||
import { t } from '../util/locale';
|
||||
|
||||
|
||||
export function uiImproveOsmHeader() {
|
||||
let _qaItem;
|
||||
|
||||
|
||||
function issueTitle(d) {
|
||||
const unknown = t('inspector.unknown');
|
||||
|
||||
if (!d) return unknown;
|
||||
const { issueKey } = d;
|
||||
const et = dataEn.QA.improveOSM.error_types[issueKey];
|
||||
|
||||
if (et && et.title) {
|
||||
return t(`QA.improveOSM.error_types.${issueKey}.title`);
|
||||
} else {
|
||||
return unknown;
|
||||
}
|
||||
const issueKey = d.issueKey;
|
||||
d.replacements = d.replacements || {};
|
||||
d.replacements.default = t('inspector.unknown'); // special key `default` works as a fallback string
|
||||
return t(`QA.improveOSM.error_types.${issueKey}.title`, d.replacements);
|
||||
}
|
||||
|
||||
|
||||
function improveOsmHeader(selection) {
|
||||
const header = selection.selectAll('.qa-header')
|
||||
.data(
|
||||
@@ -57,12 +51,11 @@ export function uiImproveOsmHeader() {
|
||||
.attr('transform', 'translate(3.5, 5)')
|
||||
.attr('xlink:href', d => {
|
||||
const picon = d.icon;
|
||||
|
||||
if (!picon) {
|
||||
return '';
|
||||
return '';
|
||||
} else {
|
||||
const isMaki = /^maki-/.test(picon);
|
||||
return `#${picon}${isMaki ? '-11' : ''}`;
|
||||
const isMaki = /^maki-/.test(picon);
|
||||
return `#${picon}${isMaki ? '-11' : ''}`;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -3,34 +3,29 @@ import {
|
||||
select as d3_select
|
||||
} from 'd3-selection';
|
||||
|
||||
import { dataEn } from '../../data';
|
||||
import { modeSelect } from '../modes/select';
|
||||
import { t } from '../util/locale';
|
||||
import { utilDisplayName, utilHighlightEntities, utilEntityRoot } from '../util';
|
||||
|
||||
|
||||
export function uiKeepRightDetails(context) {
|
||||
let _qaItem;
|
||||
|
||||
|
||||
function issueDetail(d) {
|
||||
const { itemType, parentIssueType } = d;
|
||||
const unknown = t('inspector.unknown');
|
||||
if (!d) return unknown;
|
||||
let replacements = d.replacements || {};
|
||||
replacements.default = unknown; // special key `default` works as a fallback string
|
||||
|
||||
const { itemType, parentIssueType, replacements } = d;
|
||||
const et = dataEn.QA.keepRight.errorTypes[itemType];
|
||||
const pt = dataEn.QA.keepRight.errorTypes[parentIssueType];
|
||||
|
||||
let detail;
|
||||
if (et && et.description) {
|
||||
detail = t(`QA.keepRight.errorTypes.${itemType}.description`, replacements);
|
||||
} else if (pt && pt.description) {
|
||||
let detail = t(`QA.keepRight.errorTypes.${itemType}.description`, replacements);
|
||||
if (detail === unknown) {
|
||||
detail = t(`QA.keepRight.errorTypes.${parentIssueType}.description`, replacements);
|
||||
} else {
|
||||
detail = unknown;
|
||||
}
|
||||
|
||||
return detail;
|
||||
}
|
||||
|
||||
|
||||
function keepRightDetails(selection) {
|
||||
const details = selection.selectAll('.error-details')
|
||||
.data(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { dataEn } from '../../data';
|
||||
import { svgIcon } from '../svg/icon';
|
||||
import { t } from '../util/locale';
|
||||
|
||||
@@ -6,24 +5,21 @@ import { t } from '../util/locale';
|
||||
export function uiKeepRightHeader() {
|
||||
let _qaItem;
|
||||
|
||||
|
||||
function issueTitle(d) {
|
||||
const unknown = t('inspector.unknown');
|
||||
|
||||
if (!d) return unknown;
|
||||
const { itemType, parentIssueType } = d;
|
||||
const unknown = t('inspector.unknown');
|
||||
let replacements = d.replacements || {};
|
||||
replacements.default = unknown; // special key `default` works as a fallback string
|
||||
|
||||
const et = dataEn.QA.keepRight.errorTypes[itemType];
|
||||
const pt = dataEn.QA.keepRight.errorTypes[parentIssueType];
|
||||
|
||||
if (et && et.title) {
|
||||
return t(`QA.keepRight.errorTypes.${itemType}.title`);
|
||||
} else if (pt && pt.title) {
|
||||
return t(`QA.keepRight.errorTypes.${parentIssueType}.title`);
|
||||
} else {
|
||||
return unknown;
|
||||
let title = t(`QA.keepRight.errorTypes.${itemType}.title`, replacements);
|
||||
if (title === unknown) {
|
||||
title = t(`QA.keepRight.errorTypes.${parentIssueType}.title`, replacements);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
function keepRightHeader(selection) {
|
||||
const header = selection.selectAll('.qa-header')
|
||||
.data(
|
||||
@@ -54,7 +50,8 @@ export function uiKeepRightHeader() {
|
||||
.text(issueTitle);
|
||||
}
|
||||
|
||||
keepRightHeader.issue = val => {
|
||||
|
||||
keepRightHeader.issue = function(val) {
|
||||
if (!arguments.length) return _qaItem;
|
||||
_qaItem = val;
|
||||
return keepRightHeader;
|
||||
|
||||
Reference in New Issue
Block a user