xcstrings-cli 2.7.0 → 2.7.2

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.
Files changed (2) hide show
  1. package/dist/index.js +115 -104
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -436,7 +436,7 @@ function Mi(e) {
436
436
  return e === null ? !1 : ir.exec(e) !== null || tr.exec(e) !== null;
437
437
  }
438
438
  function Di(e) {
439
- var n, r, i, t, o, l, a, s = 0, c = null, f, u, h;
439
+ var n, r, i, t, o, l, a, s = 0, c = null, f, u, g;
440
440
  if (n = ir.exec(e), n === null && (n = tr.exec(e)), n === null) throw new Error("Date resolve error");
441
441
  if (r = +n[1], i = +n[2] - 1, t = +n[3], !n[4])
442
442
  return new Date(Date.UTC(r, i, t));
@@ -445,7 +445,7 @@ function Di(e) {
445
445
  s += "0";
446
446
  s = +s;
447
447
  }
448
- return n[9] && (f = +n[10], u = +(n[11] || 0), c = (f * 60 + u) * 6e4, n[9] === "-" && (c = -c)), h = new Date(Date.UTC(r, i, t, o, l, a, s)), c && h.setTime(h.getTime() - c), h;
448
+ return n[9] && (f = +n[10], u = +(n[11] || 0), c = (f * 60 + u) * 6e4, n[9] === "-" && (c = -c)), g = new Date(Date.UTC(r, i, t, o, l, a, s)), c && g.setTime(g.getTime() - c), g;
449
449
  }
