@lokascript/i18n 2.9.4 → 2.10.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/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { I as I18nConfig, T as TranslationOptions, a as TranslationResult, D as Dictionary, V as ValidationResult$1, b as Token } from './types-BYtpqGq3.cjs';
|
|
2
2
|
export { c as DICTIONARY_CATEGORIES, d as DictionaryCategory, L as LocaleMetadata, e as TokenType, f as TranslationContext, g as ValidationError, h as ValidationWarning, i as findInDictionary, j as forEachCategory, k as getDictionaryCategory, l as isDictionaryCategory, t as translateFromEnglish } from './types-BYtpqGq3.cjs';
|
|
3
3
|
export { ar, bn, de, dictionaries, en, es, fr, getDictionary, hi, id, isLocaleSupported, it, ja, ko, ms, pl, pt, qu, ru, supportedLocales, sw, th, tl, tr, uk, vi, zh } from './dictionaries/index.cjs';
|
|
4
|
-
export { A as AdpositionType, E as ENGLISH_COMMANDS, a as ENGLISH_KEYWORDS, G as GrammarRule, b as GrammarTransformer, c as GrammaticalMarker, K as KeywordProvider, 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 arDictionary, l as arKeywords, m as arabicProfile, n as bnDictionary, o as bnKeywords, p as chineseProfile, q as createEnglishProvider, r as createKeywordProvider, s as deDictionary, t as deKeywords, u as detectBrowserLocale, v as englishProfile, w as esDictionary, x as esKeywords, y as frDictionary, z as frKeywords, D as getProfile, F as getSupportedLocales, H as grammarExamples, J as hiDictionary, N as hiKeywords, O as idDictionary, Q as idKeywords, R as indonesianProfile, T as insertMarkers, V as itDictionary, X as itKeywords, Y as jaDictionary, Z as jaKeywords, _ as japaneseProfile, a0 as koDictionary, a1 as koKeywords, a2 as koreanProfile, a3 as malayProfile, a4 as msDictionary, a5 as msKeywords, a6 as parseStatement, a7 as plDictionary, a8 as plKeywords, aa as profiles, ab as ptDictionary, ac as ptKeywords, ad as quDictionary, ae as quKeywords, af as quechuaProfile, ag as reorderRoles, ah as ruDictionary, ai as ruKeywords, aj as spanishProfile, ak as swDictionary, al as swKeywords, am as swahiliProfile, an as thDictionary, ao as thKeywords, ap as tlDictionary, aq as tlKeywords, ar as toEnglish, as as toLocale, at as trDictionary, au as trKeywords, av as transformStatement, aw as translate, ax as turkishProfile, ay as ukDictionary, az as ukKeywords, aA as viDictionary, aB as viKeywords, aC as zhDictionary, aD as zhKeywords } from './transformer
|
|
4
|
+
export { A as AdpositionType, E as ENGLISH_COMMANDS, a as ENGLISH_KEYWORDS, G as GrammarRule, b as GrammarTransformer, c as GrammaticalMarker, K as KeywordProvider, 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 arDictionary, l as arKeywords, m as arabicProfile, n as bnDictionary, o as bnKeywords, p as chineseProfile, q as createEnglishProvider, r as createKeywordProvider, s as deDictionary, t as deKeywords, u as detectBrowserLocale, v as englishProfile, w as esDictionary, x as esKeywords, y as frDictionary, z as frKeywords, D as getProfile, F as getSupportedLocales, H as grammarExamples, J as hiDictionary, N as hiKeywords, O as idDictionary, Q as idKeywords, R as indonesianProfile, T as insertMarkers, V as itDictionary, X as itKeywords, Y as jaDictionary, Z as jaKeywords, _ as japaneseProfile, a0 as koDictionary, a1 as koKeywords, a2 as koreanProfile, a3 as malayProfile, a4 as msDictionary, a5 as msKeywords, a6 as parseStatement, a7 as plDictionary, a8 as plKeywords, aa as profiles, ab as ptDictionary, ac as ptKeywords, ad as quDictionary, ae as quKeywords, af as quechuaProfile, ag as reorderRoles, ah as ruDictionary, ai as ruKeywords, aj as spanishProfile, ak as swDictionary, al as swKeywords, am as swahiliProfile, an as thDictionary, ao as thKeywords, ap as tlDictionary, aq as tlKeywords, ar as toEnglish, as as toLocale, at as trDictionary, au as trKeywords, av as transformStatement, aw as translate, ax as turkishProfile, ay as ukDictionary, az as ukKeywords, aA as viDictionary, aB as viKeywords, aC as zhDictionary, aD as zhKeywords } from './transformer-CsOeqayN.cjs';
|
|
5
5
|
export { hyperscriptI18nVitePlugin } from './plugins/vite.cjs';
|
|
6
6
|
export { HyperscriptI18nWebpackPlugin } from './plugins/webpack.cjs';
|
|
7
7
|
import { z } from 'zod';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { I as I18nConfig, T as TranslationOptions, a as TranslationResult, D as Dictionary, V as ValidationResult$1, b as Token } from './types-BYtpqGq3.js';
|
|
2
2
|
export { c as DICTIONARY_CATEGORIES, d as DictionaryCategory, L as LocaleMetadata, e as TokenType, f as TranslationContext, g as ValidationError, h as ValidationWarning, i as findInDictionary, j as forEachCategory, k as getDictionaryCategory, l as isDictionaryCategory, t as translateFromEnglish } from './types-BYtpqGq3.js';
|
|
3
3
|
export { ar, bn, de, dictionaries, en, es, fr, getDictionary, hi, id, isLocaleSupported, it, ja, ko, ms, pl, pt, qu, ru, supportedLocales, sw, th, tl, tr, uk, vi, zh } from './dictionaries/index.js';
|
|
4
|
-
export { A as AdpositionType, E as ENGLISH_COMMANDS, a as ENGLISH_KEYWORDS, G as GrammarRule, b as GrammarTransformer, c as GrammaticalMarker, K as KeywordProvider, 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 arDictionary, l as arKeywords, m as arabicProfile, n as bnDictionary, o as bnKeywords, p as chineseProfile, q as createEnglishProvider, r as createKeywordProvider, s as deDictionary, t as deKeywords, u as detectBrowserLocale, v as englishProfile, w as esDictionary, x as esKeywords, y as frDictionary, z as frKeywords, D as getProfile, F as getSupportedLocales, H as grammarExamples, J as hiDictionary, N as hiKeywords, O as idDictionary, Q as idKeywords, R as indonesianProfile, T as insertMarkers, V as itDictionary, X as itKeywords, Y as jaDictionary, Z as jaKeywords, _ as japaneseProfile, a0 as koDictionary, a1 as koKeywords, a2 as koreanProfile, a3 as malayProfile, a4 as msDictionary, a5 as msKeywords, a6 as parseStatement, a7 as plDictionary, a8 as plKeywords, aa as profiles, ab as ptDictionary, ac as ptKeywords, ad as quDictionary, ae as quKeywords, af as quechuaProfile, ag as reorderRoles, ah as ruDictionary, ai as ruKeywords, aj as spanishProfile, ak as swDictionary, al as swKeywords, am as swahiliProfile, an as thDictionary, ao as thKeywords, ap as tlDictionary, aq as tlKeywords, ar as toEnglish, as as toLocale, at as trDictionary, au as trKeywords, av as transformStatement, aw as translate, ax as turkishProfile, ay as ukDictionary, az as ukKeywords, aA as viDictionary, aB as viKeywords, aC as zhDictionary, aD as zhKeywords } from './transformer-
|
|
4
|
+
export { A as AdpositionType, E as ENGLISH_COMMANDS, a as ENGLISH_KEYWORDS, G as GrammarRule, b as GrammarTransformer, c as GrammaticalMarker, K as KeywordProvider, 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 arDictionary, l as arKeywords, m as arabicProfile, n as bnDictionary, o as bnKeywords, p as chineseProfile, q as createEnglishProvider, r as createKeywordProvider, s as deDictionary, t as deKeywords, u as detectBrowserLocale, v as englishProfile, w as esDictionary, x as esKeywords, y as frDictionary, z as frKeywords, D as getProfile, F as getSupportedLocales, H as grammarExamples, J as hiDictionary, N as hiKeywords, O as idDictionary, Q as idKeywords, R as indonesianProfile, T as insertMarkers, V as itDictionary, X as itKeywords, Y as jaDictionary, Z as jaKeywords, _ as japaneseProfile, a0 as koDictionary, a1 as koKeywords, a2 as koreanProfile, a3 as malayProfile, a4 as msDictionary, a5 as msKeywords, a6 as parseStatement, a7 as plDictionary, a8 as plKeywords, aa as profiles, ab as ptDictionary, ac as ptKeywords, ad as quDictionary, ae as quKeywords, af as quechuaProfile, ag as reorderRoles, ah as ruDictionary, ai as ruKeywords, aj as spanishProfile, ak as swDictionary, al as swKeywords, am as swahiliProfile, an as thDictionary, ao as thKeywords, ap as tlDictionary, aq as tlKeywords, ar as toEnglish, as as toLocale, at as trDictionary, au as trKeywords, av as transformStatement, aw as translate, ax as turkishProfile, ay as ukDictionary, az as ukKeywords, aA as viDictionary, aB as viKeywords, aC as zhDictionary, aD as zhKeywords } from './transformer-DWCTG1DQ.js';
|
|
5
5
|
export { hyperscriptI18nVitePlugin } from './plugins/vite.js';
|
|
6
6
|
export { HyperscriptI18nWebpackPlugin } from './plugins/webpack.js';
|
|
7
7
|
import { z } from 'zod';
|
package/dist/index.js
CHANGED
|
@@ -15335,6 +15335,25 @@ function restoreCaretScopes(input, scopes) {
|
|
|
15335
15335
|
(_m, n) => scopes[Number(n)] ?? ""
|
|
15336
15336
|
);
|
|
15337
15337
|
}
|
|
15338
|
+
var VIEW_TAIL_OPEN = "\uE002";
|
|
15339
|
+
var VIEW_TAIL_CLOSE = "\uE003";
|
|
15340
|
+
var VIEW_TAIL_RE = /\busing\s+view\b(?:\s+(?!then\b)[A-Za-z][\w-]*)?/gi;
|
|
15341
|
+
var VIEW_TAIL_TOKEN_RE = new RegExp(`^${VIEW_TAIL_OPEN}(\\d+)${VIEW_TAIL_CLOSE}$`);
|
|
15342
|
+
function maskViewTransitionTails(input) {
|
|
15343
|
+
const tails = [];
|
|
15344
|
+
const masked = input.replace(VIEW_TAIL_RE, (match) => {
|
|
15345
|
+
const idx = tails.length;
|
|
15346
|
+
tails.push(match);
|
|
15347
|
+
return `${VIEW_TAIL_OPEN}${idx}${VIEW_TAIL_CLOSE}`;
|
|
15348
|
+
});
|
|
15349
|
+
return tails.length > 0 ? { masked, tails } : null;
|
|
15350
|
+
}
|
|
15351
|
+
function restoreViewTransitionTails(input, tails) {
|
|
15352
|
+
return input.replace(
|
|
15353
|
+
new RegExp(`${VIEW_TAIL_OPEN}(\\d+)${VIEW_TAIL_CLOSE}`, "g"),
|
|
15354
|
+
(_m, n) => tails[Number(n)] ?? ""
|
|
15355
|
+
);
|
|
15356
|
+
}
|
|
15338
15357
|
var GrammarTransformer = class {
|
|
15339
15358
|
constructor(sourceLocale = "en", targetLocale) {
|
|
15340
15359
|
const source = getProfile(sourceLocale);
|
|
@@ -15356,6 +15375,10 @@ var GrammarTransformer = class {
|
|
|
15356
15375
|
return this.targetProfile.code === "he" ? repairHebrewFrontedAccusative(out) : out;
|
|
15357
15376
|
}
|
|
15358
15377
|
transformInternal(input) {
|
|
15378
|
+
const viewTails = maskViewTransitionTails(input);
|
|
15379
|
+
if (viewTails) {
|
|
15380
|
+
return restoreViewTransitionTails(this.transformInternal(viewTails.masked), viewTails.tails);
|
|
15381
|
+
}
|
|
15359
15382
|
const caret = maskCaretScopes(input);
|
|
15360
15383
|
if (caret) {
|
|
15361
15384
|
return restoreCaretScopes(this.transform(caret.masked), caret.scopes);
|
|
@@ -15408,6 +15431,10 @@ var GrammarTransformer = class {
|
|
|
15408
15431
|
if (setScope !== null) {
|
|
15409
15432
|
return setScope;
|
|
15410
15433
|
}
|
|
15434
|
+
const viewTail = this.transformWithViewTransitionTail(input);
|
|
15435
|
+
if (viewTail !== null) {
|
|
15436
|
+
return viewTail;
|
|
15437
|
+
}
|
|
15411
15438
|
const parsed = parseStatement(input, this.sourceProfile.code);
|
|
15412
15439
|
if (!parsed) {
|
|
15413
15440
|
return input;
|
|
@@ -15431,6 +15458,35 @@ var GrammarTransformer = class {
|
|
|
15431
15458
|
}
|
|
15432
15459
|
return joinTokens(reordered.map((e) => e.translated || e.value));
|
|
15433
15460
|
}
|
|
15461
|
+
/**
|
|
15462
|
+
* Clause carrying a masked `using view transition` tail: strip the opaque
|
|
15463
|
+
* token, transform the clause alone, and re-append the token at the very end.
|
|
15464
|
+
*
|
|
15465
|
+
* The tail is a clause-final modifier in every word order the corpus emits:
|
|
15466
|
+
* the semantic side matches it as the literal `using view` marker plus a value
|
|
15467
|
+
* word, and the SOV/VSO event-handler patterns admit it as an optional
|
|
15468
|
+
* TRAILING group (after the with-marked operand). So the target position is
|
|
15469
|
+
* "end of the transformed clause" for all 24 languages — no per-profile
|
|
15470
|
+
* placement decision, which is what makes this a passthrough rather than a
|
|
15471
|
+
* role.
|
|
15472
|
+
*
|
|
15473
|
+
* Returns null when the clause carries no masked tail, or when the token is
|
|
15474
|
+
* not clause-final (nothing to reposition — leaving it in place still restores
|
|
15475
|
+
* verbatim English).
|
|
15476
|
+
*/
|
|
15477
|
+
transformWithViewTransitionTail(input) {
|
|
15478
|
+
const trimmed = input.trim();
|
|
15479
|
+
const tokens = trimmed.split(/\s+/);
|
|
15480
|
+
if (tokens.length < 2) {
|
|
15481
|
+
return null;
|
|
15482
|
+
}
|
|
15483
|
+
if (!VIEW_TAIL_TOKEN_RE.test(tokens[tokens.length - 1])) {
|
|
15484
|
+
return null;
|
|
15485
|
+
}
|
|
15486
|
+
const tail = tokens[tokens.length - 1];
|
|
15487
|
+
const head = tokens.slice(0, -1).join(" ");
|
|
15488
|
+
return `${this.transformSingle(head)} ${tail}`;
|
|
15489
|
+
}
|
|
15434
15490
|
/**
|
|
15435
15491
|
* `<command …> end` fragments: transform the command without its stranded
|
|
15436
15492
|
* terminator, then re-append the translated terminator as a standalone
|