@l10nmonster/helpers-android 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/filter.js +18 -7
- package/package.json +1 -1
package/filter.js
CHANGED
|
@@ -56,13 +56,17 @@ module.exports = class AndroidFilter {
|
|
|
56
56
|
}
|
|
57
57
|
} else if ('plurals' in resNode) { // TODO: support string-array
|
|
58
58
|
for (const itemNode of resNode.plurals) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
if ('#comment' in itemNode) {
|
|
60
|
+
lastComment = itemNode['#comment'].map(e => e['#text']).join('').trim();
|
|
61
|
+
} else if ('item' in itemNode) {
|
|
62
|
+
const seg = {
|
|
63
|
+
sid: `${resNode[':@'].name}_${itemNode[':@'].quantity}`,
|
|
64
|
+
isSuffixPluralized: true,
|
|
65
|
+
str: collapseTextNodes(itemNode.item)
|
|
66
|
+
};
|
|
67
|
+
lastComment && (seg.notes = lastComment);
|
|
68
|
+
segments.push(seg);
|
|
69
|
+
}
|
|
66
70
|
}
|
|
67
71
|
lastComment = null;
|
|
68
72
|
} else {
|
|
@@ -113,7 +117,13 @@ module.exports = class AndroidFilter {
|
|
|
113
117
|
}
|
|
114
118
|
} else if ('plurals' in resNode) { // TODO: deal with plurals of the target language, not the source
|
|
115
119
|
let dropPlural = false;
|
|
120
|
+
const itemNodesToDelete = []
|
|
116
121
|
for (const itemNode of resNode.plurals) {
|
|
122
|
+
if ('#comment' in itemNode) {
|
|
123
|
+
itemNodesToDelete.push(itemNode)
|
|
124
|
+
// eslint-disable-next-line no-continue
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
117
127
|
const translation = await translator(`${resNode[':@'].name}_${itemNode[':@'].quantity}`, collapseTextNodes(itemNode.item));
|
|
118
128
|
if (translation === undefined) {
|
|
119
129
|
dropPlural = true;
|
|
@@ -121,6 +131,7 @@ module.exports = class AndroidFilter {
|
|
|
121
131
|
itemNode.item = [ { '#text': translation } ];
|
|
122
132
|
}
|
|
123
133
|
}
|
|
134
|
+
resNode.plurals = resNode.plurals.filter(n => !itemNodesToDelete.includes(n))
|
|
124
135
|
if (dropPlural) {
|
|
125
136
|
nodesToDelete.push(resNode);
|
|
126
137
|
} else {
|