@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 +56 -0
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +56 -0
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +56 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -1
- package/dist/lokascript-i18n.min.js +1 -1
- package/dist/lokascript-i18n.min.js.map +1 -1
- package/dist/lokascript-i18n.mjs +94 -0
- package/dist/lokascript-i18n.mjs.map +1 -1
- package/dist/{transformer--W46PGaW.d.cts → transformer-CsOeqayN.d.cts} +18 -1
- package/dist/{transformer-FU06J6kG.d.ts → transformer-DWCTG1DQ.d.ts} +18 -1
- package/package.json +3 -3
- package/src/grammar/grammar.test.ts +87 -0
- package/src/grammar/transformer.ts +106 -0
- package/src/grammar/types.ts +4 -0
package/dist/browser.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as KeywordProvider } from './transformer
|
|
2
|
-
export { A as AdpositionType, E as ENGLISH_COMMANDS, a as ENGLISH_KEYWORDS, G as GrammarRule, b as GrammarTransformer, c as GrammaticalMarker, d as KeywordProviderOptions, L as LANGUAGE_FAMILY_DEFAULTS, e as LanguageProfile, f as LocaleManager, M as MorphologyType, P as ParsedElement, g as ParsedStatement, h as PatternMatcher, i as PatternTransform, S as SemanticRole, U as UNIVERSAL_ENGLISH_KEYWORDS, j as UNIVERSAL_PATTERNS, W as WordOrder, k as ar, k as arDictionary, l as arKeywords, m as arabicProfile, n as bn, n as bnDictionary, o as bnKeywords, p as chineseProfile, q as createEnglishProvider, r as createKeywordProvider, s as de, s as deDictionary, t as deKeywords, u as detectBrowserLocale, v as englishProfile, w as es, w as esDictionary, x as esKeywords, y as fr, y as frDictionary, z as frKeywords, B as frenchProfile, C as germanProfile, D as getProfile, F as getSupportedLocales, H as grammarExamples, I as hebrewProfile, J as hiDictionary, N as hiKeywords, J as hindiDictionary, O as id, O as idDictionary, Q as idKeywords, R as indonesianProfile, T as insertMarkers, V as it, V as itDictionary, X as itKeywords, Y as ja, Y as jaDictionary, Z as jaKeywords, _ as japaneseProfile, $ as joinTokens, a0 as ko, a0 as koDictionary, a1 as koKeywords, a2 as koreanProfile, a3 as malayProfile, a4 as ms, a4 as msDictionary, a5 as msKeywords, a6 as parseStatement, a7 as pl, a7 as plDictionary, a8 as plKeywords, a9 as portugueseProfile, aa as profiles, ab as pt, ab as ptDictionary, ac as ptKeywords, ad as qu, ad as quDictionary, ae as quKeywords, af as quechuaProfile, ag as reorderRoles, ah as ruDictionary, ai as ruKeywords, ah as russianDictionary, aj as spanishProfile, ak as sw, ak as swDictionary, al as swKeywords, am as swahiliProfile, an as th, an as thDictionary, ao as thKeywords, ap as tl, ap as tlDictionary, aq as tlKeywords, ar as toEnglish, as as toLocale, at as tr, at as trDictionary, au as trKeywords, av as transformStatement, aw as translate, ax as turkishProfile, ay as ukDictionary, az as ukKeywords, ay as ukrainianDictionary, aA as vi, aA as viDictionary, aB as viKeywords, aC as zh, aC as zhDictionary, aD as zhKeywords } from './transformer
|
|
1
|
+
import { K as KeywordProvider } from './transformer-CsOeqayN.cjs';
|
|
2
|
+
export { A as AdpositionType, E as ENGLISH_COMMANDS, a as ENGLISH_KEYWORDS, G as GrammarRule, b as GrammarTransformer, c as GrammaticalMarker, d as KeywordProviderOptions, L as LANGUAGE_FAMILY_DEFAULTS, e as LanguageProfile, f as LocaleManager, M as MorphologyType, P as ParsedElement, g as ParsedStatement, h as PatternMatcher, i as PatternTransform, S as SemanticRole, U as UNIVERSAL_ENGLISH_KEYWORDS, j as UNIVERSAL_PATTERNS, W as WordOrder, k as ar, k as arDictionary, l as arKeywords, m as arabicProfile, n as bn, n as bnDictionary, o as bnKeywords, p as chineseProfile, q as createEnglishProvider, r as createKeywordProvider, s as de, s as deDictionary, t as deKeywords, u as detectBrowserLocale, v as englishProfile, w as es, w as esDictionary, x as esKeywords, y as fr, y as frDictionary, z as frKeywords, B as frenchProfile, C as germanProfile, D as getProfile, F as getSupportedLocales, H as grammarExamples, I as hebrewProfile, J as hiDictionary, N as hiKeywords, J as hindiDictionary, O as id, O as idDictionary, Q as idKeywords, R as indonesianProfile, T as insertMarkers, V as it, V as itDictionary, X as itKeywords, Y as ja, Y as jaDictionary, Z as jaKeywords, _ as japaneseProfile, $ as joinTokens, a0 as ko, a0 as koDictionary, a1 as koKeywords, a2 as koreanProfile, a3 as malayProfile, a4 as ms, a4 as msDictionary, a5 as msKeywords, a6 as parseStatement, a7 as pl, a7 as plDictionary, a8 as plKeywords, a9 as portugueseProfile, aa as profiles, ab as pt, ab as ptDictionary, ac as ptKeywords, ad as qu, ad as quDictionary, ae as quKeywords, af as quechuaProfile, ag as reorderRoles, ah as ruDictionary, ai as ruKeywords, ah as russianDictionary, aj as spanishProfile, ak as sw, ak as swDictionary, al as swKeywords, am as swahiliProfile, an as th, an as thDictionary, ao as thKeywords, ap as tl, ap as tlDictionary, aq as tlKeywords, ar as toEnglish, as as toLocale, at as tr, at as trDictionary, au as trKeywords, av as transformStatement, aw as translate, ax as turkishProfile, ay as ukDictionary, az as ukKeywords, ay as ukrainianDictionary, aA as vi, aA as viDictionary, aB as viKeywords, aC as zh, aC as zhDictionary, aD as zhKeywords } from './transformer-CsOeqayN.cjs';
|
|
3
3
|
import { D as Dictionary } from './types-BYtpqGq3.cjs';
|
|
4
4
|
|
|
5
5
|
declare const he: Dictionary;
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as KeywordProvider } from './transformer-
|
|
2
|
-
export { A as AdpositionType, E as ENGLISH_COMMANDS, a as ENGLISH_KEYWORDS, G as GrammarRule, b as GrammarTransformer, c as GrammaticalMarker, d as KeywordProviderOptions, L as LANGUAGE_FAMILY_DEFAULTS, e as LanguageProfile, f as LocaleManager, M as MorphologyType, P as ParsedElement, g as ParsedStatement, h as PatternMatcher, i as PatternTransform, S as SemanticRole, U as UNIVERSAL_ENGLISH_KEYWORDS, j as UNIVERSAL_PATTERNS, W as WordOrder, k as ar, k as arDictionary, l as arKeywords, m as arabicProfile, n as bn, n as bnDictionary, o as bnKeywords, p as chineseProfile, q as createEnglishProvider, r as createKeywordProvider, s as de, s as deDictionary, t as deKeywords, u as detectBrowserLocale, v as englishProfile, w as es, w as esDictionary, x as esKeywords, y as fr, y as frDictionary, z as frKeywords, B as frenchProfile, C as germanProfile, D as getProfile, F as getSupportedLocales, H as grammarExamples, I as hebrewProfile, J as hiDictionary, N as hiKeywords, J as hindiDictionary, O as id, O as idDictionary, Q as idKeywords, R as indonesianProfile, T as insertMarkers, V as it, V as itDictionary, X as itKeywords, Y as ja, Y as jaDictionary, Z as jaKeywords, _ as japaneseProfile, $ as joinTokens, a0 as ko, a0 as koDictionary, a1 as koKeywords, a2 as koreanProfile, a3 as malayProfile, a4 as ms, a4 as msDictionary, a5 as msKeywords, a6 as parseStatement, a7 as pl, a7 as plDictionary, a8 as plKeywords, a9 as portugueseProfile, aa as profiles, ab as pt, ab as ptDictionary, ac as ptKeywords, ad as qu, ad as quDictionary, ae as quKeywords, af as quechuaProfile, ag as reorderRoles, ah as ruDictionary, ai as ruKeywords, ah as russianDictionary, aj as spanishProfile, ak as sw, ak as swDictionary, al as swKeywords, am as swahiliProfile, an as th, an as thDictionary, ao as thKeywords, ap as tl, ap as tlDictionary, aq as tlKeywords, ar as toEnglish, as as toLocale, at as tr, at as trDictionary, au as trKeywords, av as transformStatement, aw as translate, ax as turkishProfile, ay as ukDictionary, az as ukKeywords, ay as ukrainianDictionary, aA as vi, aA as viDictionary, aB as viKeywords, aC as zh, aC as zhDictionary, aD as zhKeywords } from './transformer-
|
|
1
|
+
import { K as KeywordProvider } from './transformer-DWCTG1DQ.js';
|
|
2
|
+
export { A as AdpositionType, E as ENGLISH_COMMANDS, a as ENGLISH_KEYWORDS, G as GrammarRule, b as GrammarTransformer, c as GrammaticalMarker, d as KeywordProviderOptions, L as LANGUAGE_FAMILY_DEFAULTS, e as LanguageProfile, f as LocaleManager, M as MorphologyType, P as ParsedElement, g as ParsedStatement, h as PatternMatcher, i as PatternTransform, S as SemanticRole, U as UNIVERSAL_ENGLISH_KEYWORDS, j as UNIVERSAL_PATTERNS, W as WordOrder, k as ar, k as arDictionary, l as arKeywords, m as arabicProfile, n as bn, n as bnDictionary, o as bnKeywords, p as chineseProfile, q as createEnglishProvider, r as createKeywordProvider, s as de, s as deDictionary, t as deKeywords, u as detectBrowserLocale, v as englishProfile, w as es, w as esDictionary, x as esKeywords, y as fr, y as frDictionary, z as frKeywords, B as frenchProfile, C as germanProfile, D as getProfile, F as getSupportedLocales, H as grammarExamples, I as hebrewProfile, J as hiDictionary, N as hiKeywords, J as hindiDictionary, O as id, O as idDictionary, Q as idKeywords, R as indonesianProfile, T as insertMarkers, V as it, V as itDictionary, X as itKeywords, Y as ja, Y as jaDictionary, Z as jaKeywords, _ as japaneseProfile, $ as joinTokens, a0 as ko, a0 as koDictionary, a1 as koKeywords, a2 as koreanProfile, a3 as malayProfile, a4 as ms, a4 as msDictionary, a5 as msKeywords, a6 as parseStatement, a7 as pl, a7 as plDictionary, a8 as plKeywords, a9 as portugueseProfile, aa as profiles, ab as pt, ab as ptDictionary, ac as ptKeywords, ad as qu, ad as quDictionary, ae as quKeywords, af as quechuaProfile, ag as reorderRoles, ah as ruDictionary, ai as ruKeywords, ah as russianDictionary, aj as spanishProfile, ak as sw, ak as swDictionary, al as swKeywords, am as swahiliProfile, an as th, an as thDictionary, ao as thKeywords, ap as tl, ap as tlDictionary, aq as tlKeywords, ar as toEnglish, as as toLocale, at as tr, at as trDictionary, au as trKeywords, av as transformStatement, aw as translate, ax as turkishProfile, ay as ukDictionary, az as ukKeywords, ay as ukrainianDictionary, aA as vi, aA as viDictionary, aB as viKeywords, aC as zh, aC as zhDictionary, aD as zhKeywords } from './transformer-DWCTG1DQ.js';
|
|
3
3
|
import { D as Dictionary } from './types-BYtpqGq3.js';
|
|
4
4
|
|
|
5
5
|
declare const he: Dictionary;
|
package/dist/browser.js
CHANGED
|
@@ -8817,6 +8817,25 @@ function restoreCaretScopes(input, scopes) {
|
|
|
8817
8817
|
(_m, n) => scopes[Number(n)] ?? ""
|
|
8818
8818
|
);
|
|
8819
8819
|
}
|
|
8820
|
+
var VIEW_TAIL_OPEN = "\uE002";
|
|
8821
|
+
var VIEW_TAIL_CLOSE = "\uE003";
|
|
8822
|
+
var VIEW_TAIL_RE = /\busing\s+view\b(?:\s+(?!then\b)[A-Za-z][\w-]*)?/gi;
|
|
8823
|
+
var VIEW_TAIL_TOKEN_RE = new RegExp(`^${VIEW_TAIL_OPEN}(\\d+)${VIEW_TAIL_CLOSE}$`);
|
|
8824
|
+
function maskViewTransitionTails(input) {
|
|
8825
|
+
const tails = [];
|
|
8826
|
+
const masked = input.replace(VIEW_TAIL_RE, (match) => {
|
|
8827
|
+
const idx = tails.length;
|
|
8828
|
+
tails.push(match);
|
|
8829
|
+
return `${VIEW_TAIL_OPEN}${idx}${VIEW_TAIL_CLOSE}`;
|
|
8830
|
+
});
|
|
8831
|
+
return tails.length > 0 ? { masked, tails } : null;
|
|
8832
|
+
}
|
|
8833
|
+
function restoreViewTransitionTails(input, tails) {
|
|
8834
|
+
return input.replace(
|
|
8835
|
+
new RegExp(`${VIEW_TAIL_OPEN}(\\d+)${VIEW_TAIL_CLOSE}`, "g"),
|
|
8836
|
+
(_m, n) => tails[Number(n)] ?? ""
|
|
8837
|
+
);
|
|
8838
|
+
}
|
|
8820
8839
|
var GrammarTransformer = class {
|
|
8821
8840
|
constructor(sourceLocale = "en", targetLocale) {
|
|
8822
8841
|
const source = getProfile(sourceLocale);
|
|
@@ -8838,6 +8857,10 @@ var GrammarTransformer = class {
|
|
|
8838
8857
|
return this.targetProfile.code === "he" ? repairHebrewFrontedAccusative(out) : out;
|
|
8839
8858
|
}
|
|
8840
8859
|
transformInternal(input) {
|
|
8860
|
+
const viewTails = maskViewTransitionTails(input);
|
|
8861
|
+
if (viewTails) {
|
|
8862
|
+
return restoreViewTransitionTails(this.transformInternal(viewTails.masked), viewTails.tails);
|
|
8863
|
+
}
|
|
8841
8864
|
const caret = maskCaretScopes(input);
|
|
8842
8865
|
if (caret) {
|
|
8843
8866
|
return restoreCaretScopes(this.transform(caret.masked), caret.scopes);
|
|
@@ -8890,6 +8913,10 @@ var GrammarTransformer = class {
|
|
|
8890
8913
|
if (setScope !== null) {
|
|
8891
8914
|
return setScope;
|
|
8892
8915
|
}
|
|
8916
|
+
const viewTail = this.transformWithViewTransitionTail(input);
|
|
8917
|
+
if (viewTail !== null) {
|
|
8918
|
+
return viewTail;
|
|
8919
|
+
}
|
|
8893
8920
|
const parsed = parseStatement(input, this.sourceProfile.code);
|
|
8894
8921
|
if (!parsed) {
|
|
8895
8922
|
return input;
|
|
@@ -8913,6 +8940,35 @@ var GrammarTransformer = class {
|
|
|
8913
8940
|
}
|
|
8914
8941
|
return joinTokens(reordered.map((e) => e.translated || e.value));
|
|
8915
8942
|
}
|
|
8943
|
+
/**
|
|
8944
|
+
* Clause carrying a masked `using view transition` tail: strip the opaque
|
|
8945
|
+
* token, transform the clause alone, and re-append the token at the very end.
|
|
8946
|
+
*
|
|
8947
|
+
* The tail is a clause-final modifier in every word order the corpus emits:
|
|
8948
|
+
* the semantic side matches it as the literal `using view` marker plus a value
|
|
8949
|
+
* word, and the SOV/VSO event-handler patterns admit it as an optional
|
|
8950
|
+
* TRAILING group (after the with-marked operand). So the target position is
|
|
8951
|
+
* "end of the transformed clause" for all 24 languages — no per-profile
|
|
8952
|
+
* placement decision, which is what makes this a passthrough rather than a
|
|
8953
|
+
* role.
|
|
8954
|
+
*
|
|
8955
|
+
* Returns null when the clause carries no masked tail, or when the token is
|
|
8956
|
+
* not clause-final (nothing to reposition — leaving it in place still restores
|
|
8957
|
+
* verbatim English).
|
|
8958
|
+
*/
|
|
8959
|
+
transformWithViewTransitionTail(input) {
|
|
8960
|
+
const trimmed = input.trim();
|
|
8961
|
+
const tokens = trimmed.split(/\s+/);
|
|
8962
|
+
if (tokens.length < 2) {
|
|
8963
|
+
return null;
|
|
8964
|
+
}
|
|
8965
|
+
if (!VIEW_TAIL_TOKEN_RE.test(tokens[tokens.length - 1])) {
|
|
8966
|
+
return null;
|
|
8967
|
+
}
|
|
8968
|
+
const tail = tokens[tokens.length - 1];
|
|
8969
|
+
const head = tokens.slice(0, -1).join(" ");
|
|
8970
|
+
return `${this.transformSingle(head)} ${tail}`;
|
|
8971
|
+
}
|
|
8916
8972
|
/**
|
|
8917
8973
|
* `<command …> end` fragments: transform the command without its stranded
|
|
8918
8974
|
* terminator, then re-append the translated terminator as a standalone
|