Add more exacting descriptions for splitting different amounts of different types of features at different amounts of points (re: #7990)

This commit is contained in:
Quincy Morgan
2020-09-29 14:15:40 -04:00
parent 5239017cdf
commit 1daab15766
3 changed files with 70 additions and 21 deletions
+23 -6
View File
@@ -442,18 +442,35 @@ en:
split:
title: Split
description:
line: Split this line into two at this node.
area: Split the boundary of this area into two.
multiple: Split the lines/area boundaries at this node into two.
line:
single:
single_node: Divide this line into two at this point.
multiple_node: Divide this line at these points.
multiple:
single_node: Divide these lines at this point.
multiple_node: Divide these lines at these points.
area:
single:
single_node: Divide the edge of this area into two at this point.
multiple_node: Divide the edge of this area at these points.
multiple:
single_node: Divide the edges of these areas at this point.
multiple_node: Divide the edges of these areas at these points.
feature:
multiple:
multiple_node: Divide these features at these points.
key: X
annotation:
line: Split a line.
area: Split an area boundary.
line:
one: "Split a line."
other: "Split {n} lines."
area:
one: "Split the edge of an area."
other: "Split {n} areas."
feature:
one: "Split a feature."
other: "Split {n} features."
not_eligible: Lines can't be split at their beginning or end.
multiple_ways: There are too many lines here to split.
connected_to_hidden: This can't be split because it is connected to a hidden feature.
restriction:
annotation:
+33 -6
View File
@@ -590,21 +590,48 @@
"split": {
"title": "Split",
"description": {
"line": "Split this line into two at this node.",
"area": "Split the boundary of this area into two.",
"multiple": "Split the lines/area boundaries at this node into two."
"line": {
"single": {
"single_node": "Divide this line into two at this point.",
"multiple_node": "Divide this line at these points."
},
"multiple": {
"single_node": "Divide these lines at this point.",
"multiple_node": "Divide these lines at these points."
}
},
"area": {
"single": {
"single_node": "Divide the edge of this area into two at this point.",
"multiple_node": "Divide the edge of this area at these points."
},
"multiple": {
"single_node": "Divide the edges of these areas at this point.",
"multiple_node": "Divide the edges of these areas at these points."
}
},
"feature": {
"multiple": {
"multiple_node": "Divide these features at these points."
}
}
},
"key": "X",
"annotation": {
"line": "Split a line.",
"area": "Split an area boundary.",
"line": {
"one": "Split a line.",
"other": "Split {n} lines."
},
"area": {
"one": "Split the edge of an area.",
"other": "Split {n} areas."
},
"feature": {
"one": "Split a feature.",
"other": "Split {n} features."
}
},
"not_eligible": "Lines can't be split at their beginning or end.",
"multiple_ways": "There are too many lines here to split.",
"connected_to_hidden": "This can't be split because it is connected to a hidden feature."
},
"restriction": {
+14 -9
View File
@@ -16,10 +16,21 @@ export function operationSplit(context, selectedIDs) {
_vertexIds.length + _selectedWayIds.length === selectedIDs.length;
var _action = actionSplit(_vertexIds);
var _ways = [];
var _geometry = 'feature';
var _waysAmount = 'single';
var _nodesAmount = _vertexIds.length === 1 ? 'single' : 'multiple';
if (_isAvailable) {
if (_selectedWayIds.length) _action.limitWays(_selectedWayIds);
_ways = _action.ways(context.graph());
var geometries = {};
_ways.forEach(function(way) {
geometries[way.geometry(context.graph())] = true;
});
if (Object.keys(geometries).length === 1) {
_geometry = Object.keys(geometries)[0];
}
_waysAmount = _ways.length === 1 ? 'single' : 'multiple';
}
@@ -47,19 +58,13 @@ export function operationSplit(context, selectedIDs) {
operation.tooltip = function() {
var disable = operation.disabled();
if (disable) {
return t('operations.split.' + disable);
} else if (_ways.length === 1) {
return t('operations.split.description.' + context.graph().geometry(_ways[0].id));
}
return t('operations.split.description.multiple');
if (disable) return t('operations.split.' + disable);
return t('operations.split.description.' + _geometry + '.' + _waysAmount + '.' + _nodesAmount + '_node');
};
operation.annotation = function() {
return _ways.length === 1 ?
t('operations.split.annotation.' + context.graph().geometry(_ways[0].id)) :
t('operations.split.annotation.feature', { n: _ways.length });
return t('operations.split.annotation.' + _geometry, { n: _ways.length });
};