450
450
  function zi(e) {
451
451
  return e.toISOString();
@@ -709,31 +709,31 @@ function on(e, n) {
709
709
  `, n - 1));
710
710
  }
711
711
  function ut(e, n, r) {
712
- var i, t, o, l, a, s, c, f, u = e.kind, h = e.result, g;
713
- if (g = e.input.charCodeAt(e.position), B(g) || te(g) || g === 35 || g === 38 || g === 42 || g === 33 || g === 124 || g === 62 || g === 39 || g === 34 || g === 37 || g === 64 || g === 96 || (g === 63 || g === 45) && (t = e.input.charCodeAt(e.position + 1), B(t) || r && te(t)))
712
+ var i, t, o, l, a, s, c, f, u = e.kind, g = e.result, h;
713
+ if (h = e.input.charCodeAt(e.position), B(h) || te(h) || h === 35 || h === 38 || h === 42 || h === 33 || h === 124 || h === 62 || h === 39 || h === 34 || h === 37 || h === 64 || h === 96 || (h === 63 || h === 45) && (t = e.input.charCodeAt(e.position + 1), B(t) || r && te(t)))
714
714
  return !1;
715
- for (e.kind = "scalar", e.result = "", o = l = e.position, a = !1; g !== 0; ) {
716
- if (g === 58) {
715
+ for (e.kind = "scalar", e.result = "", o = l = e.position, a = !1; h !== 0; ) {
716
+ if (h === 58) {
717
717
  if (t = e.input.charCodeAt(e.position + 1), B(t) || r && te(t))
718
718
  break;
719
- } else if (g === 35) {
719
+ } else if (h === 35) {
720
720
  if (i = e.input.charCodeAt(e.position - 1), B(i))
721
721
  break;
722
722
  } else {
723
- if (e.position === e.lineStart && Pe(e) || r && te(g))
723
+ if (e.position === e.lineStart && Pe(e) || r && te(h))
724
724
  break;
725
- if (H(g))
725
+ if (H(h))
726
726
  if (s = e.line, c = e.lineStart, f = e.lineIndent, F(e, !1, -1), e.lineIndent >= n) {
727
- a = !0, g = e.input.charCodeAt(e.position);
727
+ a = !0, h = e.input.charCodeAt(e.position);
728
728
  continue;
729
729
  } else {
730
730
  e.position = l, e.line = s, e.lineStart = c, e.lineIndent = f;
731
731
  break;
732
732
  }
733
733
  }
734
- a && (q(e, o, l, !1), on(e, e.line - s), o = l = e.position, a = !1), J(g) || (l = e.position + 1), g = e.input.charCodeAt(++e.position);
734
+ a && (q(e, o, l, !1), on(e, e.line - s), o = l = e.position, a = !1), J(h) || (l = e.position + 1), h = e.input.charCodeAt(++e.position);
735
735
  }
736
- return q(e, o, l, !1), e.result ? !0 : (e.kind = u, e.result = h, !1);
736
+ return q(e, o, l, !1), e.result ? !0 : (e.kind = u, e.result = g, !1);
737
737
  }
738
738
  function ft(e, n) {
739
739
  var r, i, t;
@@ -772,17 +772,17 @@ function pt(e, n) {
772
772
  x(e, "unexpected end of the stream within a double quoted scalar");
773
773
  }
774
774
  function dt(e, n) {
775
- var r = !0, i, t, o, l = e.tag, a, s = e.anchor, c, f, u, h, g, m = /* @__PURE__ */ Object.create(null), d, w, k, v;
775
+ var r = !0, i, t, o, l = e.tag, a, s = e.anchor, c, f, u, g, h, m = /* @__PURE__ */ Object.create(null), d, w, k, v;
776
776
  if (v = e.input.charCodeAt(e.position), v === 91)
777
- f = 93, g = !1, a = [];
777
+ f = 93, h = !1, a = [];
778
778
  else if (v === 123)
779
- f = 125, g = !0, a = {};
779
+ f = 125, h = !0, a = {};
780
780
  else
781
781
  return !1;
782
782
  for (e.anchor !== null && (e.anchorMap[e.anchor] = a), v = e.input.charCodeAt(++e.position); v !== 0; ) {
783
783
  if (F(e, !0, n), v = e.input.charCodeAt(e.position), v === f)
784
- return e.position++, e.tag = l, e.anchor = s, e.kind = g ? "mapping" : "sequence", e.result = a, !0;
785
- r ? v === 44 && x(e, "expected the node content, but found ','") : x(e, "missed comma between flow collection entries"), w = d = k = null, u = h = !1, v === 63 && (c = e.input.charCodeAt(e.position + 1), B(c) && (u = h = !0, e.position++, F(e, !0, n))), i = e.line, t = e.lineStart, o = e.position, se(e, n, Oe, !1, !0), w = e.tag, d = e.result, F(e, !0, n), v = e.input.charCodeAt(e.position), (h || e.line === i) && v === 58 && (u = !0, v = e.input.charCodeAt(++e.position), F(e, !0, n), se(e, n, Oe, !1, !0), k = e.result), g ? oe(e, a, m, w, d, k, i, t, o) : u ? a.push(oe(e, null, m, w, d, k, i, t, o)) : a.push(d), F(e, !0, n), v = e.input.charCodeAt(e.position), v === 44 ? (r = !0, v = e.input.charCodeAt(++e.position)) : r = !1;
784
+ return e.position++, e.tag = l, e.anchor = s, e.kind = h ? "mapping" : "sequence", e.result = a, !0;
785
+ r ? v === 44 && x(e, "expected the node content, but found ','") : x(e, "missed comma between flow collection entries"), w = d = k = null, u = g = !1, v === 63 && (c = e.input.charCodeAt(e.position + 1), B(c) && (u = g = !0, e.position++, F(e, !0, n))), i = e.line, t = e.lineStart, o = e.position, se(e, n, Oe, !1, !0), w = e.tag, d = e.result, F(e, !0, n), v = e.input.charCodeAt(e.position), (g || e.line === i) && v === 58 && (u = !0, v = e.input.charCodeAt(++e.position), F(e, !0, n), se(e, n, Oe, !1, !0), k = e.result), h ? oe(e, a, m, w, d, k, i, t, o) : u ? a.push(oe(e, null, m, w, d, k, i, t, o)) : a.push(d), F(e, !0, n), v = e.input.charCodeAt(e.position), v === 44 ? (r = !0, v = e.input.charCodeAt(++e.position)) : r = !1;
786
786
  }
787
787
  x(e, "unexpected end of the stream within a flow collection");
788
788
  }
@@ -849,11 +849,11 @@ function En(e, n) {
849
849
  return a ? (e.tag = i, e.anchor = t, e.kind = "sequence", e.result = o, !0) : !1;
850
850
  }
851
851
  function gt(e, n, r) {
852
- var i, t, o, l, a, s, c = e.tag, f = e.anchor, u = {}, h = /* @__PURE__ */ Object.create(null), g = null, m = null, d = null, w = !1, k = !1, v;
852
+ var i, t, o, l, a, s, c = e.tag, f = e.anchor, u = {}, g = /* @__PURE__ */ Object.create(null), h = null, m = null, d = null, w = !1, k = !1, v;
853
853
  if (e.firstTabInLine !== -1) return !1;
854
854
  for (e.anchor !== null && (e.anchorMap[e.anchor] = u), v = e.input.charCodeAt(e.position); v !== 0; ) {
855
855
  if (!w && e.firstTabInLine !== -1 && (e.position = e.firstTabInLine, x(e, "tab characters must not be used in indentation")), i = e.input.charCodeAt(e.position + 1), o = e.line, (v === 63 || v === 58) && B(i))
856
- v === 63 ? (w && (oe(e, u, h, g, m, null, l, a, s), g = m = d = null), k = !0, w = !0, t = !0) : w ? (w = !1, t = !0) : x(e, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"), e.position += 1, v = i;
856
+ v === 63 ? (w && (oe(e, u, g, h, m, null, l, a, s), h = m = d = null), k = !0, w = !0, t = !0) : w ? (w = !1, t = !0) : x(e, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"), e.position += 1, v = i;
857
857
  else {
858
858
  if (l = e.line, a = e.lineStart, s = e.position, !se(e, r, fr, !1, !0))
859
859
  break;
@@ -861,7 +861,7 @@ function gt(e, n, r) {
861
861
  for (v = e.input.charCodeAt(e.position); J(v); )
862
862
  v = e.input.charCodeAt(++e.position);
863
863
  if (v === 58)
864
- v = e.input.charCodeAt(++e.position), B(v) || x(e, "a whitespace character is expected after the key-value separator within a block mapping"), w && (oe(e, u, h, g, m, null, l, a, s), g = m = d = null), k = !0, w = !1, t = !1, g = e.tag, m = e.result;
864
+ v = e.input.charCodeAt(++e.position), B(v) || x(e, "a whitespace character is expected after the key-value separator within a block mapping"), w && (oe(e, u, g, h, m, null, l, a, s), h = m = d = null), k = !0, w = !1, t = !1, h = e.tag, m = e.result;
865
865
  else if (k)
866
866
  x(e, "can not read an implicit mapping pair; a colon is missed");
867
867
  else
@@ -871,12 +871,12 @@ function gt(e, n, r) {
871
871
  else
872
872
  return e.tag = c, e.anchor = f, !0;
873
873
  }
874
- if ((e.line === o || e.lineIndent > n) && (w && (l = e.line, a = e.lineStart, s = e.position), se(e, n, _e, !0, t) && (w ? m = e.result : d = e.result), w || (oe(e, u, h, g, m, d, l, a, s), g = m = d = null), F(e, !0, -1), v = e.input.charCodeAt(e.position)), (e.line === o || e.lineIndent > n) && v !== 0)
874
+ if ((e.line === o || e.lineIndent > n) && (w && (l = e.line, a = e.lineStart, s = e.position), se(e, n, _e, !0, t) && (w ? m = e.result : d = e.result), w || (oe(e, u, g, h, m, d, l, a, s), h = m = d = null), F(e, !0, -1), v = e.input.charCodeAt(e.position)), (e.line === o || e.lineIndent > n) && v !== 0)
875
875
  x(e, "bad indentation of a mapping entry");
876
876
  else if (e.lineIndent < n)
877
877
  break;
878
878
  }
879
- return w && oe(e, u, h, g, m, null, l, a, s), k && (e.tag = c, e.anchor = f, e.kind = "mapping", e.result = u), k;
879
+ return w && oe(e, u, g, h, m, null, l, a, s), k && (e.tag = c, e.anchor = f, e.kind = "mapping", e.result = u), k;
880
880
  }
881
881
  function mt(e) {
882
882
  var n, r = !1, i = !1, t, o, l;
@@ -914,14 +914,14 @@ function vt(e) {
914
914
  return e.position === n && x(e, "name of an alias node must contain at least one character"), r = e.input.slice(n, e.position), G.call(e.anchorMap, r) || x(e, 'unidentified alias "' + r + '"'), e.result = e.anchorMap[r], F(e, !0, -1), !0;
915
915
  }
916
916
  function se(e, n, r, i, t) {
917
- var o, l, a, s = 1, c = !1, f = !1, u, h, g, m, d, w;
917
+ var o, l, a, s = 1, c = !1, f = !1, u, g, h, m, d, w;
918
918
  if (e.listener !== null && e.listener("open", e), e.tag = null, e.anchor = null, e.kind = null, e.result = null, o = l = a = _e === r || pr === r, i && F(e, !0, -1) && (c = !0, e.lineIndent > n ? s = 1 : e.lineIndent === n ? s = 0 : e.lineIndent < n && (s = -1)), s === 1)
919
919
  for (; mt(e) || yt(e); )
920
920
  F(e, !0, -1) ? (c = !0, a = o, e.lineIndent > n ? s = 1 : e.lineIndent === n ? s = 0 : e.lineIndent < n && (s = -1)) : a = !1;
921
921
  if (a && (a = c || t), (s === 1 || _e === r) && (Oe === r || fr === r ? d = n : d = n + 1, w = e.position - e.lineStart, s === 1 ? a && (En(e, w) || gt(e, w, d)) || dt(e, d) ? f = !0 : (l && ht(e, d) || ft(e, d) || pt(e, d) ? f = !0 : vt(e) ? (f = !0, (e.tag !== null || e.anchor !== null) && x(e, "alias node should not have any properties")) : ut(e, d, Oe === r) && (f = !0, e.tag === null && (e.tag = "?")), e.anchor !== null && (e.anchorMap[e.anchor] = e.result)) : s === 0 && (f = a && En(e, w))), e.tag === null)
922
922
  e.anchor !== null && (e.anchorMap[e.anchor] = e.result);
923
923
  else if (e.tag === "?") {
924
- for (e.result !== null && e.kind !== "scalar" && x(e, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + e.kind + '"'), u = 0, h = e.implicitTypes.length; u < h; u += 1)
924
+ for (e.result !== null && e.kind !== "scalar" && x(e, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + e.kind + '"'), u = 0, g = e.implicitTypes.length; u < g; u += 1)
925
925
  if (m = e.implicitTypes[u], m.resolve(e.result)) {
926
926
  e.result = m.construct(e.result), e.tag = m.tag, e.anchor !== null && (e.anchorMap[e.anchor] = e.result);
927
927
  break;
@@ -930,9 +930,9 @@ function se(e, n, r, i, t) {
930
930
  if (G.call(e.typeMap[e.kind || "fallback"], e.tag))
931
931
  m = e.typeMap[e.kind || "fallback"][e.tag];
932
932
  else
933
- for (m = null, g = e.typeMap.multi[e.kind || "fallback"], u = 0, h = g.length; u < h; u += 1)
934
- if (e.tag.slice(0, g[u].tag.length) === g[u].tag) {
935
- m = g[u];
933
+ for (m = null, h = e.typeMap.multi[e.kind || "fallback"], u = 0, g = h.length; u < g; u += 1)
934
+ if (e.tag.slice(0, h[u].tag.length) === h[u].tag) {
935
+ m = h[u];
936
936
  break;
937
937
  }
938
938
  m || x(e, "unknown tag !<" + e.tag + ">"), e.result !== null && m.kind !== e.kind && x(e, "unacceptable node kind for !<" + e.tag + '> tag; it should be "' + m.kind + '", not "' + e.kind + '"'), m.resolve(e.result, e.tag) ? (e.result = m.construct(e.result, e.tag), e.anchor !== null && (e.anchorMap[e.anchor] = e.result)) : x(e, "cannot resolve a node with !<" + e.tag + "> explicit tag");
@@ -1108,7 +1108,7 @@ function _r(e) {
1108
1108
  }
1109
1109
  var Fr = 1, Ve = 2, Tr = 3, Lr = 4, ie = 5;
1110
1110
  function Vt(e, n, r, i, t, o, l, a) {
1111
- var s, c = 0, f = null, u = !1, h = !1, g = i !== -1, m = -1, d = qt(he(e, 0)) && Gt(he(e, e.length - 1));
1111
+ var s, c = 0, f = null, u = !1, g = !1, h = i !== -1, m = -1, d = qt(he(e, 0)) && Gt(he(e, e.length - 1));
1112
1112
  if (n || l)
1113
1113
  for (s = 0; s < e.length; c >= 65536 ? s += 2 : s++) {
1114
1114
  if (c = he(e, s), !ve(c))
@@ -1118,15 +1118,15 @@ function Vt(e, n, r, i, t, o, l, a) {
1118
1118
  else {
1119
1119
  for (s = 0; s < e.length; c >= 65536 ? s += 2 : s++) {
1120
1120
  if (c = he(e, s), c === me)
1121
- u = !0, g && (h = h || // Foldable line = too long, and not more-indented.
1121
+ u = !0, h && (g = g || // Foldable line = too long, and not more-indented.
1122
1122
  s - m - 1 > i && e[m + 1] !== " ", m = s);
1123
1123
  else if (!ve(c))
1124
1124
  return ie;
1125
1125
  d = d && Fn(c, f, a), f = c;
1126
1126
  }
1127
- h = h || g && s - m - 1 > i && e[m + 1] !== " ";
1127
+ g = g || h && s - m - 1 > i && e[m + 1] !== " ";
1128
1128
  }
1129
- return !u && !h ? d && !l && !t(e) ? Fr : o === ye ? ie : Ve : r > 9 && _r(e) ? ie : l ? o === ye ? ie : Ve : h ? Lr : Tr;
1129
+ return !u && !g ? d && !l && !t(e) ? Fr : o === ye ? ie : Ve : r > 9 && _r(e) ? ie : l ? o === ye ? ie : Ve : g ? Lr : Tr;
1130
1130
  }
1131
1131
  function Xt(e, n, r, i, t) {
1132
1132
  e.dump = (function() {
@@ -1221,7 +1221,7 @@ function eo(e, n, r) {
1221
1221
  e.tag = t, e.dump = "{" + i + "}";
1222
1222
  }
1223
1223
  function no(e, n, r, i) {
1224
- var t = "", o = e.tag, l = Object.keys(r), a, s, c, f, u, h;
1224
+ var t = "", o = e.tag, l = Object.keys(r), a, s, c, f, u, g;
1225
1225
  if (e.sortKeys === !0)
1226
1226
  l.sort();
1227
1227
  else if (typeof e.sortKeys == "function")
@@ -1229,7 +1229,7 @@ function no(e, n, r, i) {
1229
1229
  else if (e.sortKeys)
1230
1230
  throw new M("sortKeys must be a boolean or a function");
1231
1231
  for (a = 0, s = l.length; a < s; a += 1)
1232
- h = "", (!i || t !== "") && (h += Ge(e, n)), c = l[a], f = r[c], e.replacer && (f = e.replacer.call(r, c, f)), W(e, n + 1, c, !0, !0, !0) && (u = e.tag !== null && e.tag !== "?" || e.dump && e.dump.length > 1024, u && (e.dump && me === e.dump.charCodeAt(0) ? h += "?" : h += "? "), h += e.dump, u && (h += Ge(e, n)), W(e, n + 1, f, !0, u) && (e.dump && me === e.dump.charCodeAt(0) ? h += ":" : h += ": ", h += e.dump, t += h));
1232
+ g = "", (!i || t !== "") && (g += Ge(e, n)), c = l[a], f = r[c], e.replacer && (f = e.replacer.call(r, c, f)), W(e, n + 1, c, !0, !0, !0) && (u = e.tag !== null && e.tag !== "?" || e.dump && e.dump.length > 1024, u && (e.dump && me === e.dump.charCodeAt(0) ? g += "?" : g += "? "), g += e.dump, u && (g += Ge(e, n)), W(e, n + 1, f, !0, u) && (e.dump && me === e.dump.charCodeAt(0) ? g += ":" : g += ": ", g += e.dump, t += g));
1233
1233
  e.tag = o, e.dump = t || "{}";
1234
1234
  }
1235
1235
  function Nn(e, n, r) {
@@ -1253,14 +1253,14 @@ function W(e, n, r, i, t, o, l) {
1253
1253
  e.tag = null, e.dump = r, Nn(e, r, !1) || Nn(e, r, !0);
1254
1254
  var a = br.call(e.dump), s = i, c;
1255
1255
  i && (i = e.flowLevel < 0 || e.flowLevel > n);
1256
- var f = a === "[object Object]" || a === "[object Array]", u, h;
1257
- if (f && (u = e.duplicates.indexOf(r), h = u !== -1), (e.tag !== null && e.tag !== "?" || h || e.indent !== 2 && n > 0) && (t = !1), h && e.usedDuplicates[u])
1256
+ var f = a === "[object Object]" || a === "[object Array]", u, g;
1257
+ if (f && (u = e.duplicates.indexOf(r), g = u !== -1), (e.tag !== null && e.tag !== "?" || g || e.indent !== 2 && n > 0) && (t = !1), g && e.usedDuplicates[u])
1258
1258
  e.dump = "*ref_" + u;
1259
1259
  else {
1260
- if (f && h && !e.usedDuplicates[u] && (e.usedDuplicates[u] = !0), a === "[object Object]")
1261
- i && Object.keys(e.dump).length !== 0 ? (no(e, n, e.dump, t), h && (e.dump = "&ref_" + u + e.dump)) : (eo(e, n, e.dump), h && (e.dump = "&ref_" + u + " " + e.dump));
1260
+ if (f && g && !e.usedDuplicates[u] && (e.usedDuplicates[u] = !0), a === "[object Object]")
1261
+ i && Object.keys(e.dump).length !== 0 ? (no(e, n, e.dump, t), g && (e.dump = "&ref_" + u + e.dump)) : (eo(e, n, e.dump), g && (e.dump = "&ref_" + u + " " + e.dump));
1262
1262
  else if (a === "[object Array]")
1263
- i && e.dump.length !== 0 ? (e.noArrayIndent && !l && n > 0 ? In(e, n - 1, e.dump, t) : In(e, n, e.dump, t), h && (e.dump = "&ref_" + u + e.dump)) : (Zt(e, n, e.dump), h && (e.dump = "&ref_" + u + " " + e.dump));
1263
+ i && e.dump.length !== 0 ? (e.noArrayIndent && !l && n > 0 ? In(e, n - 1, e.dump, t) : In(e, n, e.dump, t), g && (e.dump = "&ref_" + u + e.dump)) : (Zt(e, n, e.dump), g && (e.dump = "&ref_" + u + " " + e.dump));
1264
1264
  else if (a === "[object String]")
1265
1265
  e.tag !== "?" && Xt(e, e.dump, n, o, s);
1266
1266
  else {
@@ -1474,51 +1474,51 @@ function Co() {
1474
1474
  return r;
1475
1475
  var f = i.length;
1476
1476
  if (f === 0) return r;
1477
- for (var u = "", h = 1 - l, g = -1, m = r && r.length || 0, d = 0; d < m; ) {
1477
+ for (var u = "", g = 1 - l, h = -1, m = r && r.length || 0, d = 0; d < m; ) {
1478
1478
  if (r.charCodeAt(d) === 37 && d + 1 < m) {
1479
- switch (g = g > -1 ? g : 0, r.charCodeAt(d + 1)) {
1479
+ switch (h = h > -1 ? h : 0, r.charCodeAt(d + 1)) {
1480
1480
  case 100:
1481
1481
  // 'd'
1482
1482
  case 102:
1483
- if (h >= f || i[h] == null) break;
1484
- g < d && (u += r.slice(g, d)), u += Number(i[h]), g = d + 2, d++;
1483
+ if (g >= f || i[g] == null) break;
1484
+ h < d && (u += r.slice(h, d)), u += Number(i[g]), h = d + 2, d++;
1485
1485
  break;
1486
1486
  case 105:
1487
- if (h >= f || i[h] == null) break;
1488
- g < d && (u += r.slice(g, d)), u += Math.floor(Number(i[h])), g = d + 2, d++;
1487
+ if (g >= f || i[g] == null) break;
1488
+ h < d && (u += r.slice(h, d)), u += Math.floor(Number(i[g])), h = d + 2, d++;
1489
1489
  break;
1490
1490
  case 79:
1491
1491
  // 'O'
1492
1492
  case 111:
1493
1493
  // 'o'
1494
1494
  case 106:
1495
- if (h >= f || i[h] === void 0) break;
1496
- g < d && (u += r.slice(g, d));
1497
- var w = typeof i[h];
1495
+ if (g >= f || i[g] === void 0) break;
1496
+ h < d && (u += r.slice(h, d));
1497
+ var w = typeof i[g];
1498
1498
  if (w === "string") {
1499
- u += "'" + i[h] + "'", g = d + 2, d++;
1499
+ u += "'" + i[g] + "'", h = d + 2, d++;
1500
1500
  break;
1501
1501
  }
1502
1502
  if (w === "function") {
1503
- u += i[h].name || "<anonymous>", g = d + 2, d++;
1503
+ u += i[g].name || "<anonymous>", h = d + 2, d++;
1504
1504
  break;
1505
1505
  }
1506
- u += o(i[h]), g = d + 2, d++;
1506
+ u += o(i[g]), h = d + 2, d++;
1507
1507
  break;
1508
1508
  case 115:
1509
- if (h >= f)
1509
+ if (g >= f)
1510
1510
  break;
1511
- g < d && (u += r.slice(g, d)), u += String(i[h]), g = d + 2, d++;
1511
+ h < d && (u += r.slice(h, d)), u += String(i[g]), h = d + 2, d++;
1512
1512
  break;
1513
1513
  case 37:
1514
- g < d && (u += r.slice(g, d)), u += "%", g = d + 2, d++, h--;
1514
+ h < d && (u += r.slice(h, d)), u += "%", h = d + 2, d++, g--;
1515
1515
  break;
1516
1516
  }
1517
- ++h;
1517
+ ++g;
1518
1518
  }
1519
1519
  ++d;
1520
1520
  }
1521
- return g === -1 ? r : (g < m && (u += r.slice(g)), u);
1521
+ return h === -1 ? r : (h < m && (u += r.slice(h)), u);
1522
1522
  }
1523
1523
  return $e;
1524
1524
  }
@@ -1632,13 +1632,13 @@ function Eo() {
1632
1632
  return b;
1633
1633
  }
1634
1634
  function u(p) {
1635
- const y = p.customLevels || {}, A = Object.assign({}, f.levels.values, y), C = Object.assign({}, f.levels.labels, h(y));
1635
+ const y = p.customLevels || {}, A = Object.assign({}, f.levels.values, y), C = Object.assign({}, f.levels.labels, g(y));
1636
1636
  return {
1637
1637
  values: A,
1638
1638
  labels: C
1639
1639
  };
1640
1640
  }
1641
- function h(p) {
1641
+ function g(p) {
1642
1642
  const y = {};
1643
1643
  return Object.keys(p).forEach(function(A) {
1644
1644
  y[p[A]] = A;
@@ -1662,7 +1662,7 @@ function Eo() {
1662
1662
  60: "fatal"
1663
1663
  }
1664
1664
  }, f.stdSerializers = r, f.stdTimeFunctions = Object.assign({}, { nullTime: fn, epochTime: pn, unixTime: $r, isoTime: Ur });
1665
- function g(p) {
1665
+ function h(p) {
1666
1666
  const y = [];
1667
1667
  p.bindings && y.push(p.bindings);
1668
1668
  let A = p[o];
@@ -1679,7 +1679,7 @@ function Eo() {
1679
1679
  }), !y.transmit && p[C] === fe)
1680
1680
  return;
1681
1681
  p[C] = w(p, y, A, C);
1682
- const E = g(p);
1682
+ const E = h(p);
1683
1683
  E.length !== 0 && (p[C] = d(E, p[C]));
1684
1684
  }
1685
1685
  function d(p, y) {
@@ -2117,18 +2117,18 @@ async function zo({
2117
2117
  state: u
2118
2118
  });
2119
2119
  }
2120
- const h = await Rr(
2120
+ const g = await Rr(
2121
2121
  i,
2122
2122
  a,
2123
2123
  t
2124
2124
  );
2125
- if (h?.kind === "multi") {
2125
+ if (g?.kind === "multi") {
2126
2126
  if (n || r || o !== void 0 || l)
2127
2127
  throw new ae(
2128
2128
  "When adding multiple strings via --strings payload, omit --key, --comment, --text, and --language."
2129
2129
  );
2130
2130
  const w = [];
2131
- for (const [k, v] of Object.entries(h.entries))
2131
+ for (const [k, v] of Object.entries(g.entries))
2132
2132
  await Ie(
2133
2133
  e,
2134
2134
  k,
@@ -2141,22 +2141,22 @@ async function zo({
2141
2141
  ), w.push(k);
2142
2142
  return { kind: "multi", keys: w };
2143
2143
  }
2144
- const g = n;
2145
- if (!g)
2144
+ const h = n;
2145
+ if (!h)
2146
2146
  throw new ae(
2147
2147
  "--key is required unless the --strings payload contains multiple keys."
2148
2148
  );
2149
- const m = h?.kind === "single" ? h.translations : void 0, d = h?.kind === "single" ? h.comment : void 0;
2149
+ const m = g?.kind === "single" ? g.translations : void 0, d = g?.kind === "single" ? g.comment : void 0;
2150
2150
  return await Ie(
2151
2151
  e,
2152
- g,
2152
+ h,
2153
2153
  r ?? d,
2154
2154
  m,
2155
2155
  s,
2156
2156
  o,
2157
2157
  l,
2158
2158
  u
2159
- ), { kind: "single", keys: [g] };
2159
+ ), { kind: "single", keys: [h] };
2160
2160
  }
2161
2161
  const $o = (e) => {
2162
2162
  const n = Object.entries(e).sort(
@@ -2230,8 +2230,8 @@ async function Ie(e, n, r, i, t, o, l, a) {
2230
2230
  const c = s.sourceLanguage;
2231
2231
  s.strings || (s.strings = {});
2232
2232
  const u = (await sn(t))?.missingLanguagePolicy || "skip";
2233
- let h;
2234
- const g = async (O) => u === "include" ? !0 : (h || (h = await jr(e, t)), h.includes(O)), m = (O) => {
2233
+ let g;
2234
+ const h = async (O) => u === "include" ? !0 : (g || (g = await jr(e, t)), g.includes(O)), m = (O) => {
2235
2235
  X.warn(
2236
2236
  `Language "${O}" is not supported. Skipped adding its translation (missingLanguagePolicy=skip).`
2237
2237
  );
@@ -2246,7 +2246,7 @@ async function Ie(e, n, r, i, t, o, l, a) {
2246
2246
  };
2247
2247
  if (o !== void 0) {
2248
2248
  const O = l ?? c;
2249
- if (!await g(O))
2249
+ if (!await h(O))
2250
2250
  m(O);
2251
2251
  else {
2252
2252
  d.localizations = d.localizations || {};
@@ -2265,7 +2265,7 @@ async function Ie(e, n, r, i, t, o, l, a) {
2265
2265
  for (const [L, P] of Object.entries(v)) {
2266
2266
  if (o !== void 0 && L === (l ?? c))
2267
2267
  continue;
2268
- if (u === "include" ? !0 : L === c || await g(L)) {
2268
+ if (u === "include" ? !0 : L === c || await h(L)) {
2269
2269
  const I = k(P);
2270
2270
  I && O.push([L, I]);
2271
2271
  } else
@@ -2344,8 +2344,8 @@ async function Ho(e, n, r, i = !1) {
2344
2344
  if (!f)
2345
2345
  continue;
2346
2346
  if (!r || r.length === 0) {
2347
- const g = Object.keys(f.localizations ?? {});
2348
- o[c] = g, i || delete l[c], s = !0;
2347
+ const h = Object.keys(f.localizations ?? {});
2348
+ o[c] = h, i || delete l[c], s = !0;
2349
2349
  continue;
2350
2350
  }
2351
2351
  Yo(f, r, i, c, o);
@@ -2519,11 +2519,11 @@ function sl(e, n) {
2519
2519
  o = [];
2520
2520
  l = !1, a = !1;
2521
2521
  }
2522
- var u, h, g;
2522
+ var u, g, h;
2523
2523
  function m(I) {
2524
2524
  if (typeof I == "string" && (I = I.split(ol, 2)), !ue(I) || I.length !== 2)
2525
2525
  throw new Error("Invalid tags: " + I);
2526
- u = new RegExp(Be(I[0]) + "\\s*"), h = new RegExp("\\s*" + Be(I[1])), g = new RegExp("\\s*" + Be("}" + I[1]));
2526
+ u = new RegExp(Be(I[0]) + "\\s*"), g = new RegExp("\\s*" + Be(I[1])), h = new RegExp("\\s*" + Be("}" + I[1]));
2527
2527
  }
2528
2528
  m(n || D.tags);
2529
2529
  for (var d = new we(e), w, k, v, O, L, P; !d.eos(); ) {
@@ -2533,7 +2533,7 @@ function sl(e, n) {
2533
2533
  ` && (f(), s = "", c = 0, r = !1);
2534
2534
  if (!d.scan(u))
2535
2535
  break;
2536
- if (l = !0, k = d.scan(al) || "name", d.scan(tl), k === "=" ? (v = d.scanUntil($n), d.scan($n), d.scanUntil(h)) : k === "{" ? (v = d.scanUntil(g), d.scan(ll), d.scanUntil(h), k = "&") : v = d.scanUntil(h), !d.scan(h))
2536
+ if (l = !0, k = d.scan(al) || "name", d.scan(tl), k === "=" ? (v = d.scanUntil($n), d.scan($n), d.scanUntil(g)) : k === "{" ? (v = d.scanUntil(h), d.scan(ll), d.scanUntil(g), k = "&") : v = d.scanUntil(g), !d.scan(g))
2537
2537
  throw new Error("Unclosed tag at " + d.pos);
2538
2538
  if (k == ">" ? L = [k, v, w, d.pos, s, c, r] : L = [k, v, w, d.pos], c++, t.push(L), k === "#" || k === "^")
2539
2539
  i.push(L);
@@ -2654,8 +2654,8 @@ z.prototype.renderTokens = function(n, r, i, t, o) {
2654
2654
  };
2655
2655
  z.prototype.renderSection = function(n, r, i, t, o) {
2656
2656
  var l = this, a = "", s = r.lookup(n[1]);
2657
- function c(h) {
2658
- return l.render(h, r, i, o);
2657
+ function c(g) {
2658
+ return l.render(g, r, i, o);
2659
2659
  }
2660
2660
  if (s) {
2661
2661
  if (ue(s))
@@ -2890,10 +2890,10 @@ async function hl(e) {
2890
2890
  const r = (await Q(e.path)).strings ?? {}, i = le(e.keyFilter), t = le(e.textFilter), o = e.languages ? new Set(e.languages) : null, l = e.missingLanguages ? new Set(e.missingLanguages) : null, a = !!e.format, s = [];
2891
2891
  for (const c of Object.keys(r)) {
2892
2892
  if (!i(c)) continue;
2893
- const u = r[c]?.localizations ?? {}, h = Object.keys(u), g = l ? Array.from(l).some(
2893
+ const u = r[c]?.localizations ?? {}, g = Object.keys(u), h = l ? Array.from(l).some(
2894
2894
  (d) => !(d in u)
2895
2895
  ) : !0, m = [];
2896
- for (const d of h) {
2896
+ for (const d of g) {
2897
2897
  if (o && !o.has(d)) continue;
2898
2898
  const w = u[d]?.stringUnit?.value ?? "";
2899
2899
  t(w) && (a && e.format ? m.push(
@@ -2904,7 +2904,7 @@ async function hl(e) {
2904
2904
  })
2905
2905
  ) : m.push(` ${d}: ${JSON.stringify(w)}`));
2906
2906
  }
2907
- m.length !== 0 && g && (a ? s.push(...m) : s.push(`${c}:`, ...m));
2907
+ m.length !== 0 && h && (a ? s.push(...m) : s.push(`${c}:`, ...m));
2908
2908
  }
2909
2909
  return s.join(`
2910
2910
  `);
@@ -3016,8 +3016,8 @@ async function vl(e) {
3016
3016
  delete f.localizations[u];
3017
3017
  continue;
3018
3018
  }
3019
- const h = f.localizations[u]?.stringUnit?.value ?? "";
3020
- i(h) || delete f.localizations[u];
3019
+ const g = f.localizations[u]?.stringUnit?.value ?? "";
3020
+ i(g) || delete f.localizations[u];
3021
3021
  }
3022
3022
  if (!(f.localizations && Object.keys(f.localizations).length === 0))
3023
3023
  if (!l.strings[s])
@@ -3026,16 +3026,16 @@ async function vl(e) {
3026
3026
  const u = l.strings[s];
3027
3027
  if (e.mergePolicy === "output-first") {
3028
3028
  u.comment = f.comment ?? u.comment, u.extractionState = f.extractionState ?? u.extractionState, u.localizations = u.localizations ?? {};
3029
- const h = Object.entries(f.localizations ?? {});
3030
- if (h.length > 0)
3031
- for (const [g, m] of h)
3032
- u.localizations[g] = m;
3029
+ const g = Object.entries(f.localizations ?? {});
3030
+ if (g.length > 0)
3031
+ for (const [h, m] of g)
3032
+ u.localizations[h] = m;
3033
3033
  } else if (e.mergePolicy === "existing-first") {
3034
3034
  u.localizations = u.localizations ?? {};
3035
- const h = Object.entries(f.localizations ?? {});
3036
- if (h.length > 0)
3037
- for (const [g, m] of h)
3038
- u.localizations[g] || (u.localizations[g] = m);
3035
+ const g = Object.entries(f.localizations ?? {});
3036
+ if (g.length > 0)
3037
+ for (const [h, m] of g)
3038
+ u.localizations[h] || (u.localizations[h] = m);
3039
3039
  }
3040
3040
  }
3041
3041
  }
@@ -3048,10 +3048,10 @@ async function vl(e) {
3048
3048
  for (const [s, c] of Object.entries(n.strings ?? {})) {
3049
3049
  if (!r(s)) continue;
3050
3050
  const f = c.localizations ?? {};
3051
- for (const [u, h] of Object.entries(f)) {
3051
+ for (const [u, g] of Object.entries(f)) {
3052
3052
  if (t && !t.has(u)) continue;
3053
- const g = h?.stringUnit?.value ?? "";
3054
- i(g) && (a.has(u) || a.set(u, /* @__PURE__ */ new Map()), a.get(u).set(s, g));
3053
+ const h = g?.stringUnit?.value ?? "";
3054
+ i(h) && (a.has(u) || a.set(u, /* @__PURE__ */ new Map()), a.get(u).set(s, { value: h, comment: c.comment }));
3055
3055
  }
3056
3056
  }
3057
3057
  if (e.mergePolicy === "error")
@@ -3063,23 +3063,34 @@ async function vl(e) {
3063
3063
  );
3064
3064
  }
3065
3065
  for (const [s, c] of a.entries()) {
3066
- const f = Ee(o, `${s}.lproj`), u = Ee(f, l), h = await Ye(u), g = /* @__PURE__ */ new Map();
3067
- if (h && (e.mergePolicy === "existing-first" || e.mergePolicy === "output-first"))
3066
+ const f = Ee(o, `${s}.lproj`), u = Ee(f, l), g = await Ye(u), h = /* @__PURE__ */ new Map();
3067
+ if (g && (e.mergePolicy === "existing-first" || e.mergePolicy === "output-first"))
3068
3068
  try {
3069
3069
  const d = await Ke(u, "utf8"), w = /"((?:[^"\\]|\\.)*)"\s*=\s*"((?:[^"\\]|\\.)*)";/g;
3070
3070
  let k;
3071
3071
  for (; (k = w.exec(d)) !== null; ) {
3072
3072
  const v = k[1].replace(/\\"/g, '"'), O = k[2].replace(/\\"/g, '"');
3073
- g.set(v, O);
3073
+ h.set(v, { value: O });
3074
3074
  }
3075
3075
  } catch {
3076
3076
  }
3077
- for (const [d, w] of c.entries())
3078
- g.has(d) && e.mergePolicy === "existing-first" || g.set(d, w);
3077
+ for (const [d, w] of c.entries()) {
3078
+ if (h.has(d) && e.mergePolicy === "existing-first") {
3079
+ const k = h.get(d);
3080
+ h.set(d, { value: k.value, comment: w.comment });
3081
+ continue;
3082
+ }
3083
+ h.set(d, w);
3084
+ }
3079
3085
  let m = "";
3080
- for (const [d, w] of g.entries()) {
3081
- const k = d.replace(/"/g, '\\"').replace(/\n/g, "\\n"), v = w.replace(/"/g, '\\"').replace(/\n/g, "\\n");
3082
- m += `"${k}" = "${v}";
3086
+ for (const [d, w] of h.entries()) {
3087
+ m.length > 0 && (m += `
3088
+ `);
3089
+ const k = w.comment ? ` ${w.comment} ` : " No comment provided by engineer. ";
3090
+ m += `/*${k}*/
3091
+ `;
3092
+ const v = d.replace(/"/g, '\\"').replace(/\n/g, "\\n"), O = w.value.replace(/"/g, '\\"').replace(/\n/g, "\\n");
3093
+ m += `"${v}" = "${O}";
3083
3094
  `;
3084
3095
  }
3085
3096
  m.length > 0 && (await xn(f, { recursive: !0 }), await Ze(u, m, "utf8"));
@@ -3087,7 +3098,7 @@ async function vl(e) {
3087
3098
  }
3088
3099
  }
3089
3100
  const Bn = Ne(process.cwd(), "Localizable.xcstrings");
3090
- Kr(Wr(process.argv)).scriptName("xcstrings").usage("$0 <cmd> [args]").option("config", {
3101
+ Kr(Wr(process.argv)).scriptName("xcs").usage("$0 <cmd> [args]").option("config", {
3091
3102
  type: "string",
3092
3103
  describe: "Path to config file"
3093
3104
  }).option("path", {
@@ -3108,7 +3119,7 @@ Kr(Wr(process.argv)).scriptName("xcstrings").usage("$0 <cmd> [args]").option("co
3108
3119
  Fo(),
3109
3120
  pl(),
3110
3121
  yl()
3111
- ]).demandCommand(1, "").strictCommands().recommendCommands().fail((e, n, r) => {
3122
+ ]).demandCommand(1, "Please specify a command").strictCommands().recommendCommands().fail((e, n, r) => {
3112
3123
  const i = n instanceof ae;
3113
3124
  (e || i) && (console.error(S.red(e || n?.message || n)), console.log(), r.showHelp(), process.exit(1)), n && (console.error(S.red(n.message || n)), process.exit(1)), process.exit(1);
3114
3125
  }).help().argv;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xcstrings-cli",
3
- "version": "2.7.0",
3
+ "version": "2.7.2",
4
4
  "description": "A command line tool for handling xcstrings files.",
5
5
  "type": "module",
6
6
  "bin": {