@lokascript/i18n 2.9.4 → 2.11.0

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/dist/index.cjs CHANGED
@@ -15337,6 +15337,25 @@ function restoreCaretScopes(input, scopes) {
15337
15337
  (_m, n) => scopes[Number(n)] ?? ""
15338
15338
  );
15339
15339
  }
15340
+ var VIEW_TAIL_OPEN = "\uE002";
15341
+ var VIEW_TAIL_CLOSE = "\uE003";
15342
+ var VIEW_TAIL_RE = /\busing\s+view\b(?:\s+(?!then\b)[A-Za-z][\w-]*)?/gi;
15343
+ var VIEW_TAIL_TOKEN_RE = new RegExp(`^${VIEW_TAIL_OPEN}(\\d+)${VIEW_TAIL_CLOSE}$`);
15344
+ function maskViewTransitionTails(input) {
15345
+ const tails = [];
15346
+ const masked = input.replace(VIEW_TAIL_RE, (match) => {
15347
+ const idx = tails.length;
15348
+ tails.push(match);
15349
+ return `${VIEW_TAIL_OPEN}${idx}${VIEW_TAIL_CLOSE}`;
15350
+ });
15351
+ return tails.length > 0 ? { masked, tails } : null;
15352
+ }
15353
+ function restoreViewTransitionTails(input, tails) {
15354
+ return input.replace(
15355
+ new RegExp(`${VIEW_TAIL_OPEN}(\\d+)${VIEW_TAIL_CLOSE}`, "g"),
15356
+ (_m, n) => tails[Number(n)] ?? ""
15357
+ );
15358
+ }
15340
15359
  var GrammarTransformer = class {
15341
15360
  constructor(sourceLocale = "en", targetLocale) {
15342
15361
  const source = getProfile(sourceLocale);
@@ -15358,6 +15377,10 @@ var GrammarTransformer = class {
15358
15377
  return this.targetProfile.code === "he" ? repairHebrewFrontedAccusative(out) : out;
15359
15378
  }
15360
15379
  transformInternal(input) {
15380
+ const viewTails = maskViewTransitionTails(input);
15381
+ if (viewTails) {
15382
+ return restoreViewTransitionTails(this.transformInternal(viewTails.masked), viewTails.tails);
15383
+ }
15361
15384
  const caret = maskCaretScopes(input);
15362
15385
  if (caret) {
15363
15386
  return restoreCaretScopes(this.transform(caret.masked), caret.scopes);
@@ -15410,6 +15433,10 @@ var GrammarTransformer = class {
15410
15433
  if (setScope !== null) {
15411
15434
  return setScope;
15412
15435
  }
15436
+ const viewTail = this.transformWithViewTransitionTail(input);
15437
+ if (viewTail !== null) {
15438
+ return viewTail;
15439
+ }
15413
15440
  const parsed = parseStatement(input, this.sourceProfile.code);
15414
15441
  if (!parsed) {
15415
15442
  return input;
@@ -15433,6 +15460,35 @@ var GrammarTransformer = class {
15433
15460
  }
15434
15461
  return joinTokens(reordered.map((e) => e.translated || e.value));
15435
15462
  }
15463
+ /**
15464
+ * Clause carrying a masked `using view transition` tail: strip the opaque
15465
+ * token, transform the clause alone, and re-append the token at the very end.
15466
+ *
15467
+ * The tail is a clause-final modifier in every word order the corpus emits:
15468
+ * the semantic side matches it as the literal `using view` marker plus a value
15469
+ * word, and the SOV/VSO event-handler patterns admit it as an optional
15470
+ * TRAILING group (after the with-marked operand). So the target position is
15471
+ * "end of the transformed clause" for all 24 languages — no per-profile
15472
+ * placement decision, which is what makes this a passthrough rather than a
15473
+ * role.
15474
+ *
15475
+ * Returns null when the clause carries no masked tail, or when the token is
15476
+ * not clause-final (nothing to reposition — leaving it in place still restores
15477
+ * verbatim English).
15478
+ */
15479
+ transformWithViewTransitionTail(input) {
15480
+ const trimmed = input.trim();
15481
+ const tokens = trimmed.split(/\s+/);
15482
+ if (tokens.length < 2) {
15483
+ return null;
15484
+ }
15485
+ if (!VIEW_TAIL_TOKEN_RE.test(tokens[tokens.length - 1])) {
15486
+ return null;
15487
+ }
15488
+ const tail = tokens[tokens.length - 1];
15489
+ const head = tokens.slice(0, -1).join(" ");
15490
+ return `${this.transformSingle(head)} ${tail}`;
15491
+ }
15436
15492
  /**
15437
15493
  * `<command …> end` fragments: transform the command without its stranded
15438
15494
  * terminator, then re-append the translated terminator as a standalone