xcstrings-cli 2.5.0 → 2.5.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.
Files changed (3) hide show
  1. package/README.md +47 -0
  2. package/dist/index.js +95 -91
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -266,6 +266,53 @@ These are the settings you can specify in the config file:
266
266
  * `skip`: Only add translations for languages included in the `xcs languages` output. (Default)
267
267
  * `include`: Add translations even when they are not recognized by the Xcode project or xcs language list.
268
268
 
269
+ ## Practical use cases
270
+
271
+ ### Case 1: Translate all missing strings using LLM
272
+
273
+ Suppose you have a xcstrings file and want to add Japanese and Simplified Chinese translations generated by LLM.
274
+
275
+ Firstly, list the strings missing those languages:
276
+
277
+ ```bash
278
+ xcs strings --languages en --missing-languages ja zh-Hans
279
+ # closeAction:
280
+ # en: "Close"
281
+ # detailsAction:
282
+ # en: "Details"
283
+ ```
284
+
285
+ Then, copy the output and use it as a prompt for the LLM to generate translations. We offer [xcstrings-cli Helper](https://chatgpt.com/g/g-69365945f8bc8191be3146f880238957-xcstrings-cli-helper), a Custom GPT that can help you generate translations in the form of an `xcs add` command. The prompt could be like this:
286
+
287
+ ```
288
+ closeAction:
289
+ en: "Close"
290
+ detailsAction:
291
+ en: "Details"
292
+
293
+ Languages: ja, zh-Hans
294
+ No comments needed.
295
+ ```
296
+
297
+ Then the Custom GPT will generate an `xcs add` command like this:
298
+
299
+ ```bash
300
+ xcs add --strings << EOF
301
+ closeAction:
302
+ translations:
303
+ en: Close
304
+ ja: 閉じる
305
+ zh-Hans: 关闭
306
+ detailsAction:
307
+ translations:
308
+ en: Details
309
+ ja: 詳細
310
+ zh-Hans: 详情
311
+ EOF
312
+ ```
313
+
314
+ Finally, copy the generated command and run it in your terminal to add the translations to your xcstrings file.
315
+
269
316
  ## Q&A
270
317
 
271
318
  **Q: Strings are not being added for some languages. Why?**
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import De from "json5";
7
7
  import { select as Pr, checkbox as an, confirm as Dr } from "@inquirer/prompts";
8
8
  import S from "chalk";
9
9
  import { readFile as $r, writeFile as Nn, readdir as Rn } from "node:fs/promises";
10
- import { XcodeProject as Br } from "@bacons/xcode";
10
+ import { XcodeProject as zr } from "@bacons/xcode";
11
11
  const Le = "xcstrings-cli", sn = Mr(Le, {
12
12
  searchPlaces: [
13
13
  `${Le}.json`,
@@ -33,7 +33,7 @@ function cn(e, n) {
33
33
  return r.path;
34
34
  return null;
35
35
  }
36
- async function zr(e, n, r) {
36
+ async function Br(e, n, r) {
37
37
  const i = n?.xcstringsPaths, t = i?.some((s) => typeof s != "string") ?? !1, o = e.startsWith("alias:") ? e.slice(6) : null;
38
38
  if (o) {
39
39
  const s = cn(i, o);
@@ -226,11 +226,11 @@ function Kr() {
226
226
  const A = p.browser.write || n;
227
227
  p.browser.write && (p.browser.asObject = !0);
228
228
  const k = p.serializers || {}, E = c(p.browser.serialize, k);
229
- let B = p.browser.serialize;
230
- Array.isArray(p.browser.serialize) && p.browser.serialize.indexOf("!stdSerializers.err") > -1 && (B = !1);
229
+ let z = p.browser.serialize;
230
+ Array.isArray(p.browser.serialize) && p.browser.serialize.indexOf("!stdSerializers.err") > -1 && (z = !1);
231
231
  const K = Object.keys(p.customLevels || {}), O = ["error", "fatal", "warn", "info", "debug", "trace"].concat(K);
232
- typeof A == "function" && O.forEach(function(z) {
233
- A[z] = A;
232
+ typeof A == "function" && O.forEach(function(B) {
233
+ A[B] = A;
234
234
  }), (p.enabled === !1 || p.browser.disabled) && (p.level = "silent");
235
235
  const M = p.level || "info", w = Object.create(A);
236
236
  w.log || (w.log = se), s(w, O, A), a({}, w), Object.defineProperty(w, "levelVal", {
@@ -247,32 +247,32 @@ function Kr() {
247
247
  levels: O,
248
248
  timestamp: J(p)
249
249
  };
250
- w.levels = f(p), w.level = M, w.setMaxListeners = w.getMaxListeners = w.emit = w.addListener = w.on = w.prependListener = w.once = w.prependOnceListener = w.removeListener = w.removeAllListeners = w.listeners = w.listenerCount = w.eventNames = w.write = w.flush = se, w.serializers = k, w._serialize = E, w._stdErrSerialize = B, w.child = Ir, m && (w._logEvent = L());
250
+ w.levels = f(p), w.level = M, w.setMaxListeners = w.getMaxListeners = w.emit = w.addListener = w.on = w.prependListener = w.once = w.prependOnceListener = w.removeListener = w.removeAllListeners = w.listeners = w.listenerCount = w.eventNames = w.write = w.flush = se, w.serializers = k, w._serialize = E, w._stdErrSerialize = z, w.child = Ir, m && (w._logEvent = L());
251
251
  function ve() {
252
252
  return i(this.level, this);
253
253
  }
254
254
  function Z() {
255
255
  return this._level;
256
256
  }
257
- function jr(z) {
258
- if (z !== "silent" && !this.levels.values[z])
259
- throw Error("unknown level " + z);
260
- this._level = z, y(this, Y, w, "error"), y(this, Y, w, "fatal"), y(this, Y, w, "warn"), y(this, Y, w, "info"), y(this, Y, w, "debug"), y(this, Y, w, "trace"), K.forEach((ee) => {
257
+ function jr(B) {
258
+ if (B !== "silent" && !this.levels.values[B])
259
+ throw Error("unknown level " + B);
260
+ this._level = B, y(this, Y, w, "error"), y(this, Y, w, "fatal"), y(this, Y, w, "warn"), y(this, Y, w, "info"), y(this, Y, w, "debug"), y(this, Y, w, "trace"), K.forEach((ee) => {
261
261
  y(this, Y, w, ee);
262
262
  });
263
263
  }
264
- function Ir(z, ee) {
265
- if (!z)
264
+ function Ir(B, ee) {
265
+ if (!B)
266
266
  throw new Error("missing bindings for child Pino");
267
- ee = ee || {}, E && z.serializers && (ee.serializers = z.serializers);
267
+ ee = ee || {}, E && B.serializers && (ee.serializers = B.serializers);
268
268
  const rn = ee.serializers;
269
269
  if (E && rn) {
270
270
  var xe = Object.assign({}, k, rn), tn = p.browser.serialize === !0 ? Object.keys(xe) : E;
271
- delete z.serializers, x([z], tn, xe, this._stdErrSerialize);
271
+ delete B.serializers, x([B], tn, xe, this._stdErrSerialize);
272
272
  }
273
273
  function on(ln) {
274
- this._childLevel = (ln._childLevel | 0) + 1, this.bindings = z, xe && (this.serializers = xe, this._serialize = tn), m && (this._logEvent = L(
275
- [].concat(ln._logEvent.bindings, z)
274
+ this._childLevel = (ln._childLevel | 0) + 1, this.bindings = B, xe && (this.serializers = xe, this._serialize = tn), m && (this._logEvent = L(
275
+ [].concat(ln._logEvent.bindings, B)
276
276
  ));
277
277
  }
278
278
  on.prototype = this;
@@ -359,14 +359,14 @@ function Kr() {
359
359
  }
360
360
  function C(p, m, A, k, E = {}) {
361
361
  const {
362
- level: B = () => p.levels.values[m],
362
+ level: z = () => p.levels.values[m],
363
363
  log: K = (Z) => Z
364
364
  } = E;
365
365
  p._serialize && x(A, p._serialize, p.serializers, p._stdErrSerialize);
366
366
  const O = A.slice();
367
367
  let M = O[0];
368
368
  const w = {};
369
- k && (w.time = k), w.level = B(m, p.levels.values[m]);
369
+ k && (w.time = k), w.level = z(m, p.levels.values[m]);
370
370
  let Y = (p._childLevel | 0) + 1;
371
371
  if (Y < 1 && (Y = 1), M !== null && typeof M == "object") {
372
372
  for (; Y-- && typeof O[0] == "object"; )
@@ -380,11 +380,11 @@ function Kr() {
380
380
  if (k && p[E] instanceof Error)
381
381
  p[E] = u.stdSerializers.err(p[E]);
382
382
  else if (typeof p[E] == "object" && !Array.isArray(p[E]))
383
- for (const B in p[E])
384
- m && m.indexOf(B) > -1 && B in A && (p[E][B] = A[B](p[E][B]));
383
+ for (const z in p[E])
384
+ m && m.indexOf(z) > -1 && z in A && (p[E][z] = A[z](p[E][z]));
385
385
  }
386
386
  function _(p, m, A) {
387
- const k = m.send, E = m.ts, B = m.methodLevel, K = m.methodValue, O = m.val, M = p._logEvent.bindings;
387
+ const k = m.send, E = m.ts, z = m.methodLevel, K = m.methodValue, O = m.val, M = p._logEvent.bindings;
388
388
  x(
389
389
  A,
390
390
  p._serialize || Object.keys(p.serializers),
@@ -392,7 +392,7 @@ function Kr() {
392
392
  p._stdErrSerialize === void 0 ? !0 : p._stdErrSerialize
393
393
  ), p._logEvent.ts = E, p._logEvent.messages = A.filter(function(w) {
394
394
  return M.indexOf(w) === -1;
395
- }), p._logEvent.level.label = B, p._logEvent.level.value = K, k(B, p._logEvent, O), p._logEvent = L(M);
395
+ }), p._logEvent.level.label = z, p._logEvent.level.value = K, k(z, p._logEvent, O), p._logEvent = L(M);
396
396
  }
397
397
  function L(p) {
398
398
  return {
@@ -468,7 +468,7 @@ function Gr() {
468
468
  }
469
469
  function Vr(e) {
470
470
  const n = Oe(e, "project.pbxproj");
471
- return (Br.open(n).rootObject.props.knownRegions ?? []).filter((o) => o !== "Base").sort();
471
+ return (zr.open(n).rootObject.props.knownRegions ?? []).filter((o) => o !== "Base").sort();
472
472
  }
473
473
  async function Xr(e) {
474
474
  const n = await me(e), r = /* @__PURE__ */ new Set();
@@ -651,10 +651,10 @@ function hi() {
651
651
  arguments[n].forEach(i);
652
652
  return e;
653
653
  }
654
- function Be(e) {
654
+ function ze(e) {
655
655
  return this.extend(e);
656
656
  }
657
- Be.prototype.extend = function(n) {
657
+ ze.prototype.extend = function(n) {
658
658
  var r = [], i = [];
659
659
  if (n instanceof j)
660
660
  i.push(n);
@@ -675,10 +675,10 @@ Be.prototype.extend = function(n) {
675
675
  if (!(o instanceof j))
676
676
  throw new P("Specified list of YAML types (or a single Type object) contains a non-Type object.");
677
677
  });
678
- var t = Object.create(Be.prototype);
678
+ var t = Object.create(ze.prototype);
679
679
  return t.implicit = (this.implicit || []).concat(r), t.explicit = (this.explicit || []).concat(i), t.compiledImplicit = pn(t, "implicit"), t.compiledExplicit = pn(t, "explicit"), t.compiledTypeMap = hi(t.compiledImplicit, t.compiledExplicit), t;
680
680
  };
681
- var Bn = Be, zn = new j("tag:yaml.org,2002:str", {
681
+ var zn = ze, Bn = new j("tag:yaml.org,2002:str", {
682
682
  kind: "scalar",
683
683
  construct: function(e) {
684
684
  return e !== null ? e : "";
@@ -693,9 +693,9 @@ var Bn = Be, zn = new j("tag:yaml.org,2002:str", {
693
693
  construct: function(e) {
694
694
  return e !== null ? e : {};
695
695
  }
696
- }), Hn = new Bn({
696
+ }), Hn = new zn({
697
697
  explicit: [
698
- zn,
698
+ Bn,
699
699
  Un,
700
700
  Yn
701
701
  ]
@@ -977,23 +977,23 @@ function $i(e) {
977
977
  i % 3 === 0 && i && (n += l[r >> 18 & 63], n += l[r >> 12 & 63], n += l[r >> 6 & 63], n += l[r & 63]), r = (r << 8) + e[i];
978
978
  return t = o % 3, t === 0 ? (n += l[r >> 18 & 63], n += l[r >> 12 & 63], n += l[r >> 6 & 63], n += l[r & 63]) : t === 2 ? (n += l[r >> 10 & 63], n += l[r >> 4 & 63], n += l[r << 2 & 63], n += l[64]) : t === 1 && (n += l[r >> 2 & 63], n += l[r << 4 & 63], n += l[64], n += l[64]), n;
979
979
  }
980
- function Bi(e) {
980
+ function zi(e) {
981
981
  return Object.prototype.toString.call(e) === "[object Uint8Array]";
982
982
  }
983
983
  var nr = new j("tag:yaml.org,2002:binary", {
984
984
  kind: "scalar",
985
985
  resolve: Pi,
986
986
  construct: Di,
987
- predicate: Bi,
987
+ predicate: zi,
988
988
  represent: $i
989
- }), zi = Object.prototype.hasOwnProperty, Ui = Object.prototype.toString;
989
+ }), Bi = Object.prototype.hasOwnProperty, Ui = Object.prototype.toString;
990
990
  function Yi(e) {
991
991
  if (e === null) return !0;
992
992
  var n = [], r, i, t, o, l, a = e;
993
993
  for (r = 0, i = a.length; r < i; r += 1) {
994
994
  if (t = a[r], l = !1, Ui.call(t) !== "[object Object]") return !1;
995
995
  for (o in t)
996
- if (zi.call(t, o))
996
+ if (Bi.call(t, o))
997
997
  if (!l) l = !0;
998
998
  else return !1;
999
999
  if (!l) return !1;
@@ -1488,7 +1488,7 @@ function yt(e, n) {
1488
1488
  var vt = mt, xt = yt, hr = {
1489
1489
  loadAll: vt,
1490
1490
  load: xt
1491
- }, gr = Object.prototype.toString, mr = Object.prototype.hasOwnProperty, Qe = 65279, wt = 9, pe = 10, bt = 13, At = 32, Ct = 33, St = 34, ze = 35, kt = 37, Et = 38, _t = 39, Ot = 42, yr = 44, Ft = 45, Ee = 58, Tt = 61, Lt = 62, jt = 63, It = 64, vr = 91, xr = 93, Nt = 96, wr = 123, Rt = 124, br = 125, N = {};
1491
+ }, gr = Object.prototype.toString, mr = Object.prototype.hasOwnProperty, Qe = 65279, wt = 9, pe = 10, bt = 13, At = 32, Ct = 33, St = 34, Be = 35, kt = 37, Et = 38, _t = 39, Ot = 42, yr = 44, Ft = 45, Ee = 58, Tt = 61, Lt = 62, jt = 63, It = 64, vr = 91, xr = 93, Nt = 96, wr = 123, Rt = 124, br = 125, N = {};
1492
1492
  N[0] = "\\0";
1493
1493
  N[7] = "\\a";
1494
1494
  N[8] = "\\b";
@@ -1541,9 +1541,9 @@ function $t(e) {
1541
1541
  throw new P("code point within a string may not be greater than 0xFFFFFFFF");
1542
1542
  return "\\" + r + T.repeat("0", i - n.length) + n;
1543
1543
  }
1544
- var Bt = 1, de = 2;
1545
- function zt(e) {
1546
- this.schema = e.schema || Ge, this.indent = Math.max(1, e.indent || 2), this.noArrayIndent = e.noArrayIndent || !1, this.skipInvalid = e.skipInvalid || !1, this.flowLevel = T.isNothing(e.flowLevel) ? -1 : e.flowLevel, this.styleMap = Dt(this.schema, e.styles || null), this.sortKeys = e.sortKeys || !1, this.lineWidth = e.lineWidth || 80, this.noRefs = e.noRefs || !1, this.noCompatMode = e.noCompatMode || !1, this.condenseFlow = e.condenseFlow || !1, this.quotingType = e.quotingType === '"' ? de : Bt, this.forceQuotes = e.forceQuotes || !1, this.replacer = typeof e.replacer == "function" ? e.replacer : null, this.implicitTypes = this.schema.compiledImplicit, this.explicitTypes = this.schema.compiledExplicit, this.tag = null, this.result = "", this.duplicates = [], this.usedDuplicates = null;
1544
+ var zt = 1, de = 2;
1545
+ function Bt(e) {
1546
+ this.schema = e.schema || Ge, this.indent = Math.max(1, e.indent || 2), this.noArrayIndent = e.noArrayIndent || !1, this.skipInvalid = e.skipInvalid || !1, this.flowLevel = T.isNothing(e.flowLevel) ? -1 : e.flowLevel, this.styleMap = Dt(this.schema, e.styles || null), this.sortKeys = e.sortKeys || !1, this.lineWidth = e.lineWidth || 80, this.noRefs = e.noRefs || !1, this.noCompatMode = e.noCompatMode || !1, this.condenseFlow = e.condenseFlow || !1, this.quotingType = e.quotingType === '"' ? de : zt, this.forceQuotes = e.forceQuotes || !1, this.replacer = typeof e.replacer == "function" ? e.replacer : null, this.implicitTypes = this.schema.compiledImplicit, this.explicitTypes = this.schema.compiledExplicit, this.tag = null, this.result = "", this.duplicates = [], this.usedDuplicates = null;
1547
1547
  }
1548
1548
  function xn(e, n) {
1549
1549
  for (var r = T.repeat(" ", n), i = 0, t = -1, o = "", l, a = e.length; i < a; )
@@ -1579,11 +1579,11 @@ function bn(e, n, r) {
1579
1579
  (r ? (
1580
1580
  // c = flow-in
1581
1581
  i
1582
- ) : i && e !== yr && e !== vr && e !== xr && e !== wr && e !== br) && e !== ze && !(n === Ee && !t) || wn(n) && !_e(n) && e === ze || n === Ee && t
1582
+ ) : i && e !== yr && e !== vr && e !== xr && e !== wr && e !== br) && e !== Be && !(n === Ee && !t) || wn(n) && !_e(n) && e === Be || n === Ee && t
1583
1583
  );
1584
1584
  }
1585
1585
  function Yt(e) {
1586
- return he(e) && e !== Qe && !_e(e) && e !== Ft && e !== jt && e !== Ee && e !== yr && e !== vr && e !== xr && e !== wr && e !== br && e !== ze && e !== Et && e !== Ot && e !== Ct && e !== Rt && e !== Tt && e !== Lt && e !== _t && e !== St && e !== kt && e !== It && e !== Nt;
1586
+ return he(e) && e !== Qe && !_e(e) && e !== Ft && e !== jt && e !== Ee && e !== yr && e !== vr && e !== xr && e !== wr && e !== br && e !== Be && e !== Et && e !== Ot && e !== Ct && e !== Rt && e !== Tt && e !== Lt && e !== _t && e !== St && e !== kt && e !== It && e !== Nt;
1587
1587
  }
1588
1588
  function Ht(e) {
1589
1589
  return !_e(e) && e !== Ee;
@@ -1785,7 +1785,7 @@ function He(e, n, r) {
1785
1785
  }
1786
1786
  function Zt(e, n) {
1787
1787
  n = n || {};
1788
- var r = new zt(n);
1788
+ var r = new Bt(n);
1789
1789
  r.noRefs || Jt(e, r);
1790
1790
  var i = e;
1791
1791
  return r.replacer && (i = r.replacer.call({ "": i }, "", i)), W(r, 0, i, !0, !0) ? r.dump + `
@@ -1799,7 +1799,7 @@ function Je(e, n) {
1799
1799
  throw new Error("Function yaml." + e + " is removed in js-yaml 4. Use yaml." + n + " instead, which is now safe by default.");
1800
1800
  };
1801
1801
  }
1802
- var ro = j, io = Bn, to = Hn, oo = Vn, lo = Xn, ao = Ge, so = hr.load, co = hr.loadAll, uo = no.dump, fo = P, po = {
1802
+ var ro = j, io = zn, to = Hn, oo = Vn, lo = Xn, ao = Ge, so = hr.load, co = hr.loadAll, uo = no.dump, fo = P, po = {
1803
1803
  binary: nr,
1804
1804
  float: Gn,
1805
1805
  map: Yn,
@@ -1812,7 +1812,7 @@ var ro = j, io = Bn, to = Hn, oo = Vn, lo = Xn, ao = Ge, so = hr.load, co = hr.l
1812
1812
  merge: er,
1813
1813
  omap: rr,
1814
1814
  seq: Un,
1815
- str: zn
1815
+ str: Bn
1816
1816
  }, ho = Je("safeLoad", "load"), go = Je("safeLoadAll", "loadAll"), mo = Je("safeDump", "dump"), _n = {
1817
1817
  Type: ro,
1818
1818
  Schema: io,
@@ -2005,7 +2005,11 @@ async function So({
2005
2005
  const g = u?.kind === "single" ? u.translations : void 0, y = u?.kind === "single" ? u.comment : void 0;
2006
2006
  return await On(e, h, r ?? y, g, s, o, l, f), { kind: "single", keys: [h] };
2007
2007
  }
2008
- function ko() {
2008
+ const ko = (e) => {
2009
+ const n = Object.entries(e).sort(([r], [i]) => r.localeCompare(i, "en", { sensitivity: "case" }));
2010
+ return Object.fromEntries(n);
2011
+ };
2012
+ function Eo() {
2009
2013
  return {
2010
2014
  command: "add",
2011
2015
  describe: "Add a string",
@@ -2112,9 +2116,9 @@ async function On(e, n, r, i, t, o, l, a) {
2112
2116
  };
2113
2117
  }
2114
2118
  }
2115
- s.strings[n] = d, await Mn(e, s);
2119
+ s.strings[n] = d, d.localizations && (d.localizations = ko(d.localizations)), await Mn(e, s);
2116
2120
  }
2117
- function Eo() {
2121
+ function _o() {
2118
2122
  return {
2119
2123
  command: "remove",
2120
2124
  describe: "Remove a string",
@@ -2138,7 +2142,7 @@ function Eo() {
2138
2142
  throw new Error("Either --key or --languages must be provided");
2139
2143
  }),
2140
2144
  handler: async (e) => {
2141
- const n = await Oo(
2145
+ const n = await Fo(
2142
2146
  e.path,
2143
2147
  e.key,
2144
2148
  e.languages,
@@ -2155,14 +2159,14 @@ ${r}`));
2155
2159
  }
2156
2160
  };
2157
2161
  }
2158
- function _o(e, n, r, i, t) {
2162
+ function Oo(e, n, r, i, t) {
2159
2163
  if (e.localizations) {
2160
2164
  for (const o of n)
2161
2165
  e.localizations[o] && (t[i] ??= [], t[i].push(o), r || delete e.localizations[o]);
2162
2166
  !r && e.localizations && Object.keys(e.localizations).length === 0 && delete e.localizations;
2163
2167
  }
2164
2168
  }
2165
- async function Oo(e, n, r, i = !1) {
2169
+ async function Fo(e, n, r, i = !1) {
2166
2170
  const t = await me(e), o = {}, l = t.strings || {};
2167
2171
  t.strings = l;
2168
2172
  const a = n ? [n] : Object.keys(l);
@@ -2176,23 +2180,23 @@ async function Oo(e, n, r, i = !1) {
2176
2180
  o[c] = g, i || delete l[c], s = !0;
2177
2181
  continue;
2178
2182
  }
2179
- _o(u, r, i, c, o);
2183
+ Oo(u, r, i, c, o);
2180
2184
  const f = o[c]?.length ?? 0;
2181
2185
  !(u.localizations && Object.keys(u.localizations).length > 0) && f > 0 && (i || delete l[c]), f > 0 && (s = !0);
2182
2186
  }
2183
2187
  return !i && s && await Mn(e, t), o;
2184
2188
  }
2185
2189
  const Me = "xcstrings-cli.json5";
2186
- function Fo() {
2190
+ function To() {
2187
2191
  return {
2188
2192
  command: "init",
2189
2193
  describe: "Initialize configuration file",
2190
2194
  handler: async () => {
2191
- await jo();
2195
+ await Io();
2192
2196
  }
2193
2197
  };
2194
2198
  }
2195
- async function To(e) {
2199
+ async function Lo(e) {
2196
2200
  const n = [];
2197
2201
  async function r(i) {
2198
2202
  try {
@@ -2206,7 +2210,7 @@ async function To(e) {
2206
2210
  }
2207
2211
  return await r(e), n;
2208
2212
  }
2209
- async function Lo(e) {
2213
+ async function jo(e) {
2210
2214
  const n = [];
2211
2215
  let r = e;
2212
2216
  try {
@@ -2217,12 +2221,12 @@ async function Lo(e) {
2217
2221
  }
2218
2222
  return n;
2219
2223
  }
2220
- async function jo() {
2224
+ async function Io() {
2221
2225
  const e = process.cwd();
2222
2226
  console.log(), console.log(S.bold.cyan("🚀 xcstrings-cli Configuration Setup")), console.log(S.dim("─".repeat(40))), console.log(), console.log(S.yellow("🔍 Searching for .xcstrings files..."));
2223
- const n = await To(e);
2227
+ const n = await Lo(e);
2224
2228
  console.log(S.yellow("🔍 Searching for .xcodeproj directories..."));
2225
- const r = await Lo(e);
2229
+ const r = await jo(e);
2226
2230
  console.log();
2227
2231
  let i = [];
2228
2232
  if (n.length > 0) {
@@ -2277,13 +2281,13 @@ ${a}
2277
2281
  `;
2278
2282
  await Nn(Me, s, "utf-8"), console.log(), console.log(S.bold.green(`✓ Created ${Me}`)), console.log(S.dim(` Run ${S.cyan("xcstrings --help")} to see available commands.`)), console.log();
2279
2283
  }
2280
- var Io = Object.prototype.toString, ae = Array.isArray || function(n) {
2281
- return Io.call(n) === "[object Array]";
2284
+ var No = Object.prototype.toString, ae = Array.isArray || function(n) {
2285
+ return No.call(n) === "[object Array]";
2282
2286
  };
2283
2287
  function Ze(e) {
2284
2288
  return typeof e == "function";
2285
2289
  }
2286
- function No(e) {
2290
+ function Ro(e) {
2287
2291
  return ae(e) ? "array" : typeof e;
2288
2292
  }
2289
2293
  function Pe(e) {
@@ -2292,16 +2296,16 @@ function Pe(e) {
2292
2296
  function Fn(e, n) {
2293
2297
  return e != null && typeof e == "object" && n in e;
2294
2298
  }
2295
- function Ro(e, n) {
2299
+ function Mo(e, n) {
2296
2300
  return e != null && typeof e != "object" && e.hasOwnProperty && e.hasOwnProperty(n);
2297
2301
  }
2298
- var Mo = RegExp.prototype.test;
2299
- function Po(e, n) {
2300
- return Mo.call(e, n);
2302
+ var Po = RegExp.prototype.test;
2303
+ function Do(e, n) {
2304
+ return Po.call(e, n);
2301
2305
  }
2302
- var Do = /\S/;
2303
- function $o(e) {
2304
- return !Po(Do, e);
2306
+ var $o = /\S/;
2307
+ function zo(e) {
2308
+ return !Do($o, e);
2305
2309
  }
2306
2310
  var Bo = {
2307
2311
  "&": "&amp;",
@@ -2313,13 +2317,13 @@ var Bo = {
2313
2317
  "`": "&#x60;",
2314
2318
  "=": "&#x3D;"
2315
2319
  };
2316
- function zo(e) {
2320
+ function Uo(e) {
2317
2321
  return String(e).replace(/[&<>"'`=\/]/g, function(r) {
2318
2322
  return Bo[r];
2319
2323
  });
2320
2324
  }
2321
- var Uo = /\s*/, Yo = /\s+/, Tn = /\s*=/, Ho = /\s*\}/, Ko = /#|\^|\/|>|\{|&|=|!/;
2322
- function Wo(e, n) {
2325
+ var Yo = /\s*/, Ho = /\s+/, Tn = /\s*=/, Ko = /\s*\}/, Wo = /#|\^|\/|>|\{|&|=|!/;
2326
+ function qo(e, n) {
2323
2327
  if (!e)
2324
2328
  return [];
2325
2329
  var r = !1, i = [], t = [], o = [], l = !1, a = !1, s = "", c = 0;
@@ -2333,7 +2337,7 @@ function Wo(e, n) {
2333
2337
  }
2334
2338
  var f, h, g;
2335
2339
  function y(I) {
2336
- if (typeof I == "string" && (I = I.split(Yo, 2)), !ae(I) || I.length !== 2)
2340
+ if (typeof I == "string" && (I = I.split(Ho, 2)), !ae(I) || I.length !== 2)
2337
2341
  throw new Error("Invalid tags: " + I);
2338
2342
  f = new RegExp(Pe(I[0]) + "\\s*"), h = new RegExp("\\s*" + Pe(I[1])), g = new RegExp("\\s*" + Pe("}" + I[1]));
2339
2343
  }
@@ -2341,11 +2345,11 @@ function Wo(e, n) {
2341
2345
  for (var d = new ye(e), b, C, x, _, L, R; !d.eos(); ) {
2342
2346
  if (b = d.pos, x = d.scanUntil(f), x)
2343
2347
  for (var J = 0, V = x.length; J < V; ++J)
2344
- _ = x.charAt(J), $o(_) ? (o.push(t.length), s += _) : (a = !0, r = !0, s += " "), t.push(["text", _, b, b + 1]), b += 1, _ === `
2348
+ _ = x.charAt(J), zo(_) ? (o.push(t.length), s += _) : (a = !0, r = !0, s += " "), t.push(["text", _, b, b + 1]), b += 1, _ === `
2345
2349
  ` && (u(), s = "", c = 0, r = !1);
2346
2350
  if (!d.scan(f))
2347
2351
  break;
2348
- if (l = !0, C = d.scan(Ko) || "name", d.scan(Uo), C === "=" ? (x = d.scanUntil(Tn), d.scan(Tn), d.scanUntil(h)) : C === "{" ? (x = d.scanUntil(g), d.scan(Ho), d.scanUntil(h), C = "&") : x = d.scanUntil(h), !d.scan(h))
2352
+ if (l = !0, C = d.scan(Wo) || "name", d.scan(Yo), C === "=" ? (x = d.scanUntil(Tn), d.scan(Tn), d.scanUntil(h)) : C === "{" ? (x = d.scanUntil(g), d.scan(Ko), d.scanUntil(h), C = "&") : x = d.scanUntil(h), !d.scan(h))
2349
2353
  throw new Error("Unclosed tag at " + d.pos);
2350
2354
  if (C == ">" ? L = [C, x, b, d.pos, s, c, r] : L = [C, x, b, d.pos], c++, t.push(L), C === "#" || C === "^")
2351
2355
  i.push(L);
@@ -2358,14 +2362,14 @@ function Wo(e, n) {
2358
2362
  }
2359
2363
  if (u(), R = i.pop(), R)
2360
2364
  throw new Error('Unclosed section "' + R[1] + '" at ' + d.pos);
2361
- return Go(qo(t));
2365
+ return Vo(Go(t));
2362
2366
  }
2363
- function qo(e) {
2367
+ function Go(e) {
2364
2368
  for (var n = [], r, i, t = 0, o = e.length; t < o; ++t)
2365
2369
  r = e[t], r && (r[0] === "text" && i && i[0] === "text" ? (i[1] += r[1], i[3] = r[3]) : (n.push(r), i = r));
2366
2370
  return n;
2367
2371
  }
2368
- function Go(e) {
2372
+ function Vo(e) {
2369
2373
  for (var n = [], r = n, i = [], t, o, l = 0, a = e.length; l < a; ++l)
2370
2374
  switch (t = e[l], t[0]) {
2371
2375
  case "#":
@@ -2421,7 +2425,7 @@ le.prototype.lookup = function(n) {
2421
2425
  for (var t = this, o, l, a, s = !1; t; ) {
2422
2426
  if (n.indexOf(".") > 0)
2423
2427
  for (o = t.view, l = n.split("."), a = 0; o != null && a < l.length; )
2424
- a === l.length - 1 && (s = Fn(o, l[a]) || Ro(o, l[a])), o = o[l[a++]];
2428
+ a === l.length - 1 && (s = Fn(o, l[a]) || Mo(o, l[a])), o = o[l[a++]];
2425
2429
  else
2426
2430
  o = t.view[n], s = Fn(t.view, n);
2427
2431
  if (s) {
@@ -2453,7 +2457,7 @@ $.prototype.clearCache = function() {
2453
2457
  };
2454
2458
  $.prototype.parse = function(n, r) {
2455
2459
  var i = this.templateCache, t = n + ":" + (r || D.tags).join(":"), o = typeof i < "u", l = o ? i.get(t) : void 0;
2456
- return l == null && (l = Wo(n, r), o && i.set(t, l)), l;
2460
+ return l == null && (l = qo(n, r), o && i.set(t, l)), l;
2457
2461
  };
2458
2462
  $.prototype.render = function(n, r, i, t) {
2459
2463
  var o = this.getConfigTags(t), l = this.parse(n, o), a = r instanceof le ? r : new le(r, void 0);
@@ -2561,10 +2565,10 @@ D.parse = function(n, r) {
2561
2565
  };
2562
2566
  D.render = function(n, r, i, t) {
2563
2567
  if (typeof n != "string")
2564
- throw new TypeError('Invalid template! Template should be a "string" but "' + No(n) + '" was given as the first argument for mustache#render(template, view, partials)');
2568
+ throw new TypeError('Invalid template! Template should be a "string" but "' + Ro(n) + '" was given as the first argument for mustache#render(template, view, partials)');
2565
2569
  return ge.render(n, r, i, t);
2566
2570
  };
2567
- D.escape = zo;
2571
+ D.escape = Uo;
2568
2572
  D.Scanner = ye;
2569
2573
  D.Context = le;
2570
2574
  D.Writer = $;
@@ -2580,7 +2584,7 @@ function Ln(e, {
2580
2584
  return r !== void 0 ? { pattern: r, mode: "regex" } : i !== void 0 ? { pattern: i, mode: "substring" } : { pattern: n, mode: "glob" };
2581
2585
  }
2582
2586
  }
2583
- function Vo() {
2587
+ function Xo() {
2584
2588
  return {
2585
2589
  command: "strings",
2586
2590
  describe: "List strings in the xcstrings file",
@@ -2638,7 +2642,7 @@ function Vo() {
2638
2642
  glob: r[0],
2639
2643
  regex: e["text-regex"],
2640
2644
  substring: e["text-substring"]
2641
- }), o = await Jo({
2645
+ }), o = await Zo({
2642
2646
  path: e.path,
2643
2647
  languages: e.languages,
2644
2648
  missingLanguages: e["missing-languages"],
@@ -2650,7 +2654,7 @@ function Vo() {
2650
2654
  }
2651
2655
  };
2652
2656
  }
2653
- function Xo(e) {
2657
+ function Qo(e) {
2654
2658
  const n = e.replace(/[.+^${}()|\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
2655
2659
  return new RegExp(`^${n}$`);
2656
2660
  }
@@ -2664,10 +2668,10 @@ function jn(e) {
2664
2668
  const r = e.pattern;
2665
2669
  return (i) => i.includes(r);
2666
2670
  }
2667
- const n = Xo(e.pattern);
2671
+ const n = Qo(e.pattern);
2668
2672
  return (r) => n.test(r);
2669
2673
  }
2670
- function Qo(e, n) {
2674
+ function Jo(e, n) {
2671
2675
  const r = D.escape;
2672
2676
  D.escape = (i) => i;
2673
2677
  try {
@@ -2676,7 +2680,7 @@ function Qo(e, n) {
2676
2680
  D.escape = r;
2677
2681
  }
2678
2682
  }
2679
- async function Jo(e) {
2683
+ async function Zo(e) {
2680
2684
  const r = (await me(e.path)).strings ?? {}, i = jn(e.keyFilter), t = jn(e.textFilter), o = e.languages ? new Set(e.languages) : null, l = e.missingLanguages ? new Set(e.missingLanguages) : null, a = !!e.format, s = [];
2681
2685
  for (const c of Object.keys(r)) {
2682
2686
  if (!i(c)) continue;
@@ -2684,7 +2688,7 @@ async function Jo(e) {
2684
2688
  for (const d of h) {
2685
2689
  if (o && !o.has(d)) continue;
2686
2690
  const b = f[d]?.stringUnit?.value ?? "";
2687
- t(b) && (a && e.format ? y.push(Qo(e.format, { language: d, key: c, text: b })) : y.push(` ${d}: ${JSON.stringify(b)}`));
2691
+ t(b) && (a && e.format ? y.push(Jo(e.format, { language: d, key: c, text: b })) : y.push(` ${d}: ${JSON.stringify(b)}`));
2688
2692
  }
2689
2693
  y.length !== 0 && g && (a ? s.push(...y) : s.push(`${c}:`, ...y));
2690
2694
  }
@@ -2701,13 +2705,13 @@ Nr(Rr(process.argv)).scriptName("xcstrings").usage("$0 <cmd> [args]").option("co
2701
2705
  default: In
2702
2706
  }).middleware(async (e) => {
2703
2707
  const n = await We(e.config);
2704
- e.path = await zr(e.path, n, In);
2708
+ e.path = await Br(e.path, n, In);
2705
2709
  }).command([
2706
- ko(),
2707
2710
  Eo(),
2708
- Fo(),
2711
+ _o(),
2712
+ To(),
2709
2713
  Gr(),
2710
- Vo()
2714
+ Xo()
2711
2715
  ]).demandCommand(1, "").strictCommands().recommendCommands().showHelpOnFail(!0).fail((e, n, r) => {
2712
2716
  const i = e || n?.message;
2713
2717
  i && (console.error(S.red(i)), console.log(), r.showHelp(), process.exit(1)), n && (console.error(n), process.exit(1)), r.showHelp(), process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xcstrings-cli",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "A command line tool for handling xcstrings files.",
5
5
  "type": "module",
6
6
  "bin": {