@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/browser.cjs CHANGED
@@ -8819,6 +8819,25 @@ function restoreCaretScopes(input, scopes) {
8819
8819
  (_m, n) => scopes[Number(n)] ?? ""
8820
8820
  );
8821
8821
  }
8822
+ var VIEW_TAIL_OPEN = "\uE002";
8823
+ var VIEW_TAIL_CLOSE = "\uE003";
8824
+ var VIEW_TAIL_RE = /\busing\s+view\b(?:\s+(?!then\b)[A-Za-z][\w-]*)?/gi;
8825
+ var VIEW_TAIL_TOKEN_RE = new RegExp(`^${VIEW_TAIL_OPEN}(\\d+)${VIEW_TAIL_CLOSE}$`);
8826
+ function maskViewTransitionTails(input) {
8827
+ const tails = [];
8828
+ const masked = input.replace(VIEW_TAIL_RE, (match) => {
8829
+ const idx = tails.length;
8830
+ tails.push(match);
8831
+ return `${VIEW_TAIL_OPEN}${idx}${VIEW_TAIL_CLOSE}`;
8832
+ });
8833
+ return tails.length > 0 ? { masked, tails } : null;
8834
+ }
8835
+ function restoreViewTransitionTails(input, tails) {
8836
+ return input.replace(
8837
+ new RegExp(`${VIEW_TAIL_OPEN}(\\d+)${VIEW_TAIL_CLOSE}`, "g"),
8838
+ (_m, n) => tails[Number(n)] ?? ""
8839
+ );
8840
+ }
8822
8841
  var GrammarTransformer = class {
8823
8842
  constructor(sourceLocale = "en", targetLocale) {
8824
8843
  const source = getProfile(sourceLocale);
@@ -8840,6 +8859,10 @@ var GrammarTransformer = class {
8840
8859
  return this.targetProfile.code === "he" ? repairHebrewFrontedAccusative(out) : out;
8841
8860
  }
8842
8861
  transformInternal(input) {
8862
+ const viewTails = maskViewTransitionTails(input);
8863
+ if (viewTails) {
8864
+ return restoreViewTransitionTails(this.transformInternal(viewTails.masked), viewTails.tails);
8865
+ }
8843
8866
  const caret = maskCaretScopes(input);
8844
8867
  if (caret) {
8845
8868
  return restoreCaretScopes(this.transform(caret.masked), caret.scopes);
@@ -8892,6 +8915,10 @@ var GrammarTransformer = class {
8892
8915
  if (setScope !== null) {
8893
8916
  return setScope;
8894
8917
  }
8918
+ const viewTail = this.transformWithViewTransitionTail(input);
8919
+ if (viewTail !== null) {
8920
+ return viewTail;
8921
+ }
8895
8922
  const parsed = parseStatement(input, this.sourceProfile.code);
8896
8923
  if (!parsed) {
8897
8924
  return input;
@@ -8915,6 +8942,35 @@ var GrammarTransformer = class {
8915
8942
  }
8916
8943
  return joinTokens(reordered.map((e) => e.translated || e.value));
8917
8944
  }
8945
+ /**
8946
+ * Clause carrying a masked `using view transition` tail: strip the opaque
8947
+ * token, transform the clause alone, and re-append the token at the very end.
8948
+ *
8949
+ * The tail is a clause-final modifier in every word order the corpus emits:
8950
+ * the semantic side matches it as the literal `using view` marker plus a value
8951
+ * word, and the SOV/VSO event-handler patterns admit it as an optional
8952
+ * TRAILING group (after the with-marked operand). So the target position is
8953
+ * "end of the transformed clause" for all 24 languages — no per-profile
8954
+ * placement decision, which is what makes this a passthrough rather than a
8955
+ * role.
8956
+ *
8957
+ * Returns null when the clause carries no masked tail, or when the token is
8958
+ * not clause-final (nothing to reposition — leaving it in place still restores
8959
+ * verbatim English).
8960
+ */
8961
+ transformWithViewTransitionTail(input) {
8962
+ const trimmed = input.trim();
8963
+ const tokens = trimmed.split(/\s+/);
8964
+ if (tokens.length < 2) {
8965
+ return null;
8966
+ }
8967
+ if (!VIEW_TAIL_TOKEN_RE.test(tokens[tokens.length - 1])) {
8968
+ return null;
8969
+ }
8970
+ const tail = tokens[tokens.length - 1];
8971
+ const head = tokens.slice(0, -1).join(" ");
8972
+ return `${this.transformSingle(head)} ${tail}`;
8973
+ }
8918
8974
  /**
8919
8975
  * `<command …> end` fragments: transform the command without its stranded
8920
8976
  * terminator, then re-append the translated terminator as a standalone