@lokascript/i18n 2.11.1 → 3.0.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/CHANGELOG.md +13 -0
- package/dist/browser.cjs +5 -1690
- 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 +6 -1685
- package/dist/browser.js.map +1 -1
- package/dist/dictionaries/index.cjs +5 -1
- package/dist/dictionaries/index.cjs.map +1 -1
- package/dist/dictionaries/index.js +5 -1
- package/dist/dictionaries/index.js.map +1 -1
- package/dist/{transformer-CsOeqayN.d.cts → index-BykxjYST.d.cts} +1 -232
- package/dist/{transformer-DWCTG1DQ.d.ts → index-DuIef8O7.d.ts} +1 -232
- package/dist/index.cjs +16 -1878
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -35
- package/dist/index.d.ts +35 -35
- package/dist/index.js +17 -1873
- 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 +49 -2680
- package/dist/lokascript-i18n.mjs.map +1 -1
- package/dist/plugins/vite.cjs +5 -1
- package/dist/plugins/vite.cjs.map +1 -1
- package/dist/plugins/vite.js +5 -1
- package/dist/plugins/vite.js.map +1 -1
- package/dist/plugins/webpack.cjs +5 -1
- package/dist/plugins/webpack.cjs.map +1 -1
- package/dist/plugins/webpack.js +5 -1
- package/dist/plugins/webpack.js.map +1 -1
- package/package.json +4 -4
- package/src/browser.ts +0 -7
- package/src/compatibility/browser-tests/grammar-demo.spec.ts +22 -8
- package/src/constants.ts +1 -0
- package/src/dictionaries/bn.ts +5 -1
- package/src/grammar/index.ts +15 -9
- package/src/grammar/profiles.test.ts +440 -0
- package/src/index.ts +0 -7
- package/src/lexicon-parity.test.ts +77 -0
- package/src/grammar/grammar.test.ts +0 -2751
- package/src/grammar/transformer.ts +0 -2737
package/dist/index.js
CHANGED
|
@@ -4523,7 +4523,11 @@ var bengaliDictionary = {
|
|
|
4523
4523
|
random: "\u098F\u09B2\u09CB\u09AE\u09C7\u09B2\u09CB",
|
|
4524
4524
|
length: "\u09A6\u09C8\u09B0\u09CD\u0998\u09CD\u09AF",
|
|
4525
4525
|
index: "\u09B8\u09C2\u099A\u0995",
|
|
4526
|
-
empty
|
|
4526
|
+
// The EXPRESSION `empty` is the state predicate (`if my value is empty`),
|
|
4527
|
+
// not the command: `খালি-করুন` is the imperative "empty it!" and belongs to
|
|
4528
|
+
// the `empty` COMMAND, which keeps it. Kept in step with the semantic
|
|
4529
|
+
// lexicon by `lexicon-parity.test.ts`.
|
|
4530
|
+
empty: "\u0996\u09BE\u09B2\u09BF",
|
|
4527
4531
|
"starts with": "\u09A6\u09BF\u09AF\u09BC\u09C7_\u09B6\u09C1\u09B0\u09C1",
|
|
4528
4532
|
"ends with": "\u09A6\u09BF\u09AF\u09BC\u09C7_\u09B6\u09C7\u09B7",
|
|
4529
4533
|
"ignoring case": "\u0995\u09C7\u09B8_\u0989\u09AA\u09C7\u0995\u09CD\u09B7\u09BE",
|
|
@@ -7435,25 +7439,25 @@ var HyperscriptTranslator = class {
|
|
|
7435
7439
|
}
|
|
7436
7440
|
translateWithDetails(text, options) {
|
|
7437
7441
|
const fromLocale = options.from || this.detectLanguage(text);
|
|
7438
|
-
const
|
|
7439
|
-
if (fromLocale ===
|
|
7442
|
+
const toLocale = options.to;
|
|
7443
|
+
if (fromLocale === toLocale) {
|
|
7440
7444
|
return {
|
|
7441
7445
|
translated: text,
|
|
7442
7446
|
original: text,
|
|
7443
7447
|
tokens: [],
|
|
7444
|
-
locale: { from: fromLocale, to:
|
|
7448
|
+
locale: { from: fromLocale, to: toLocale }
|
|
7445
7449
|
};
|
|
7446
7450
|
}
|
|
7447
7451
|
const fromDict = this.getDictionary(fromLocale);
|
|
7448
|
-
const toDict = this.getDictionary(
|
|
7452
|
+
const toDict = this.getDictionary(toLocale);
|
|
7449
7453
|
if (!fromDict || !toDict) {
|
|
7450
|
-
throw new Error(`Missing dictionary for locale: ${!fromDict ? fromLocale :
|
|
7454
|
+
throw new Error(`Missing dictionary for locale: ${!fromDict ? fromLocale : toLocale}`);
|
|
7451
7455
|
}
|
|
7452
7456
|
const tokens = tokenize(text, fromLocale);
|
|
7453
|
-
const translatedTokens = this.translateTokens(tokens, fromLocale,
|
|
7457
|
+
const translatedTokens = this.translateTokens(tokens, fromLocale, toLocale);
|
|
7454
7458
|
const translated = this.reconstructText(translatedTokens);
|
|
7455
7459
|
if (options.validate && toDict) {
|
|
7456
|
-
const validation = validate(toDict,
|
|
7460
|
+
const validation = validate(toDict, toLocale);
|
|
7457
7461
|
if (!validation.valid) {
|
|
7458
7462
|
console.warn("Translation validation warnings:", validation.warnings);
|
|
7459
7463
|
}
|
|
@@ -7461,7 +7465,7 @@ var HyperscriptTranslator = class {
|
|
|
7461
7465
|
const result = {
|
|
7462
7466
|
translated,
|
|
7463
7467
|
tokens: translatedTokens,
|
|
7464
|
-
locale: { from: fromLocale, to:
|
|
7468
|
+
locale: { from: fromLocale, to: toLocale },
|
|
7465
7469
|
warnings: []
|
|
7466
7470
|
};
|
|
7467
7471
|
if (options.preserveOriginal) {
|
|
@@ -7469,9 +7473,9 @@ var HyperscriptTranslator = class {
|
|
|
7469
7473
|
}
|
|
7470
7474
|
return result;
|
|
7471
7475
|
}
|
|
7472
|
-
translateTokens(tokens, fromLocale,
|
|
7476
|
+
translateTokens(tokens, fromLocale, toLocale) {
|
|
7473
7477
|
const fromDict = this.getDictionary(fromLocale);
|
|
7474
|
-
const toDict = this.getDictionary(
|
|
7478
|
+
const toDict = this.getDictionary(toLocale);
|
|
7475
7479
|
const reverseFromDict = this.getReverseDictionary(fromLocale);
|
|
7476
7480
|
const emptyDict = {
|
|
7477
7481
|
commands: {},
|
|
@@ -7486,7 +7490,7 @@ var HyperscriptTranslator = class {
|
|
|
7486
7490
|
return tokens.map((token) => {
|
|
7487
7491
|
let translated = token.value;
|
|
7488
7492
|
if (this.isTranslatableToken(token)) {
|
|
7489
|
-
if (fromLocale !== "en" &&
|
|
7493
|
+
if (fromLocale !== "en" && toLocale !== "en") {
|
|
7490
7494
|
const english = this.findTranslation(token.value, fromDict || emptyDict, reverseFromDict);
|
|
7491
7495
|
if (english) {
|
|
7492
7496
|
translated = this.findTranslation(english, toDict || emptyDict, /* @__PURE__ */ new Map()) || token.value;
|
|
@@ -7617,39 +7621,6 @@ var HyperscriptTranslator = class {
|
|
|
7617
7621
|
new HyperscriptTranslator({ locale: "en" });
|
|
7618
7622
|
|
|
7619
7623
|
// src/constants.ts
|
|
7620
|
-
var ENGLISH_MODIFIER_ROLES = {
|
|
7621
|
-
to: "destination",
|
|
7622
|
-
into: "destination",
|
|
7623
|
-
from: "source",
|
|
7624
|
-
with: "style",
|
|
7625
|
-
by: "quantity",
|
|
7626
|
-
as: "method",
|
|
7627
|
-
on: "event",
|
|
7628
|
-
over: "duration",
|
|
7629
|
-
for: "duration"
|
|
7630
|
-
};
|
|
7631
|
-
var COMMAND_PRIMARY_ROLES = {
|
|
7632
|
-
set: "destination",
|
|
7633
|
-
on: "event",
|
|
7634
|
-
trigger: "event",
|
|
7635
|
-
send: "event",
|
|
7636
|
-
wait: "duration",
|
|
7637
|
-
fetch: "source",
|
|
7638
|
-
get: "source",
|
|
7639
|
-
if: "condition",
|
|
7640
|
-
unless: "condition",
|
|
7641
|
-
while: "condition",
|
|
7642
|
-
repeat: "loopType",
|
|
7643
|
-
go: "destination",
|
|
7644
|
-
scroll: "destination",
|
|
7645
|
-
tell: "destination",
|
|
7646
|
-
default: "destination",
|
|
7647
|
-
swap: "destination",
|
|
7648
|
-
// morph deliberately absent: its schema primaryRole is `patient` (the
|
|
7649
|
-
// element being morphed — aligned with the transformer's patient marking
|
|
7650
|
-
// in the session-9 role-layout swap), and patient is the default.
|
|
7651
|
-
bind: "destination"
|
|
7652
|
-
};
|
|
7653
7624
|
var ENGLISH_MODIFIERS = /* @__PURE__ */ new Set([
|
|
7654
7625
|
"to",
|
|
7655
7626
|
"from",
|
|
@@ -7882,69 +7853,6 @@ var ENGLISH_EXPRESSION_KEYWORDS = /* @__PURE__ */ new Set([
|
|
|
7882
7853
|
"starts with",
|
|
7883
7854
|
"ends with"
|
|
7884
7855
|
]);
|
|
7885
|
-
var CONDITIONAL_KEYWORDS = /* @__PURE__ */ new Set([
|
|
7886
|
-
// English
|
|
7887
|
-
"if",
|
|
7888
|
-
"unless",
|
|
7889
|
-
"when",
|
|
7890
|
-
"where",
|
|
7891
|
-
// Japanese
|
|
7892
|
-
"\u3082\u3057",
|
|
7893
|
-
"\u6642\u306B",
|
|
7894
|
-
"\u3068\u304D\u306B",
|
|
7895
|
-
"\u3069\u3053\u3067",
|
|
7896
|
-
// Chinese
|
|
7897
|
-
"\u5982\u679C",
|
|
7898
|
-
"\u5F53",
|
|
7899
|
-
// Arabic
|
|
7900
|
-
"\u0625\u0630\u0627",
|
|
7901
|
-
"\u0639\u0646\u062F\u0645\u0627",
|
|
7902
|
-
"\u062D\u064A\u062B",
|
|
7903
|
-
// Spanish
|
|
7904
|
-
"si",
|
|
7905
|
-
"cuando",
|
|
7906
|
-
"donde",
|
|
7907
|
-
// German
|
|
7908
|
-
"wenn",
|
|
7909
|
-
"wann",
|
|
7910
|
-
"wo",
|
|
7911
|
-
// French
|
|
7912
|
-
"quand",
|
|
7913
|
-
"lorsque",
|
|
7914
|
-
"o\xF9",
|
|
7915
|
-
// Portuguese
|
|
7916
|
-
"quando",
|
|
7917
|
-
"onde",
|
|
7918
|
-
// Turkish
|
|
7919
|
-
"e\u011Fer",
|
|
7920
|
-
"zaman",
|
|
7921
|
-
"nerede",
|
|
7922
|
-
// Indonesian
|
|
7923
|
-
"ketika",
|
|
7924
|
-
"saat",
|
|
7925
|
-
"dimana",
|
|
7926
|
-
// Korean
|
|
7927
|
-
"\uB54C",
|
|
7928
|
-
"\uC5B4\uB514\uC11C",
|
|
7929
|
-
// Quechua
|
|
7930
|
-
"maypi",
|
|
7931
|
-
// Swahili
|
|
7932
|
-
"wakati",
|
|
7933
|
-
"wapi"
|
|
7934
|
-
]);
|
|
7935
|
-
var THEN_KEYWORDS = /* @__PURE__ */ new Set([
|
|
7936
|
-
"then",
|
|
7937
|
-
"\u305D\u308C\u304B\u3089",
|
|
7938
|
-
"\u90A3\u4E48",
|
|
7939
|
-
"\u062B\u0645",
|
|
7940
|
-
"entonces",
|
|
7941
|
-
"alors",
|
|
7942
|
-
"dann",
|
|
7943
|
-
"sonra",
|
|
7944
|
-
"lalu",
|
|
7945
|
-
"chayqa",
|
|
7946
|
-
"kisha"
|
|
7947
|
-
]);
|
|
7948
7856
|
|
|
7949
7857
|
// src/parser/create-provider.ts
|
|
7950
7858
|
function createKeywordProvider(dictionary, locale, options = {}) {
|
|
@@ -14177,1774 +14085,10 @@ async function createEnhancedI18n(locale, options) {
|
|
|
14177
14085
|
}
|
|
14178
14086
|
var enhancedI18nImplementation = new TypedI18nContextImplementation();
|
|
14179
14087
|
|
|
14180
|
-
// src/grammar/direct-mappings.ts
|
|
14181
|
-
function reverseMapping(mapping) {
|
|
14182
|
-
const reversedWords = {};
|
|
14183
|
-
for (const [source, target] of Object.entries(mapping.words)) {
|
|
14184
|
-
reversedWords[target] = source;
|
|
14185
|
-
}
|
|
14186
|
-
const reversedCategories = {};
|
|
14187
|
-
if (mapping.categories) {
|
|
14188
|
-
for (const [category, words] of Object.entries(mapping.categories)) {
|
|
14189
|
-
reversedCategories[category] = {};
|
|
14190
|
-
for (const [source, target] of Object.entries(words)) {
|
|
14191
|
-
reversedCategories[category][target] = source;
|
|
14192
|
-
}
|
|
14193
|
-
}
|
|
14194
|
-
}
|
|
14195
|
-
const result = {
|
|
14196
|
-
source: mapping.target,
|
|
14197
|
-
target: mapping.source,
|
|
14198
|
-
words: reversedWords
|
|
14199
|
-
};
|
|
14200
|
-
if (Object.keys(reversedCategories).length > 0) {
|
|
14201
|
-
result.categories = reversedCategories;
|
|
14202
|
-
}
|
|
14203
|
-
return result;
|
|
14204
|
-
}
|
|
14205
|
-
function buildMappingFromDictionaries(sourceDict, targetDict, sourceCode, targetCode) {
|
|
14206
|
-
const words = {};
|
|
14207
|
-
const categories = {};
|
|
14208
|
-
for (const category of [
|
|
14209
|
-
"commands",
|
|
14210
|
-
"modifiers",
|
|
14211
|
-
"events",
|
|
14212
|
-
"logical",
|
|
14213
|
-
"temporal",
|
|
14214
|
-
"values",
|
|
14215
|
-
"attributes"
|
|
14216
|
-
]) {
|
|
14217
|
-
const sourceCategory = sourceDict[category];
|
|
14218
|
-
const targetCategory = targetDict[category];
|
|
14219
|
-
if (sourceCategory && targetCategory) {
|
|
14220
|
-
categories[category] = {};
|
|
14221
|
-
for (const [englishKey, sourceWord] of Object.entries(sourceCategory)) {
|
|
14222
|
-
const targetWord = targetCategory[englishKey];
|
|
14223
|
-
if (targetWord && sourceWord !== targetWord) {
|
|
14224
|
-
words[sourceWord] = targetWord;
|
|
14225
|
-
categories[category][sourceWord] = targetWord;
|
|
14226
|
-
}
|
|
14227
|
-
}
|
|
14228
|
-
}
|
|
14229
|
-
}
|
|
14230
|
-
return {
|
|
14231
|
-
source: sourceCode,
|
|
14232
|
-
target: targetCode,
|
|
14233
|
-
words,
|
|
14234
|
-
categories
|
|
14235
|
-
};
|
|
14236
|
-
}
|
|
14237
|
-
var jaZhMapping = buildMappingFromDictionaries(ja, zh, "ja", "zh");
|
|
14238
|
-
var zhJaMapping = reverseMapping(jaZhMapping);
|
|
14239
|
-
var koJaMapping = buildMappingFromDictionaries(ko, ja, "ko", "ja");
|
|
14240
|
-
var jaKoMapping = reverseMapping(koJaMapping);
|
|
14241
|
-
var esPtMapping = {
|
|
14242
|
-
source: "es",
|
|
14243
|
-
target: "pt",
|
|
14244
|
-
words: {
|
|
14245
|
-
// Commands - many are cognates
|
|
14246
|
-
en: "em",
|
|
14247
|
-
// on (event)
|
|
14248
|
-
decir: "dizer",
|
|
14249
|
-
// tell
|
|
14250
|
-
disparar: "disparar",
|
|
14251
|
-
// trigger
|
|
14252
|
-
enviar: "enviar",
|
|
14253
|
-
// send
|
|
14254
|
-
tomar: "pegar",
|
|
14255
|
-
// take
|
|
14256
|
-
poner: "colocar",
|
|
14257
|
-
// put
|
|
14258
|
-
establecer: "definir",
|
|
14259
|
-
// set
|
|
14260
|
-
obtener: "obter",
|
|
14261
|
-
// get
|
|
14262
|
-
agregar: "adicionar",
|
|
14263
|
-
// add
|
|
14264
|
-
quitar: "remover",
|
|
14265
|
-
// remove
|
|
14266
|
-
alternar: "alternar",
|
|
14267
|
-
// toggle
|
|
14268
|
-
ocultar: "esconder",
|
|
14269
|
-
// hide
|
|
14270
|
-
mostrar: "mostrar",
|
|
14271
|
-
// show
|
|
14272
|
-
si: "se",
|
|
14273
|
-
// if
|
|
14274
|
-
menos: "a menos",
|
|
14275
|
-
// unless
|
|
14276
|
-
repetir: "repetir",
|
|
14277
|
-
// repeat
|
|
14278
|
-
para: "para",
|
|
14279
|
-
// for
|
|
14280
|
-
mientras: "enquanto",
|
|
14281
|
-
// while
|
|
14282
|
-
hasta: "at\xE9",
|
|
14283
|
-
// until
|
|
14284
|
-
continuar: "continuar",
|
|
14285
|
-
// continue
|
|
14286
|
-
romper: "parar",
|
|
14287
|
-
// break
|
|
14288
|
-
detener: "parar",
|
|
14289
|
-
// halt
|
|
14290
|
-
esperar: "esperar",
|
|
14291
|
-
// wait
|
|
14292
|
-
buscar: "buscar",
|
|
14293
|
-
// fetch
|
|
14294
|
-
llamar: "chamar",
|
|
14295
|
-
// call
|
|
14296
|
-
retornar: "retornar",
|
|
14297
|
-
// return
|
|
14298
|
-
hacer: "fazer",
|
|
14299
|
-
// make
|
|
14300
|
-
registrar: "registrar",
|
|
14301
|
-
// log
|
|
14302
|
-
lanzar: "lan\xE7ar",
|
|
14303
|
-
// throw
|
|
14304
|
-
atrapar: "capturar",
|
|
14305
|
-
// catch
|
|
14306
|
-
medir: "medir",
|
|
14307
|
-
// measure
|
|
14308
|
-
transici\u00F3n: "transi\xE7\xE3o",
|
|
14309
|
-
// transition
|
|
14310
|
-
incrementar: "incrementar",
|
|
14311
|
-
// increment
|
|
14312
|
-
decrementar: "decrementar",
|
|
14313
|
-
// decrement
|
|
14314
|
-
predeterminar: "padr\xE3o",
|
|
14315
|
-
// default
|
|
14316
|
-
ir: "ir",
|
|
14317
|
-
// go
|
|
14318
|
-
copiar: "copiar",
|
|
14319
|
-
// copy
|
|
14320
|
-
escoger: "escolher",
|
|
14321
|
-
// pick
|
|
14322
|
-
intercambiar: "trocar",
|
|
14323
|
-
// swap
|
|
14324
|
-
transformar: "transformar",
|
|
14325
|
-
// morph
|
|
14326
|
-
a\u00F1adir: "anexar",
|
|
14327
|
-
// append
|
|
14328
|
-
salir: "sair",
|
|
14329
|
-
// exit
|
|
14330
|
-
// Modifiers
|
|
14331
|
-
a: "para",
|
|
14332
|
-
// to
|
|
14333
|
-
de: "de",
|
|
14334
|
-
// from
|
|
14335
|
-
dentro: "em",
|
|
14336
|
-
// into
|
|
14337
|
-
con: "com",
|
|
14338
|
-
// with
|
|
14339
|
-
como: "como",
|
|
14340
|
-
// as
|
|
14341
|
-
por: "por",
|
|
14342
|
-
// by
|
|
14343
|
-
// Events
|
|
14344
|
-
clic: "clique",
|
|
14345
|
-
// click
|
|
14346
|
-
cambio: "mudan\xE7a",
|
|
14347
|
-
// change
|
|
14348
|
-
entrada: "entrada",
|
|
14349
|
-
// input
|
|
14350
|
-
env\u00EDo: "envio",
|
|
14351
|
-
// submit
|
|
14352
|
-
carga: "carregar",
|
|
14353
|
-
// load
|
|
14354
|
-
enfoque: "foco",
|
|
14355
|
-
// focus
|
|
14356
|
-
desenfoque: "desfoque",
|
|
14357
|
-
// blur
|
|
14358
|
-
// Logical
|
|
14359
|
-
verdadero: "verdadeiro",
|
|
14360
|
-
// true
|
|
14361
|
-
falso: "falso",
|
|
14362
|
-
// false
|
|
14363
|
-
y: "e",
|
|
14364
|
-
// and
|
|
14365
|
-
o: "ou",
|
|
14366
|
-
// or
|
|
14367
|
-
no: "n\xE3o",
|
|
14368
|
-
// not
|
|
14369
|
-
es: "\xE9",
|
|
14370
|
-
// is
|
|
14371
|
-
// Temporal
|
|
14372
|
-
segundos: "segundos",
|
|
14373
|
-
// seconds
|
|
14374
|
-
milisegundos: "milissegundos",
|
|
14375
|
-
// milliseconds
|
|
14376
|
-
// Values
|
|
14377
|
-
nulo: "nulo",
|
|
14378
|
-
// null
|
|
14379
|
-
indefinido: "indefinido",
|
|
14380
|
-
// undefined
|
|
14381
|
-
vac\u00EDo: "vazio"
|
|
14382
|
-
// empty
|
|
14383
|
-
},
|
|
14384
|
-
categories: {
|
|
14385
|
-
commands: {
|
|
14386
|
-
en: "em",
|
|
14387
|
-
decir: "dizer",
|
|
14388
|
-
tomar: "pegar",
|
|
14389
|
-
poner: "colocar",
|
|
14390
|
-
establecer: "definir",
|
|
14391
|
-
obtener: "obter",
|
|
14392
|
-
agregar: "adicionar",
|
|
14393
|
-
quitar: "remover",
|
|
14394
|
-
ocultar: "esconder",
|
|
14395
|
-
si: "se",
|
|
14396
|
-
mientras: "enquanto",
|
|
14397
|
-
hasta: "at\xE9",
|
|
14398
|
-
romper: "parar",
|
|
14399
|
-
detener: "parar",
|
|
14400
|
-
llamar: "chamar",
|
|
14401
|
-
hacer: "fazer",
|
|
14402
|
-
lanzar: "lan\xE7ar",
|
|
14403
|
-
atrapar: "capturar",
|
|
14404
|
-
escoger: "escolher",
|
|
14405
|
-
intercambiar: "trocar",
|
|
14406
|
-
a\u00F1adir: "anexar",
|
|
14407
|
-
salir: "sair"
|
|
14408
|
-
},
|
|
14409
|
-
events: {
|
|
14410
|
-
clic: "clique",
|
|
14411
|
-
cambio: "mudan\xE7a",
|
|
14412
|
-
carga: "carregar",
|
|
14413
|
-
enfoque: "foco",
|
|
14414
|
-
desenfoque: "desfoque"
|
|
14415
|
-
},
|
|
14416
|
-
logical: {
|
|
14417
|
-
verdadero: "verdadeiro",
|
|
14418
|
-
y: "e",
|
|
14419
|
-
o: "ou",
|
|
14420
|
-
no: "n\xE3o",
|
|
14421
|
-
es: "\xE9"
|
|
14422
|
-
}
|
|
14423
|
-
}
|
|
14424
|
-
};
|
|
14425
|
-
var ptEsMapping = reverseMapping(esPtMapping);
|
|
14426
|
-
var directMappings = /* @__PURE__ */ new Map([
|
|
14427
|
-
// Japanese ↔ Chinese
|
|
14428
|
-
["ja->zh", jaZhMapping],
|
|
14429
|
-
["zh->ja", zhJaMapping],
|
|
14430
|
-
// Korean ↔ Japanese
|
|
14431
|
-
["ko->ja", koJaMapping],
|
|
14432
|
-
["ja->ko", jaKoMapping],
|
|
14433
|
-
// Spanish ↔ Portuguese
|
|
14434
|
-
["es->pt", esPtMapping],
|
|
14435
|
-
["pt->es", ptEsMapping]
|
|
14436
|
-
]);
|
|
14437
|
-
function hasDirectMapping(source, target) {
|
|
14438
|
-
return directMappings.has(`${source}->${target}`);
|
|
14439
|
-
}
|
|
14440
|
-
function getDirectMapping(source, target) {
|
|
14441
|
-
return directMappings.get(`${source}->${target}`);
|
|
14442
|
-
}
|
|
14443
|
-
|
|
14444
|
-
// src/grammar/transformer.ts
|
|
14445
|
-
function getCommandKeywordsForLocale(locale) {
|
|
14446
|
-
const keywords = new Set(ENGLISH_COMMANDS);
|
|
14447
|
-
const dict = dictionaries[locale];
|
|
14448
|
-
if (dict?.commands) {
|
|
14449
|
-
Object.values(dict.commands).forEach((cmd) => {
|
|
14450
|
-
if (typeof cmd === "string") {
|
|
14451
|
-
keywords.add(cmd.toLowerCase());
|
|
14452
|
-
}
|
|
14453
|
-
});
|
|
14454
|
-
}
|
|
14455
|
-
return keywords;
|
|
14456
|
-
}
|
|
14457
|
-
var EN_COPULAS = ["is", "are", "was", "were", "am", "be"];
|
|
14458
|
-
function getCopulasForLocale(locale) {
|
|
14459
|
-
const copulas = new Set(EN_COPULAS);
|
|
14460
|
-
if (locale !== "en") {
|
|
14461
|
-
for (const form of EN_COPULAS) {
|
|
14462
|
-
copulas.add(translateWord(form, "en", locale).toLowerCase());
|
|
14463
|
-
}
|
|
14464
|
-
}
|
|
14465
|
-
return copulas;
|
|
14466
|
-
}
|
|
14467
|
-
function isPredicateAdjectivePosition(tokens, i, copulas) {
|
|
14468
|
-
const prev = tokens[i - 1]?.toLowerCase();
|
|
14469
|
-
return !!prev && copulas.has(prev);
|
|
14470
|
-
}
|
|
14471
|
-
function getForLoopWordsForLocale(locale) {
|
|
14472
|
-
const forWords = /* @__PURE__ */ new Set(["for"]);
|
|
14473
|
-
const inWords = /* @__PURE__ */ new Set(["in"]);
|
|
14474
|
-
if (locale !== "en") {
|
|
14475
|
-
forWords.add(translateWord("for", "en", locale).toLowerCase());
|
|
14476
|
-
inWords.add(translateWord("in", "en", locale).toLowerCase());
|
|
14477
|
-
}
|
|
14478
|
-
return { forWords, inWords };
|
|
14479
|
-
}
|
|
14480
|
-
function isLoopHeadFor(tokens, i, inWords, commandKeywords) {
|
|
14481
|
-
for (let j = i + 1; j < tokens.length; j++) {
|
|
14482
|
-
const lt = tokens[j].toLowerCase();
|
|
14483
|
-
if (inWords.has(lt)) return true;
|
|
14484
|
-
if (commandKeywords.has(lt)) return false;
|
|
14485
|
-
}
|
|
14486
|
-
return false;
|
|
14487
|
-
}
|
|
14488
|
-
function repairHebrewFrontedAccusative(text) {
|
|
14489
|
-
const ACC = "\u05D0\u05EA";
|
|
14490
|
-
const verbs = getCommandKeywordsForLocale("he");
|
|
14491
|
-
const tokens = text.split(/\s+/);
|
|
14492
|
-
let changed = false;
|
|
14493
|
-
for (let i = 0; i + 1 < tokens.length; i++) {
|
|
14494
|
-
if (tokens[i] === ACC && verbs.has(tokens[i + 1].toLowerCase())) {
|
|
14495
|
-
[tokens[i], tokens[i + 1]] = [tokens[i + 1], tokens[i]];
|
|
14496
|
-
changed = true;
|
|
14497
|
-
i++;
|
|
14498
|
-
}
|
|
14499
|
-
}
|
|
14500
|
-
return changed ? tokens.join(" ") : text;
|
|
14501
|
-
}
|
|
14502
|
-
function extractBlockStructure(input, sourceLocale) {
|
|
14503
|
-
const tokens = input.split(/\s+/);
|
|
14504
|
-
const head = tokens[0]?.toLowerCase();
|
|
14505
|
-
if (!head || !BLOCK_HEAD_KEYWORDS.has(head)) return null;
|
|
14506
|
-
let depth = 1;
|
|
14507
|
-
let endIdx = -1;
|
|
14508
|
-
for (let i = 1; i < tokens.length; i++) {
|
|
14509
|
-
const t = tokens[i].toLowerCase();
|
|
14510
|
-
if (BLOCK_HEAD_KEYWORDS.has(t)) depth++;
|
|
14511
|
-
else if (t === "end") {
|
|
14512
|
-
depth--;
|
|
14513
|
-
if (depth === 0) {
|
|
14514
|
-
endIdx = i;
|
|
14515
|
-
break;
|
|
14516
|
-
}
|
|
14517
|
-
}
|
|
14518
|
-
}
|
|
14519
|
-
if (endIdx !== -1 && endIdx !== tokens.length - 1) return null;
|
|
14520
|
-
const inner = endIdx !== -1 ? tokens.slice(1, endIdx) : tokens.slice(1);
|
|
14521
|
-
const base = { headKeyword: tokens[0], body: "" };
|
|
14522
|
-
if (endIdx !== -1) base.tailKeyword = tokens[endIdx];
|
|
14523
|
-
if (head === "live") {
|
|
14524
|
-
return { ...base, body: inner.join(" ") };
|
|
14525
|
-
}
|
|
14526
|
-
if (head === "when") {
|
|
14527
|
-
const idx = inner.findIndex((t) => t.toLowerCase() === "changes");
|
|
14528
|
-
if (idx >= 0) {
|
|
14529
|
-
return {
|
|
14530
|
-
...base,
|
|
14531
|
-
prefixExpr: inner.slice(0, idx).join(" "),
|
|
14532
|
-
connector: inner[idx],
|
|
14533
|
-
body: inner.slice(idx + 1).join(" ")
|
|
14534
|
-
};
|
|
14535
|
-
}
|
|
14536
|
-
return null;
|
|
14537
|
-
}
|
|
14538
|
-
const commands = getCommandKeywordsForLocale(sourceLocale);
|
|
14539
|
-
const copulas = getCopulasForLocale(sourceLocale);
|
|
14540
|
-
let bodyStart = -1;
|
|
14541
|
-
for (let i = 0; i < inner.length; i++) {
|
|
14542
|
-
if (commands.has(inner[i].toLowerCase()) && !isPredicateAdjectivePosition(inner, i, copulas)) {
|
|
14543
|
-
bodyStart = i;
|
|
14544
|
-
break;
|
|
14545
|
-
}
|
|
14546
|
-
}
|
|
14547
|
-
if (bodyStart <= 0) return null;
|
|
14548
|
-
return {
|
|
14549
|
-
...base,
|
|
14550
|
-
prefixExpr: inner.slice(0, bodyStart).join(" "),
|
|
14551
|
-
body: inner.slice(bodyStart).join(" ")
|
|
14552
|
-
};
|
|
14553
|
-
}
|
|
14554
|
-
function splitCompoundStatement(input, sourceLocale) {
|
|
14555
|
-
const lines = input.split(/\n/).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
14556
|
-
const parts = [];
|
|
14557
|
-
for (const line of lines) {
|
|
14558
|
-
const lineParts = splitOnThen(line, sourceLocale);
|
|
14559
|
-
for (const part of lineParts) {
|
|
14560
|
-
const commandParts = splitOnCommandBoundaries(part, sourceLocale);
|
|
14561
|
-
parts.push(...commandParts);
|
|
14562
|
-
}
|
|
14563
|
-
}
|
|
14564
|
-
return parts;
|
|
14565
|
-
}
|
|
14566
|
-
function splitCompoundStatementWithMetadata(input, sourceLocale) {
|
|
14567
|
-
const rawLines = input.split("\n");
|
|
14568
|
-
const lineMetadata = [];
|
|
14569
|
-
const parts = [];
|
|
14570
|
-
const partToLineIndex = [];
|
|
14571
|
-
for (let lineIndex = 0; lineIndex < rawLines.length; lineIndex++) {
|
|
14572
|
-
const rawLine = rawLines[lineIndex];
|
|
14573
|
-
const indentMatch = rawLine.match(/^(\s*)/);
|
|
14574
|
-
const originalIndent = indentMatch ? indentMatch[1] : "";
|
|
14575
|
-
const trimmed = rawLine.trim();
|
|
14576
|
-
lineMetadata.push({
|
|
14577
|
-
content: trimmed,
|
|
14578
|
-
originalIndent,
|
|
14579
|
-
isBlank: trimmed.length === 0
|
|
14580
|
-
});
|
|
14581
|
-
if (trimmed.length > 0) {
|
|
14582
|
-
const lineParts = splitOnThen(trimmed, sourceLocale);
|
|
14583
|
-
for (const part of lineParts) {
|
|
14584
|
-
const commandParts = splitOnCommandBoundaries(part, sourceLocale);
|
|
14585
|
-
for (const cmdPart of commandParts) {
|
|
14586
|
-
parts.push(cmdPart);
|
|
14587
|
-
partToLineIndex.push(lineIndex);
|
|
14588
|
-
}
|
|
14589
|
-
}
|
|
14590
|
-
}
|
|
14591
|
-
}
|
|
14592
|
-
return { parts, lineMetadata, partToLineIndex };
|
|
14593
|
-
}
|
|
14594
|
-
function normalizeIndentation(lineMetadata) {
|
|
14595
|
-
const indentedLines = lineMetadata.filter((m) => !m.isBlank && m.originalIndent.length > 0);
|
|
14596
|
-
if (indentedLines.length === 0) {
|
|
14597
|
-
return lineMetadata.map(() => "");
|
|
14598
|
-
}
|
|
14599
|
-
const indentLengths = indentedLines.map((m) => {
|
|
14600
|
-
const normalized = m.originalIndent.replace(/\t/g, " ");
|
|
14601
|
-
return normalized.length;
|
|
14602
|
-
});
|
|
14603
|
-
const minIndent = Math.min(...indentLengths);
|
|
14604
|
-
const baseUnit = minIndent > 0 ? minIndent : 4;
|
|
14605
|
-
return lineMetadata.map((meta) => {
|
|
14606
|
-
if (meta.isBlank) {
|
|
14607
|
-
return "";
|
|
14608
|
-
}
|
|
14609
|
-
if (meta.originalIndent.length === 0) {
|
|
14610
|
-
return "";
|
|
14611
|
-
}
|
|
14612
|
-
const normalized = meta.originalIndent.replace(/\t/g, " ");
|
|
14613
|
-
const level = Math.round(normalized.length / baseUnit);
|
|
14614
|
-
return " ".repeat(level);
|
|
14615
|
-
});
|
|
14616
|
-
}
|
|
14617
|
-
function reconstructWithLineStructure(transformedParts, lineMetadata, partToLineIndex, targetThen) {
|
|
14618
|
-
const nonBlankCount = lineMetadata.filter((m) => !m.isBlank).length;
|
|
14619
|
-
if (nonBlankCount <= 1 && transformedParts.length <= 1) {
|
|
14620
|
-
const normalizedIndents2 = normalizeIndentation(lineMetadata);
|
|
14621
|
-
const result2 = [];
|
|
14622
|
-
for (let i = 0; i < lineMetadata.length; i++) {
|
|
14623
|
-
if (lineMetadata[i].isBlank) {
|
|
14624
|
-
result2.push("");
|
|
14625
|
-
} else if (transformedParts.length > 0) {
|
|
14626
|
-
result2.push(normalizedIndents2[i] + transformedParts[0]);
|
|
14627
|
-
}
|
|
14628
|
-
}
|
|
14629
|
-
return result2.join("\n");
|
|
14630
|
-
}
|
|
14631
|
-
const normalizedIndents = normalizeIndentation(lineMetadata);
|
|
14632
|
-
const partsPerLine = /* @__PURE__ */ new Map();
|
|
14633
|
-
for (let i = 0; i < transformedParts.length; i++) {
|
|
14634
|
-
const lineIdx = partToLineIndex[i];
|
|
14635
|
-
if (!partsPerLine.has(lineIdx)) {
|
|
14636
|
-
partsPerLine.set(lineIdx, []);
|
|
14637
|
-
}
|
|
14638
|
-
partsPerLine.get(lineIdx).push(transformedParts[i]);
|
|
14639
|
-
}
|
|
14640
|
-
const result = [];
|
|
14641
|
-
for (let i = 0; i < lineMetadata.length; i++) {
|
|
14642
|
-
const meta = lineMetadata[i];
|
|
14643
|
-
const indent = normalizedIndents[i];
|
|
14644
|
-
if (meta.isBlank) {
|
|
14645
|
-
result.push("");
|
|
14646
|
-
} else {
|
|
14647
|
-
const lineParts = partsPerLine.get(i) || [];
|
|
14648
|
-
if (lineParts.length > 0) {
|
|
14649
|
-
const lineContent = lineParts.join(` ${targetThen} `);
|
|
14650
|
-
result.push(indent + lineContent);
|
|
14651
|
-
}
|
|
14652
|
-
}
|
|
14653
|
-
}
|
|
14654
|
-
return result.join("\n");
|
|
14655
|
-
}
|
|
14656
|
-
var BOUNDARY_MODIFIERS = /* @__PURE__ */ new Set([
|
|
14657
|
-
"to",
|
|
14658
|
-
"into",
|
|
14659
|
-
"from",
|
|
14660
|
-
"with",
|
|
14661
|
-
"by",
|
|
14662
|
-
"as",
|
|
14663
|
-
"at",
|
|
14664
|
-
"in",
|
|
14665
|
-
"on",
|
|
14666
|
-
"of",
|
|
14667
|
-
"over"
|
|
14668
|
-
]);
|
|
14669
|
-
var boundaryModifiersCache = /* @__PURE__ */ new Map();
|
|
14670
|
-
function getBoundaryModifiersForLocale(locale) {
|
|
14671
|
-
const cached = boundaryModifiersCache.get(locale);
|
|
14672
|
-
if (cached) return cached;
|
|
14673
|
-
const modifiers = new Set(BOUNDARY_MODIFIERS);
|
|
14674
|
-
const profile = getProfile(locale);
|
|
14675
|
-
profile?.markers.forEach((marker) => {
|
|
14676
|
-
const form = marker.form.replace(/^-|-$/g, "").toLowerCase();
|
|
14677
|
-
if (form) modifiers.add(form);
|
|
14678
|
-
marker.alternatives?.forEach((alt) => {
|
|
14679
|
-
const altForm = alt.replace(/^-|-$/g, "").toLowerCase();
|
|
14680
|
-
if (altForm) modifiers.add(altForm);
|
|
14681
|
-
});
|
|
14682
|
-
});
|
|
14683
|
-
boundaryModifiersCache.set(locale, modifiers);
|
|
14684
|
-
return modifiers;
|
|
14685
|
-
}
|
|
14686
|
-
var ON_TARGET_COMMANDS = /* @__PURE__ */ new Set(["toggle", "add", "remove", "trigger", "send"]);
|
|
14687
|
-
function commandVerbOf(tokens, commandKeywords) {
|
|
14688
|
-
for (const token of tokens) {
|
|
14689
|
-
const lt = token.toLowerCase();
|
|
14690
|
-
if (commandKeywords.has(lt) && !BOUNDARY_MODIFIERS.has(lt) && !EVENT_KEYWORDS.has(lt)) {
|
|
14691
|
-
return lt;
|
|
14692
|
-
}
|
|
14693
|
-
}
|
|
14694
|
-
return null;
|
|
14695
|
-
}
|
|
14696
|
-
var BLOCK_HEAD_KEYWORDS = /* @__PURE__ */ new Set(["live", "when", "unless"]);
|
|
14697
|
-
var BLOCK_BODY_KEYWORDS = /* @__PURE__ */ new Set(["if", "repeat", "unless", "while", "for"]);
|
|
14698
|
-
var UNLESS_GUARD_OBJECT_MARKING_LOCALES = /* @__PURE__ */ new Set(["he", "zh"]);
|
|
14699
|
-
function splitOnCommandBoundaries(input, sourceLocale) {
|
|
14700
|
-
const commandKeywords = getCommandKeywordsForLocale(sourceLocale);
|
|
14701
|
-
const boundaryModifiers = getBoundaryModifiersForLocale(sourceLocale);
|
|
14702
|
-
const { forWords, inWords } = getForLoopWordsForLocale(sourceLocale);
|
|
14703
|
-
const tokens = input.split(/\s+/);
|
|
14704
|
-
if (tokens.length === 0) return [input];
|
|
14705
|
-
const parts = [];
|
|
14706
|
-
let currentPart = [];
|
|
14707
|
-
const firstTokenLower = tokens[0]?.toLowerCase();
|
|
14708
|
-
const isEventHandler = EVENT_KEYWORDS.has(firstTokenLower);
|
|
14709
|
-
let seenFirstCommand = !isEventHandler;
|
|
14710
|
-
let blockDepth = 0;
|
|
14711
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
14712
|
-
const token = tokens[i];
|
|
14713
|
-
const lowerToken = token.toLowerCase();
|
|
14714
|
-
if (BLOCK_HEAD_KEYWORDS.has(lowerToken)) {
|
|
14715
|
-
blockDepth++;
|
|
14716
|
-
} else if (lowerToken === "end" && blockDepth > 0) {
|
|
14717
|
-
blockDepth--;
|
|
14718
|
-
}
|
|
14719
|
-
if (commandKeywords.has(lowerToken) && currentPart.length > 0) {
|
|
14720
|
-
const prevToken = currentPart[currentPart.length - 1];
|
|
14721
|
-
const prevLower = prevToken.toLowerCase();
|
|
14722
|
-
if (!seenFirstCommand) {
|
|
14723
|
-
seenFirstCommand = true;
|
|
14724
|
-
currentPart.push(token);
|
|
14725
|
-
continue;
|
|
14726
|
-
}
|
|
14727
|
-
if (blockDepth > 0) {
|
|
14728
|
-
currentPart.push(token);
|
|
14729
|
-
continue;
|
|
14730
|
-
}
|
|
14731
|
-
if (forWords.has(lowerToken) && !isLoopHeadFor(tokens, i, inWords, commandKeywords)) {
|
|
14732
|
-
currentPart.push(token);
|
|
14733
|
-
continue;
|
|
14734
|
-
}
|
|
14735
|
-
if (BOUNDARY_MODIFIERS.has(lowerToken)) {
|
|
14736
|
-
const verb = commandVerbOf(currentPart, commandKeywords);
|
|
14737
|
-
if (verb && ON_TARGET_COMMANDS.has(verb)) {
|
|
14738
|
-
currentPart.push(token);
|
|
14739
|
-
continue;
|
|
14740
|
-
}
|
|
14741
|
-
if (lowerToken === "on" && verb === "set") {
|
|
14742
|
-
const nextTok = tokens[i + 1];
|
|
14743
|
-
const nextLower = nextTok?.toLowerCase();
|
|
14744
|
-
const scopeLike = !!nextTok && (/^[#.<@[]/.test(nextTok) || nextLower === "me" || nextLower === "it" || nextLower === "you");
|
|
14745
|
-
if (scopeLike) {
|
|
14746
|
-
currentPart.push(token);
|
|
14747
|
-
continue;
|
|
14748
|
-
}
|
|
14749
|
-
}
|
|
14750
|
-
}
|
|
14751
|
-
if (!boundaryModifiers.has(prevLower) && !commandKeywords.has(prevLower)) {
|
|
14752
|
-
parts.push(currentPart.join(" "));
|
|
14753
|
-
currentPart = [token];
|
|
14754
|
-
continue;
|
|
14755
|
-
}
|
|
14756
|
-
}
|
|
14757
|
-
currentPart.push(token);
|
|
14758
|
-
}
|
|
14759
|
-
if (currentPart.length > 0) {
|
|
14760
|
-
parts.push(currentPart.join(" "));
|
|
14761
|
-
}
|
|
14762
|
-
return parts.filter((p) => p.length > 0);
|
|
14763
|
-
}
|
|
14764
|
-
function splitOnThen(input, sourceLocale) {
|
|
14765
|
-
const thenKeywords = Array.from(THEN_KEYWORDS);
|
|
14766
|
-
const sourceDict = sourceLocale === "en" ? null : dictionaries[sourceLocale];
|
|
14767
|
-
if (sourceDict?.modifiers?.then) {
|
|
14768
|
-
thenKeywords.push(sourceDict.modifiers.then);
|
|
14769
|
-
}
|
|
14770
|
-
if (sourceDict?.logical?.then) {
|
|
14771
|
-
thenKeywords.push((sourceDict?.logical).then);
|
|
14772
|
-
}
|
|
14773
|
-
const escapedKeywords = thenKeywords.map((k) => k.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
14774
|
-
const pattern = new RegExp(`\\s+(${escapedKeywords.join("|")})\\s+`, "gi");
|
|
14775
|
-
const parts = input.split(pattern).filter((part) => {
|
|
14776
|
-
const lowerPart = part.toLowerCase().trim();
|
|
14777
|
-
return lowerPart && !thenKeywords.some((k) => k.toLowerCase() === lowerPart);
|
|
14778
|
-
});
|
|
14779
|
-
return parts.map((p) => p.trim()).filter((p) => p.length > 0);
|
|
14780
|
-
}
|
|
14781
|
-
function getTargetThenKeyword(targetLocale) {
|
|
14782
|
-
if (targetLocale === "en") return "then";
|
|
14783
|
-
const targetDict = dictionaries[targetLocale];
|
|
14784
|
-
if (!targetDict) return "then";
|
|
14785
|
-
return targetDict.modifiers?.then || targetDict.logical?.then || "then";
|
|
14786
|
-
}
|
|
14787
|
-
function deriveEventKeywordsFromProfiles() {
|
|
14788
|
-
const keywords = /* @__PURE__ */ new Set();
|
|
14789
|
-
keywords.add("on");
|
|
14790
|
-
for (const profile of Object.values(profiles)) {
|
|
14791
|
-
for (const marker of profile.markers) {
|
|
14792
|
-
if (marker.role === "event") {
|
|
14793
|
-
const form = marker.form.replace(/^-|-$/g, "").toLowerCase();
|
|
14794
|
-
if (form) keywords.add(form);
|
|
14795
|
-
marker.alternatives?.forEach((alt) => {
|
|
14796
|
-
const altForm = alt.replace(/^-|-$/g, "").toLowerCase();
|
|
14797
|
-
if (altForm) keywords.add(altForm);
|
|
14798
|
-
});
|
|
14799
|
-
}
|
|
14800
|
-
}
|
|
14801
|
-
}
|
|
14802
|
-
return keywords;
|
|
14803
|
-
}
|
|
14804
|
-
var EVENT_KEYWORDS = deriveEventKeywordsFromProfiles();
|
|
14805
|
-
var EVENT_CONJUNCTIONS = /* @__PURE__ */ new Set(["or"]);
|
|
14806
|
-
var BODY_MODIFIER_KEYWORDS = /* @__PURE__ */ new Set([
|
|
14807
|
-
"async",
|
|
14808
|
-
"once",
|
|
14809
|
-
"debounced",
|
|
14810
|
-
"debounce",
|
|
14811
|
-
"throttled",
|
|
14812
|
-
"throttle"
|
|
14813
|
-
]);
|
|
14814
|
-
function generateModifierMap(profile) {
|
|
14815
|
-
const map = {};
|
|
14816
|
-
profile.markers.forEach((marker) => {
|
|
14817
|
-
const form = marker.form.replace(/^-|-$/g, "").toLowerCase();
|
|
14818
|
-
if (form) {
|
|
14819
|
-
map[form] = marker.role;
|
|
14820
|
-
}
|
|
14821
|
-
marker.alternatives?.forEach((alt) => {
|
|
14822
|
-
const altForm = alt.replace(/^-|-$/g, "").toLowerCase();
|
|
14823
|
-
if (altForm) {
|
|
14824
|
-
map[altForm] = marker.role;
|
|
14825
|
-
}
|
|
14826
|
-
});
|
|
14827
|
-
});
|
|
14828
|
-
for (const [key, role] of Object.entries(ENGLISH_MODIFIER_ROLES)) {
|
|
14829
|
-
if (!(key in map)) {
|
|
14830
|
-
map[key] = role;
|
|
14831
|
-
}
|
|
14832
|
-
}
|
|
14833
|
-
return map;
|
|
14834
|
-
}
|
|
14835
|
-
function buildArgumentModifierMap(profile, actionVerb) {
|
|
14836
|
-
const map = generateModifierMap(profile);
|
|
14837
|
-
const verb = actionVerb?.toLowerCase();
|
|
14838
|
-
if (profile.wordOrder !== "SVO" || !verb || !ON_TARGET_COMMANDS.has(verb)) {
|
|
14839
|
-
return map;
|
|
14840
|
-
}
|
|
14841
|
-
const remapped = {};
|
|
14842
|
-
for (const [form, role] of Object.entries(map)) {
|
|
14843
|
-
remapped[form] = role === "event" ? "destination" : role;
|
|
14844
|
-
}
|
|
14845
|
-
return remapped;
|
|
14846
|
-
}
|
|
14847
|
-
function parseStatement(input, sourceLocale = "en") {
|
|
14848
|
-
const profile = getProfile(sourceLocale);
|
|
14849
|
-
if (!profile) return null;
|
|
14850
|
-
const tokens = tokenize2(input, profile);
|
|
14851
|
-
const statementType = identifyStatementType(tokens, profile);
|
|
14852
|
-
switch (statementType) {
|
|
14853
|
-
case "event-handler":
|
|
14854
|
-
return parseEventHandler(tokens, profile);
|
|
14855
|
-
case "command":
|
|
14856
|
-
return parseCommand(tokens, profile);
|
|
14857
|
-
case "conditional":
|
|
14858
|
-
return parseConditional(tokens);
|
|
14859
|
-
default:
|
|
14860
|
-
return null;
|
|
14861
|
-
}
|
|
14862
|
-
}
|
|
14863
|
-
var ATTACHED_SUFFIXES = {
|
|
14864
|
-
// Chinese: 时 (time/when) often attaches to events like 点击时 (when clicking)
|
|
14865
|
-
zh: ["\u65F6", "\u7684", "\u5730", "\u5F97"],
|
|
14866
|
-
// Japanese: Some particles may attach in casual writing
|
|
14867
|
-
ja: [],
|
|
14868
|
-
// Korean: Particles sometimes written without spaces
|
|
14869
|
-
ko: []
|
|
14870
|
-
};
|
|
14871
|
-
var ATTACHED_PREFIXES = {
|
|
14872
|
-
// Chinese: 当 (when) sometimes written attached
|
|
14873
|
-
zh: ["\u5F53"],
|
|
14874
|
-
// Arabic: Prepositions that attach
|
|
14875
|
-
ar: ["\u0628\u0640", "\u0643\u0640", "\u0648"]
|
|
14876
|
-
};
|
|
14877
|
-
function splitAttachedAffixes(tokens, locale) {
|
|
14878
|
-
const suffixes = ATTACHED_SUFFIXES[locale] || [];
|
|
14879
|
-
const prefixes = ATTACHED_PREFIXES[locale] || [];
|
|
14880
|
-
if (suffixes.length === 0 && prefixes.length === 0) {
|
|
14881
|
-
return tokens;
|
|
14882
|
-
}
|
|
14883
|
-
const result = [];
|
|
14884
|
-
for (const token of tokens) {
|
|
14885
|
-
if (/^[#.<@]/.test(token) || /^\d+/.test(token)) {
|
|
14886
|
-
result.push(token);
|
|
14887
|
-
continue;
|
|
14888
|
-
}
|
|
14889
|
-
let processed = token;
|
|
14890
|
-
let prefix = "";
|
|
14891
|
-
let suffix = "";
|
|
14892
|
-
for (const p of prefixes) {
|
|
14893
|
-
if (processed.startsWith(p) && processed.length > p.length) {
|
|
14894
|
-
prefix = p;
|
|
14895
|
-
processed = processed.slice(p.length);
|
|
14896
|
-
break;
|
|
14897
|
-
}
|
|
14898
|
-
}
|
|
14899
|
-
for (const s of suffixes) {
|
|
14900
|
-
if (processed.endsWith(s) && processed.length > s.length) {
|
|
14901
|
-
suffix = s;
|
|
14902
|
-
processed = processed.slice(0, -s.length);
|
|
14903
|
-
break;
|
|
14904
|
-
}
|
|
14905
|
-
}
|
|
14906
|
-
if (prefix) result.push(prefix);
|
|
14907
|
-
if (processed) result.push(processed);
|
|
14908
|
-
if (suffix) result.push(suffix);
|
|
14909
|
-
}
|
|
14910
|
-
return result;
|
|
14911
|
-
}
|
|
14912
|
-
function tokenize2(input, profile) {
|
|
14913
|
-
const tokens = [];
|
|
14914
|
-
let current = "";
|
|
14915
|
-
let inSelector = false;
|
|
14916
|
-
let selectorDepth = 0;
|
|
14917
|
-
let bracketDepth = 0;
|
|
14918
|
-
let parenDepth = 0;
|
|
14919
|
-
for (let i = 0; i < input.length; i++) {
|
|
14920
|
-
const char = input[i];
|
|
14921
|
-
if (char === "<") {
|
|
14922
|
-
inSelector = true;
|
|
14923
|
-
selectorDepth++;
|
|
14924
|
-
} else if (char === ">" && inSelector) {
|
|
14925
|
-
selectorDepth--;
|
|
14926
|
-
if (selectorDepth === 0) inSelector = false;
|
|
14927
|
-
}
|
|
14928
|
-
if (char === "[") {
|
|
14929
|
-
bracketDepth++;
|
|
14930
|
-
} else if (char === "]" && bracketDepth > 0) {
|
|
14931
|
-
bracketDepth--;
|
|
14932
|
-
}
|
|
14933
|
-
if (char === "(") {
|
|
14934
|
-
parenDepth++;
|
|
14935
|
-
} else if (char === ")" && parenDepth > 0) {
|
|
14936
|
-
parenDepth--;
|
|
14937
|
-
}
|
|
14938
|
-
if (/\s/.test(char) && !inSelector && bracketDepth === 0 && parenDepth === 0) {
|
|
14939
|
-
if (current) {
|
|
14940
|
-
tokens.push(current);
|
|
14941
|
-
current = "";
|
|
14942
|
-
}
|
|
14943
|
-
} else {
|
|
14944
|
-
current += char;
|
|
14945
|
-
}
|
|
14946
|
-
}
|
|
14947
|
-
if (current) {
|
|
14948
|
-
tokens.push(current);
|
|
14949
|
-
}
|
|
14950
|
-
return splitAttachedAffixes(tokens, profile.code);
|
|
14951
|
-
}
|
|
14952
|
-
function identifyStatementType(tokens, profile) {
|
|
14953
|
-
if (tokens.length === 0) return "unknown";
|
|
14954
|
-
const firstToken = tokens[0].toLowerCase();
|
|
14955
|
-
const eventMarker = profile.markers.find((m) => m.role === "event" && m.position === "preposition");
|
|
14956
|
-
if (eventMarker && firstToken === eventMarker.form.toLowerCase()) {
|
|
14957
|
-
return "event-handler";
|
|
14958
|
-
}
|
|
14959
|
-
if (EVENT_KEYWORDS.has(firstToken)) {
|
|
14960
|
-
return "event-handler";
|
|
14961
|
-
}
|
|
14962
|
-
if (CONDITIONAL_KEYWORDS.has(firstToken)) {
|
|
14963
|
-
return "conditional";
|
|
14964
|
-
}
|
|
14965
|
-
return "command";
|
|
14966
|
-
}
|
|
14967
|
-
function parseEventHandler(tokens, profile) {
|
|
14968
|
-
const roles = /* @__PURE__ */ new Map();
|
|
14969
|
-
let startIndex = EVENT_KEYWORDS.has(tokens[0]?.toLowerCase()) ? 1 : 0;
|
|
14970
|
-
if (tokens[startIndex]) {
|
|
14971
|
-
const eventTokens = [tokens[startIndex]];
|
|
14972
|
-
startIndex++;
|
|
14973
|
-
while (tokens[startIndex] && EVENT_CONJUNCTIONS.has(tokens[startIndex].toLowerCase()) && tokens[startIndex + 1]) {
|
|
14974
|
-
eventTokens.push(tokens[startIndex], tokens[startIndex + 1]);
|
|
14975
|
-
startIndex += 2;
|
|
14976
|
-
}
|
|
14977
|
-
roles.set("event", {
|
|
14978
|
-
role: "event",
|
|
14979
|
-
value: eventTokens.join(" ")
|
|
14980
|
-
});
|
|
14981
|
-
}
|
|
14982
|
-
if (tokens[startIndex] && tokens[startIndex].toLowerCase() === "from" && tokens[startIndex + 1]) {
|
|
14983
|
-
startIndex++;
|
|
14984
|
-
const sourceValue = [];
|
|
14985
|
-
while (tokens[startIndex]) {
|
|
14986
|
-
if (ENGLISH_COMMANDS.has(tokens[startIndex].toLowerCase())) break;
|
|
14987
|
-
sourceValue.push(tokens[startIndex]);
|
|
14988
|
-
startIndex++;
|
|
14989
|
-
}
|
|
14990
|
-
if (sourceValue.length > 0) {
|
|
14991
|
-
const value = sourceValue.join(" ");
|
|
14992
|
-
roles.set("source", {
|
|
14993
|
-
role: "source",
|
|
14994
|
-
value,
|
|
14995
|
-
isSelector: /^[#.<@]/.test(value)
|
|
14996
|
-
});
|
|
14997
|
-
}
|
|
14998
|
-
}
|
|
14999
|
-
if (tokens[startIndex]) {
|
|
15000
|
-
roles.set("action", {
|
|
15001
|
-
role: "action",
|
|
15002
|
-
value: tokens[startIndex]
|
|
15003
|
-
});
|
|
15004
|
-
startIndex++;
|
|
15005
|
-
}
|
|
15006
|
-
if (tokens[startIndex]) {
|
|
15007
|
-
const modifierMap = buildArgumentModifierMap(profile, roles.get("action")?.value);
|
|
15008
|
-
let currentRole = "patient";
|
|
15009
|
-
let currentValue = [];
|
|
15010
|
-
for (let i = startIndex; i < tokens.length; i++) {
|
|
15011
|
-
const token = tokens[i];
|
|
15012
|
-
const mappedRole = modifierMap[token.toLowerCase()];
|
|
15013
|
-
if (mappedRole) {
|
|
15014
|
-
if (currentValue.length > 0) {
|
|
15015
|
-
const value = currentValue.join(" ");
|
|
15016
|
-
roles.set(currentRole, {
|
|
15017
|
-
role: currentRole,
|
|
15018
|
-
value,
|
|
15019
|
-
isSelector: /^[#.<@]/.test(value)
|
|
15020
|
-
});
|
|
15021
|
-
}
|
|
15022
|
-
currentRole = mappedRole;
|
|
15023
|
-
currentValue = [];
|
|
15024
|
-
} else {
|
|
15025
|
-
currentValue.push(token);
|
|
15026
|
-
}
|
|
15027
|
-
}
|
|
15028
|
-
if (currentValue.length > 0) {
|
|
15029
|
-
const value = currentValue.join(" ");
|
|
15030
|
-
roles.set(currentRole, {
|
|
15031
|
-
role: currentRole,
|
|
15032
|
-
value,
|
|
15033
|
-
isSelector: /^[#.<@]/.test(value)
|
|
15034
|
-
});
|
|
15035
|
-
}
|
|
15036
|
-
}
|
|
15037
|
-
return {
|
|
15038
|
-
type: "event-handler",
|
|
15039
|
-
roles,
|
|
15040
|
-
original: tokens.join(" ")
|
|
15041
|
-
};
|
|
15042
|
-
}
|
|
15043
|
-
function parseCommand(tokens, profile) {
|
|
15044
|
-
const roles = /* @__PURE__ */ new Map();
|
|
15045
|
-
if (tokens.length === 0) {
|
|
15046
|
-
return { type: "command", roles, original: "" };
|
|
15047
|
-
}
|
|
15048
|
-
roles.set("action", {
|
|
15049
|
-
role: "action",
|
|
15050
|
-
value: tokens[0]
|
|
15051
|
-
});
|
|
15052
|
-
const modifierMap = buildArgumentModifierMap(profile, tokens[0]);
|
|
15053
|
-
let currentRole = "patient";
|
|
15054
|
-
let currentValue = [];
|
|
15055
|
-
for (let i = 1; i < tokens.length; i++) {
|
|
15056
|
-
const token = tokens[i];
|
|
15057
|
-
const mappedRole = modifierMap[token.toLowerCase()];
|
|
15058
|
-
if (mappedRole) {
|
|
15059
|
-
if (currentValue.length > 0) {
|
|
15060
|
-
const value = currentValue.join(" ");
|
|
15061
|
-
roles.set(currentRole, {
|
|
15062
|
-
role: currentRole,
|
|
15063
|
-
value,
|
|
15064
|
-
isSelector: /^[#.<@]/.test(value)
|
|
15065
|
-
});
|
|
15066
|
-
}
|
|
15067
|
-
currentRole = mappedRole;
|
|
15068
|
-
currentValue = [];
|
|
15069
|
-
} else {
|
|
15070
|
-
currentValue.push(token);
|
|
15071
|
-
}
|
|
15072
|
-
}
|
|
15073
|
-
if (currentValue.length > 0) {
|
|
15074
|
-
const value = currentValue.join(" ");
|
|
15075
|
-
roles.set(currentRole, {
|
|
15076
|
-
role: currentRole,
|
|
15077
|
-
value,
|
|
15078
|
-
isSelector: /^[#.<@]/.test(value)
|
|
15079
|
-
});
|
|
15080
|
-
}
|
|
15081
|
-
return {
|
|
15082
|
-
type: "command",
|
|
15083
|
-
roles,
|
|
15084
|
-
original: tokens.join(" ")
|
|
15085
|
-
};
|
|
15086
|
-
}
|
|
15087
|
-
var LITERAL_PRIMARY_ROLES = /* @__PURE__ */ new Set([
|
|
15088
|
-
"duration",
|
|
15089
|
-
"quantity"
|
|
15090
|
-
]);
|
|
15091
|
-
function applyPrimaryRole(parsed, targetProfile) {
|
|
15092
|
-
if (parsed.type !== "command") return;
|
|
15093
|
-
const action = parsed.roles.get("action")?.value;
|
|
15094
|
-
if (!action) return;
|
|
15095
|
-
const primaryRole = COMMAND_PRIMARY_ROLES[action.toLowerCase()];
|
|
15096
|
-
if (!primaryRole || !LITERAL_PRIMARY_ROLES.has(primaryRole)) return;
|
|
15097
|
-
const patientEl = parsed.roles.get("patient");
|
|
15098
|
-
if (!patientEl || parsed.roles.has(primaryRole)) return;
|
|
15099
|
-
if (targetProfile.markers.some((m) => m.role === primaryRole)) return;
|
|
15100
|
-
parsed.roles.delete("patient");
|
|
15101
|
-
parsed.roles.set(primaryRole, { ...patientEl, role: primaryRole });
|
|
15102
|
-
}
|
|
15103
|
-
function parseConditional(tokens, _profile) {
|
|
15104
|
-
const roles = /* @__PURE__ */ new Map();
|
|
15105
|
-
roles.set("action", {
|
|
15106
|
-
role: "action",
|
|
15107
|
-
value: tokens[0]
|
|
15108
|
-
});
|
|
15109
|
-
const thenIndex = tokens.findIndex((t) => THEN_KEYWORDS.has(t.toLowerCase()));
|
|
15110
|
-
if (thenIndex > 1) {
|
|
15111
|
-
const conditionValue = tokens.slice(1, thenIndex).join(" ");
|
|
15112
|
-
roles.set("condition", {
|
|
15113
|
-
role: "condition",
|
|
15114
|
-
value: conditionValue
|
|
15115
|
-
});
|
|
15116
|
-
} else if (thenIndex === -1 && tokens.length > 1) {
|
|
15117
|
-
roles.set("condition", {
|
|
15118
|
-
role: "condition",
|
|
15119
|
-
value: tokens.slice(1).join(" ")
|
|
15120
|
-
});
|
|
15121
|
-
}
|
|
15122
|
-
return {
|
|
15123
|
-
type: "conditional",
|
|
15124
|
-
roles,
|
|
15125
|
-
original: tokens.join(" ")
|
|
15126
|
-
};
|
|
15127
|
-
}
|
|
15128
|
-
function translateWord(word, sourceLocale, targetLocale) {
|
|
15129
|
-
if (/^[#.<@]/.test(word)) {
|
|
15130
|
-
return word;
|
|
15131
|
-
}
|
|
15132
|
-
if (/^\d+/.test(word)) {
|
|
15133
|
-
return word;
|
|
15134
|
-
}
|
|
15135
|
-
if (/\s/.test(word) && word.startsWith("(")) {
|
|
15136
|
-
return word.split(/\s+/).map((w) => translateWord(w, sourceLocale, targetLocale)).join(" ");
|
|
15137
|
-
}
|
|
15138
|
-
if (word.length > 1 && (word.startsWith("(") || word.endsWith(")"))) {
|
|
15139
|
-
const m = word.match(/^(\(*)([^()]+)(\)*)$/);
|
|
15140
|
-
if (m && (m[1] || m[3])) {
|
|
15141
|
-
return m[1] + translateWord(m[2], sourceLocale, targetLocale) + m[3];
|
|
15142
|
-
}
|
|
15143
|
-
}
|
|
15144
|
-
const sourceDict = sourceLocale === "en" ? null : dictionaries[sourceLocale];
|
|
15145
|
-
const targetDict = dictionaries[targetLocale];
|
|
15146
|
-
if (!targetDict) return word;
|
|
15147
|
-
let englishWord = word;
|
|
15148
|
-
if (sourceDict) {
|
|
15149
|
-
const found = findInDictionary(sourceDict, word);
|
|
15150
|
-
if (found) {
|
|
15151
|
-
englishWord = found.englishKey;
|
|
15152
|
-
}
|
|
15153
|
-
}
|
|
15154
|
-
const translated = translateFromEnglish(targetDict, englishWord);
|
|
15155
|
-
return translated ?? word;
|
|
15156
|
-
}
|
|
15157
|
-
var POSSESSIVE_MARKERS = {
|
|
15158
|
-
en: { type: "suffix", marker: "'s" },
|
|
15159
|
-
es: { type: "preposition", marker: "de" },
|
|
15160
|
-
pt: { type: "preposition", marker: "de" },
|
|
15161
|
-
fr: { type: "preposition", marker: "de" },
|
|
15162
|
-
de: { type: "preposition", marker: "von" },
|
|
15163
|
-
ja: { type: "suffix", marker: "\u306E" },
|
|
15164
|
-
ko: { type: "suffix", marker: "\uC758" },
|
|
15165
|
-
zh: { type: "suffix", marker: "\u7684" },
|
|
15166
|
-
ar: { type: "preposition", marker: "\u0644\u0640" },
|
|
15167
|
-
// Spaced genitive particle (not the glued `'ın`), so the tokenizer can split
|
|
15168
|
-
// it off the selector — consistent with Turkish's other spaced case markers.
|
|
15169
|
-
tr: { type: "particle", marker: "\u0131n" },
|
|
15170
|
-
id: { type: "preposition", marker: "dari" },
|
|
15171
|
-
// Latin-script genitive: must be a *spaced* particle (`#picker pa`), since a
|
|
15172
|
-
// glued `#pickerpa` can't be split from the selector by the tokenizer the
|
|
15173
|
-
// way a non-Latin suffix (の/의/র) can.
|
|
15174
|
-
qu: { type: "particle", marker: "pa" },
|
|
15175
|
-
// Bengali SOV postposition genitive, like ja/ko — a spaced suffix the
|
|
15176
|
-
// tokenizer splits off as a particle. Previously absent, so it fell back to
|
|
15177
|
-
// the English `'s` marker and its possessive property paths never parsed.
|
|
15178
|
-
// (Hindi `का` is intentionally omitted: its `bind` lacks a verb-final
|
|
15179
|
-
// grammar rule, so fixing its possessive alone yields a wrong `on` parse —
|
|
15180
|
-
// tracked as separate follow-up.)
|
|
15181
|
-
bn: { type: "suffix", marker: "\u09B0" },
|
|
15182
|
-
sw: { type: "preposition", marker: "ya" }
|
|
15183
|
-
};
|
|
15184
|
-
function translatePossessive(token, sourceLocale, targetLocale) {
|
|
15185
|
-
const possessiveMatch = token.match(/^(.+)'s$/i);
|
|
15186
|
-
if (!possessiveMatch) {
|
|
15187
|
-
return token;
|
|
15188
|
-
}
|
|
15189
|
-
const owner = possessiveMatch[1];
|
|
15190
|
-
const targetMarker = POSSESSIVE_MARKERS[targetLocale] || POSSESSIVE_MARKERS.en;
|
|
15191
|
-
const pronounPossessives = {
|
|
15192
|
-
me: "my",
|
|
15193
|
-
it: "its",
|
|
15194
|
-
you: "your"
|
|
15195
|
-
};
|
|
15196
|
-
const lowerOwner = owner.toLowerCase();
|
|
15197
|
-
if (pronounPossessives[lowerOwner]) {
|
|
15198
|
-
const possessiveForm = pronounPossessives[lowerOwner];
|
|
15199
|
-
return translateWord(possessiveForm, "en", targetLocale);
|
|
15200
|
-
}
|
|
15201
|
-
const translatedOwner = translateWord(owner, sourceLocale, targetLocale);
|
|
15202
|
-
switch (targetMarker.type) {
|
|
15203
|
-
case "suffix":
|
|
15204
|
-
return `${translatedOwner}${targetMarker.marker}`;
|
|
15205
|
-
case "particle":
|
|
15206
|
-
return `${translatedOwner} ${targetMarker.marker}`;
|
|
15207
|
-
case "preposition":
|
|
15208
|
-
return `__POSS__${targetMarker.marker}__${translatedOwner}__POSS__`;
|
|
15209
|
-
default:
|
|
15210
|
-
return `${translatedOwner}'s`;
|
|
15211
|
-
}
|
|
15212
|
-
}
|
|
15213
|
-
var POSSESSIVE_DOT_REGEX = /^(my|its|your|me|it|you)(\??\..+)$/i;
|
|
15214
|
-
var POSSESSIVE_DOT_PRONOUNS = {
|
|
15215
|
-
me: "my",
|
|
15216
|
-
it: "its",
|
|
15217
|
-
you: "your",
|
|
15218
|
-
my: "my",
|
|
15219
|
-
its: "its",
|
|
15220
|
-
your: "your"
|
|
15221
|
-
};
|
|
15222
|
-
function translatePossessiveDotNotation(value, sourceLocale, targetLocale) {
|
|
15223
|
-
const match = value.match(POSSESSIVE_DOT_REGEX);
|
|
15224
|
-
if (!match) return null;
|
|
15225
|
-
const possessiveWord = match[1].toLowerCase();
|
|
15226
|
-
const propertySuffix = match[2];
|
|
15227
|
-
const possessiveKey = POSSESSIVE_DOT_PRONOUNS[possessiveWord] || possessiveWord;
|
|
15228
|
-
const translated = translateWord(possessiveKey, sourceLocale, targetLocale);
|
|
15229
|
-
if (translated.includes(" ")) return null;
|
|
15230
|
-
if (translated !== possessiveKey) {
|
|
15231
|
-
return translated + propertySuffix;
|
|
15232
|
-
}
|
|
15233
|
-
if (possessiveWord !== possessiveKey) {
|
|
15234
|
-
const alt = translateWord(possessiveWord, sourceLocale, targetLocale);
|
|
15235
|
-
if (alt !== possessiveWord && !alt.includes(" ")) {
|
|
15236
|
-
return alt + propertySuffix;
|
|
15237
|
-
}
|
|
15238
|
-
}
|
|
15239
|
-
return null;
|
|
15240
|
-
}
|
|
15241
|
-
function translateMultiWordValue(value, sourceLocale, targetLocale) {
|
|
15242
|
-
if (value.includes("[")) {
|
|
15243
|
-
const guards = [];
|
|
15244
|
-
const masked = value.replace(/\[[^\]]*\]/g, (match) => {
|
|
15245
|
-
guards.push(match);
|
|
15246
|
-
return `\uE000${guards.length - 1}\uE001`;
|
|
15247
|
-
});
|
|
15248
|
-
if (guards.length > 0) {
|
|
15249
|
-
const translated2 = translateMultiWordValue(masked, sourceLocale, targetLocale);
|
|
15250
|
-
return translated2.replace(/(\d+)/g, (_, n) => guards[Number(n)]);
|
|
15251
|
-
}
|
|
15252
|
-
}
|
|
15253
|
-
if (!value.includes(" ")) {
|
|
15254
|
-
if (value.includes("'s")) {
|
|
15255
|
-
return translatePossessive(value, sourceLocale, targetLocale);
|
|
15256
|
-
}
|
|
15257
|
-
const dotResult = translatePossessiveDotNotation(value, sourceLocale, targetLocale);
|
|
15258
|
-
if (dotResult !== null) return dotResult;
|
|
15259
|
-
return translateWord(value, sourceLocale, targetLocale);
|
|
15260
|
-
}
|
|
15261
|
-
const words = value.split(/\s+/);
|
|
15262
|
-
const translated = [];
|
|
15263
|
-
let i = 0;
|
|
15264
|
-
while (i < words.length) {
|
|
15265
|
-
const word = words[i];
|
|
15266
|
-
if (word.includes("'s")) {
|
|
15267
|
-
const possessiveResult = translatePossessive(word, sourceLocale, targetLocale);
|
|
15268
|
-
const prepMatch = possessiveResult.match(/^__POSS__(.+)__(.+)__POSS__$/);
|
|
15269
|
-
if (prepMatch && i + 1 < words.length) {
|
|
15270
|
-
const marker = prepMatch[1];
|
|
15271
|
-
const owner = prepMatch[2];
|
|
15272
|
-
const property = words[i + 1];
|
|
15273
|
-
const translatedProperty = translateWord(property, sourceLocale, targetLocale);
|
|
15274
|
-
translated.push(`${translatedProperty} ${marker} ${owner}`);
|
|
15275
|
-
i += 2;
|
|
15276
|
-
continue;
|
|
15277
|
-
} else if (prepMatch) {
|
|
15278
|
-
const marker = prepMatch[1];
|
|
15279
|
-
const owner = prepMatch[2];
|
|
15280
|
-
translated.push(`${marker} ${owner}`);
|
|
15281
|
-
i++;
|
|
15282
|
-
continue;
|
|
15283
|
-
}
|
|
15284
|
-
translated.push(possessiveResult);
|
|
15285
|
-
i++;
|
|
15286
|
-
continue;
|
|
15287
|
-
}
|
|
15288
|
-
if (/^[#.<@]/.test(word) || /^\d+/.test(word)) {
|
|
15289
|
-
translated.push(word);
|
|
15290
|
-
i++;
|
|
15291
|
-
continue;
|
|
15292
|
-
}
|
|
15293
|
-
if (/^["'].*["']$/.test(word)) {
|
|
15294
|
-
translated.push(word);
|
|
15295
|
-
i++;
|
|
15296
|
-
continue;
|
|
15297
|
-
}
|
|
15298
|
-
const dotResult = translatePossessiveDotNotation(word, sourceLocale, targetLocale);
|
|
15299
|
-
if (dotResult !== null) {
|
|
15300
|
-
translated.push(dotResult);
|
|
15301
|
-
i++;
|
|
15302
|
-
continue;
|
|
15303
|
-
}
|
|
15304
|
-
translated.push(translateWord(word, sourceLocale, targetLocale));
|
|
15305
|
-
i++;
|
|
15306
|
-
}
|
|
15307
|
-
return translated.join(" ");
|
|
15308
|
-
}
|
|
15309
|
-
function translateElements(parsed, sourceLocale, targetLocale) {
|
|
15310
|
-
for (const [_role, element] of parsed.roles) {
|
|
15311
|
-
if (element.value.includes("'s")) {
|
|
15312
|
-
element.translated = translateMultiWordValue(element.value, sourceLocale, targetLocale);
|
|
15313
|
-
} else if (!element.isSelector && !element.isLiteral) {
|
|
15314
|
-
element.translated = translateMultiWordValue(element.value, sourceLocale, targetLocale);
|
|
15315
|
-
} else {
|
|
15316
|
-
element.translated = element.value;
|
|
15317
|
-
}
|
|
15318
|
-
}
|
|
15319
|
-
}
|
|
15320
|
-
var CARET_SCOPE_OPEN = "\uE000";
|
|
15321
|
-
var CARET_SCOPE_CLOSE = "\uE001";
|
|
15322
|
-
var CARET_SCOPE_RE = /(\^[A-Za-z_][\w-]*)(\s+on\s+(?:[#.][\w-]+|<[^>]*\/>|\[[^\]]+\]))/g;
|
|
15323
|
-
function maskCaretScopes(input) {
|
|
15324
|
-
const scopes = [];
|
|
15325
|
-
const masked = input.replace(CARET_SCOPE_RE, (_m, varTok, scope) => {
|
|
15326
|
-
const idx = scopes.length;
|
|
15327
|
-
scopes.push(scope);
|
|
15328
|
-
return `${varTok}${CARET_SCOPE_OPEN}${idx}${CARET_SCOPE_CLOSE}`;
|
|
15329
|
-
});
|
|
15330
|
-
return scopes.length > 0 ? { masked, scopes } : null;
|
|
15331
|
-
}
|
|
15332
|
-
function restoreCaretScopes(input, scopes) {
|
|
15333
|
-
return input.replace(
|
|
15334
|
-
new RegExp(`${CARET_SCOPE_OPEN}(\\d+)${CARET_SCOPE_CLOSE}`, "g"),
|
|
15335
|
-
(_m, n) => scopes[Number(n)] ?? ""
|
|
15336
|
-
);
|
|
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
|
-
}
|
|
15357
|
-
var GrammarTransformer = class {
|
|
15358
|
-
constructor(sourceLocale = "en", targetLocale) {
|
|
15359
|
-
const source = getProfile(sourceLocale);
|
|
15360
|
-
const target = getProfile(targetLocale);
|
|
15361
|
-
if (!source) throw new Error(`Unknown source locale: ${sourceLocale}`);
|
|
15362
|
-
if (!target) throw new Error(`Unknown target locale: ${targetLocale}`);
|
|
15363
|
-
this.sourceProfile = source;
|
|
15364
|
-
this.targetProfile = target;
|
|
15365
|
-
}
|
|
15366
|
-
/**
|
|
15367
|
-
* Transform a hyperscript statement from source to target language.
|
|
15368
|
-
* Handles compound statements with "then" by splitting, transforming each part,
|
|
15369
|
-
* and rejoining with the target language's "then" keyword.
|
|
15370
|
-
*
|
|
15371
|
-
* For multi-line input, preserves line structure (indentation, blank lines).
|
|
15372
|
-
*/
|
|
15373
|
-
transform(input) {
|
|
15374
|
-
const out = this.transformInternal(input);
|
|
15375
|
-
return this.targetProfile.code === "he" ? repairHebrewFrontedAccusative(out) : out;
|
|
15376
|
-
}
|
|
15377
|
-
transformInternal(input) {
|
|
15378
|
-
const viewTails = maskViewTransitionTails(input);
|
|
15379
|
-
if (viewTails) {
|
|
15380
|
-
return restoreViewTransitionTails(this.transformInternal(viewTails.masked), viewTails.tails);
|
|
15381
|
-
}
|
|
15382
|
-
const caret = maskCaretScopes(input);
|
|
15383
|
-
if (caret) {
|
|
15384
|
-
return restoreCaretScopes(this.transform(caret.masked), caret.scopes);
|
|
15385
|
-
}
|
|
15386
|
-
const targetThen = getTargetThenKeyword(this.targetProfile.code);
|
|
15387
|
-
if (!input.includes("\n")) {
|
|
15388
|
-
const jsBlock = this.tryTransformJsBlock(input);
|
|
15389
|
-
if (jsBlock !== null) return jsBlock;
|
|
15390
|
-
const eventModifier = this.tryTransformEventWithModifierBody(input);
|
|
15391
|
-
if (eventModifier !== null) return eventModifier;
|
|
15392
|
-
const eventBlock = this.tryTransformEventWithBlockBody(input);
|
|
15393
|
-
if (eventBlock !== null) return eventBlock;
|
|
15394
|
-
const eventGuard = this.tryTransformEventWithUnlessGuard(input);
|
|
15395
|
-
if (eventGuard !== null) return eventGuard;
|
|
15396
|
-
}
|
|
15397
|
-
const hasMultiLineStructure = input.includes("\n");
|
|
15398
|
-
if (hasMultiLineStructure) {
|
|
15399
|
-
const { parts: parts2, lineMetadata, partToLineIndex } = splitCompoundStatementWithMetadata(
|
|
15400
|
-
input,
|
|
15401
|
-
this.sourceProfile.code
|
|
15402
|
-
);
|
|
15403
|
-
const transformedParts = parts2.map((part) => this.transformSingle(part));
|
|
15404
|
-
return reconstructWithLineStructure(
|
|
15405
|
-
transformedParts,
|
|
15406
|
-
lineMetadata,
|
|
15407
|
-
partToLineIndex,
|
|
15408
|
-
targetThen
|
|
15409
|
-
);
|
|
15410
|
-
}
|
|
15411
|
-
const parts = splitCompoundStatement(input, this.sourceProfile.code);
|
|
15412
|
-
if (parts.length > 1) {
|
|
15413
|
-
const transformedParts = parts.map((part) => this.transformSingle(part));
|
|
15414
|
-
return transformedParts.join(` ${targetThen} `);
|
|
15415
|
-
}
|
|
15416
|
-
return this.transformSingle(input);
|
|
15417
|
-
}
|
|
15418
|
-
/**
|
|
15419
|
-
* Transform a single hyperscript statement (no compound "then" chains).
|
|
15420
|
-
*/
|
|
15421
|
-
transformSingle(input) {
|
|
15422
|
-
const block = extractBlockStructure(input, this.sourceProfile.code);
|
|
15423
|
-
if (block) {
|
|
15424
|
-
return this.transformBlock(block);
|
|
15425
|
-
}
|
|
15426
|
-
const strippedEnd = this.transformWithTrailingEnd(input);
|
|
15427
|
-
if (strippedEnd !== null) {
|
|
15428
|
-
return strippedEnd;
|
|
15429
|
-
}
|
|
15430
|
-
const setScope = this.transformSetWithScope(input);
|
|
15431
|
-
if (setScope !== null) {
|
|
15432
|
-
return setScope;
|
|
15433
|
-
}
|
|
15434
|
-
const viewTail = this.transformWithViewTransitionTail(input);
|
|
15435
|
-
if (viewTail !== null) {
|
|
15436
|
-
return viewTail;
|
|
15437
|
-
}
|
|
15438
|
-
const parsed = parseStatement(input, this.sourceProfile.code);
|
|
15439
|
-
if (!parsed) {
|
|
15440
|
-
return input;
|
|
15441
|
-
}
|
|
15442
|
-
applyPrimaryRole(parsed, this.targetProfile);
|
|
15443
|
-
translateElements(parsed, this.sourceProfile.code, this.targetProfile.code);
|
|
15444
|
-
const rule = this.findRule(parsed);
|
|
15445
|
-
if (rule?.transform.custom) {
|
|
15446
|
-
return rule.transform.custom(parsed, this.targetProfile);
|
|
15447
|
-
}
|
|
15448
|
-
const roleOrder = rule?.transform.roleOrder || this.targetProfile.canonicalOrder;
|
|
15449
|
-
const reordered = reorderRoles(parsed.roles, roleOrder);
|
|
15450
|
-
const shouldInsertMarkers = rule?.transform.insertMarkers ?? true;
|
|
15451
|
-
if (shouldInsertMarkers) {
|
|
15452
|
-
const result = insertMarkers(
|
|
15453
|
-
reordered,
|
|
15454
|
-
this.targetProfile.markers,
|
|
15455
|
-
this.targetProfile.adpositionType
|
|
15456
|
-
);
|
|
15457
|
-
return joinTokens(result);
|
|
15458
|
-
}
|
|
15459
|
-
return joinTokens(reordered.map((e) => e.translated || e.value));
|
|
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
|
-
}
|
|
15490
|
-
/**
|
|
15491
|
-
* `<command …> end` fragments: transform the command without its stranded
|
|
15492
|
-
* terminator, then re-append the translated terminator as a standalone
|
|
15493
|
-
* trailing token. Fragments that open a block of their own (`if … end`,
|
|
15494
|
-
* `repeat … end`, `js … end`) bail — their terminator belongs to them and
|
|
15495
|
-
* their dedicated paths handle it.
|
|
15496
|
-
*/
|
|
15497
|
-
transformWithTrailingEnd(input) {
|
|
15498
|
-
const src = this.sourceProfile.code;
|
|
15499
|
-
const tokens = input.trim().split(/\s+/);
|
|
15500
|
-
if (tokens.length < 2) {
|
|
15501
|
-
return null;
|
|
15502
|
-
}
|
|
15503
|
-
const sourceEnd = translateWord("end", "en", src).toLowerCase();
|
|
15504
|
-
if (tokens[tokens.length - 1].toLowerCase() !== sourceEnd) {
|
|
15505
|
-
return null;
|
|
15506
|
-
}
|
|
15507
|
-
const openers = new Set(
|
|
15508
|
-
["if", "repeat", "unless", "while", "when", "live", "js"].map(
|
|
15509
|
-
(k) => translateWord(k, "en", src).toLowerCase()
|
|
15510
|
-
)
|
|
15511
|
-
);
|
|
15512
|
-
if (tokens.slice(0, -1).some((t) => openers.has(t.toLowerCase()))) {
|
|
15513
|
-
return null;
|
|
15514
|
-
}
|
|
15515
|
-
const inner = this.transformSingle(tokens.slice(0, -1).join(" "));
|
|
15516
|
-
const endT = translateWord(tokens[tokens.length - 1], src, this.targetProfile.code);
|
|
15517
|
-
return `${inner} ${endT}`;
|
|
15518
|
-
}
|
|
15519
|
-
/**
|
|
15520
|
-
* Detect and transform an inline JS block (`[on <event>] js <raw js> end`).
|
|
15521
|
-
*
|
|
15522
|
-
* The `js ... end` body is raw JavaScript: it must not be tokenized,
|
|
15523
|
-
* translated, or word-order reordered. We mask the whole block with a single
|
|
15524
|
-
* opaque placeholder, run the surrounding statement (the event-handler head,
|
|
15525
|
-
* if any) through the normal reorder pipeline so the placeholder lands in the
|
|
15526
|
-
* correct action position, then substitute the translated `js`/`end` keywords
|
|
15527
|
-
* around the verbatim body.
|
|
15528
|
-
*
|
|
15529
|
-
* Returns `null` (fall through to the normal path) when there is no js block,
|
|
15530
|
-
* no matching `end`, or trailing content after `end` (kept tight on purpose).
|
|
15531
|
-
*/
|
|
15532
|
-
tryTransformJsBlock(input) {
|
|
15533
|
-
const src = this.sourceProfile.code;
|
|
15534
|
-
const dst = this.targetProfile.code;
|
|
15535
|
-
const sourceJs = translateWord("js", "en", src);
|
|
15536
|
-
const sourceEnd = translateWord("end", "en", src).toLowerCase();
|
|
15537
|
-
const tokens = input.split(/\s+/).filter((t) => t.length > 0);
|
|
15538
|
-
const escapedJs = sourceJs.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
15539
|
-
const jsRe = new RegExp(`^${escapedJs}(\\(.*\\))?$`, "i");
|
|
15540
|
-
const jsIdx = tokens.findIndex((t) => jsRe.test(t));
|
|
15541
|
-
if (jsIdx === -1) return null;
|
|
15542
|
-
let endIdx = -1;
|
|
15543
|
-
for (let i = jsIdx + 1; i < tokens.length; i++) {
|
|
15544
|
-
if (tokens[i].toLowerCase() === sourceEnd) {
|
|
15545
|
-
endIdx = i;
|
|
15546
|
-
break;
|
|
15547
|
-
}
|
|
15548
|
-
}
|
|
15549
|
-
if (endIdx === -1) return null;
|
|
15550
|
-
if (endIdx !== tokens.length - 1) return null;
|
|
15551
|
-
const jsToken = tokens[jsIdx];
|
|
15552
|
-
const jsParen = jsToken.match(jsRe)?.[1] ?? "";
|
|
15553
|
-
const jsKeywordRaw = jsParen ? jsToken.slice(0, jsToken.length - jsParen.length) : jsToken;
|
|
15554
|
-
const body = tokens.slice(jsIdx + 1, endIdx).join(" ");
|
|
15555
|
-
const targetJs = translateWord(jsKeywordRaw, src, dst) + jsParen;
|
|
15556
|
-
const targetEnd = translateWord(tokens[endIdx], src, dst);
|
|
15557
|
-
const replacement = [targetJs, body, targetEnd].filter((s) => s.length > 0).join(" ");
|
|
15558
|
-
const before = tokens.slice(0, jsIdx);
|
|
15559
|
-
if (before.length === 0) return replacement;
|
|
15560
|
-
const placeholder = "JSBLOCKPLACEHOLDER";
|
|
15561
|
-
const reordered = this.transformSingle([...before, placeholder].join(" "));
|
|
15562
|
-
if (!reordered.includes(placeholder)) return null;
|
|
15563
|
-
return reordered.replace(placeholder, replacement);
|
|
15564
|
-
}
|
|
15565
|
-
/**
|
|
15566
|
-
* Transform an event handler whose body is a block command
|
|
15567
|
-
* (`on <event> [from <src>] {if|repeat|unless|while|for} … end`).
|
|
15568
|
-
*
|
|
15569
|
-
* `parseEventHandler` would treat the block keyword as the action and sweep the
|
|
15570
|
-
* condition/body into role values, then reorder them — shredding the block
|
|
15571
|
-
* (`if event.shiftKey call submitAndContinue() end` → scattered tokens). Instead
|
|
15572
|
-
* we mask the whole block as an opaque action placeholder, reorder the event
|
|
15573
|
-
* head normally, transform the block as a self-contained unit, and restitch.
|
|
15574
|
-
*
|
|
15575
|
-
* Returns `null` (fall through) when the input isn't an event handler, has no
|
|
15576
|
-
* block-keyword body, or has no closing `end`.
|
|
15577
|
-
*/
|
|
15578
|
-
tryTransformEventWithBlockBody(input) {
|
|
15579
|
-
const tokens = tokenize2(input, this.sourceProfile);
|
|
15580
|
-
if (tokens.length === 0) return null;
|
|
15581
|
-
if (!EVENT_KEYWORDS.has(tokens[0]?.toLowerCase())) return null;
|
|
15582
|
-
let blockIdx = -1;
|
|
15583
|
-
for (let i = 1; i < tokens.length; i++) {
|
|
15584
|
-
if (BLOCK_BODY_KEYWORDS.has(tokens[i].toLowerCase())) {
|
|
15585
|
-
blockIdx = i;
|
|
15586
|
-
break;
|
|
15587
|
-
}
|
|
15588
|
-
}
|
|
15589
|
-
if (blockIdx <= 0) return null;
|
|
15590
|
-
if (tokens[tokens.length - 1].toLowerCase() !== "end") return null;
|
|
15591
|
-
const eventHead = tokens.slice(0, blockIdx);
|
|
15592
|
-
const blockTokens = tokens.slice(blockIdx);
|
|
15593
|
-
if (this.targetProfile.wordOrder === "VSO" && eventHead.some((t) => t.toLowerCase() === "from")) {
|
|
15594
|
-
return null;
|
|
15595
|
-
}
|
|
15596
|
-
const placeholder = "EVENTBLOCKPLACEHOLDER";
|
|
15597
|
-
const headOut = this.transformSingle([...eventHead, placeholder].join(" "));
|
|
15598
|
-
if (!headOut.includes(placeholder)) return null;
|
|
15599
|
-
const blockOut = this.transformBlockBody(blockTokens);
|
|
15600
|
-
const eventClause = headOut.replace(placeholder, "").replace(/\s+/g, " ").trim();
|
|
15601
|
-
return [eventClause, blockOut].filter((s) => s.length > 0).join(" ");
|
|
15602
|
-
}
|
|
15603
|
-
/**
|
|
15604
|
-
* Transform an event handler whose body is an inline `unless` guard with NO
|
|
15605
|
-
* `end` (`on <event> unless <cond> <body>` — the `unless-condition` shape).
|
|
15606
|
-
*
|
|
15607
|
-
* Object-marking SVO targets (he, zh). `parseEventHandler` reads `unless` as the
|
|
15608
|
-
* action and sweeps the whole `<cond> <body>` tail into a single `patient` blob;
|
|
15609
|
-
* the target then prefixes that blob with its object marker — Hebrew's accusative
|
|
15610
|
-
* את (`… אלא את I match .disabled מתג .selected`) or Chinese's BA particle 把
|
|
15611
|
-
* (`… 除非 把 I match .disabled 切换 .selected`) — and the inner toggle loses its
|
|
15612
|
-
* own marker. The semantic parser can't recover the guard from that: the marker
|
|
15613
|
-
* ahead of the condition blocks the `unless` pattern AND the now-markerless body
|
|
15614
|
-
* command fails its object-marked toggle pattern, so the body collapses (`unless`
|
|
15615
|
-
* dropped). Marker-less languages (de/it/ar/pl) tolerate the same role-blob and
|
|
15616
|
-
* stay faithful, so this is an object-marker artifact, not a general parse gap.
|
|
15617
|
-
*
|
|
15618
|
-
* The standalone `unless <cond> <body>` path already produces the correct shape
|
|
15619
|
-
* (`extractBlockStructure` → `transformBlock`: condition kept marker-free, body
|
|
15620
|
-
* command keeps its marker — he `אלא I match .disabled מתג את .selected`, zh
|
|
15621
|
-
* `除非 I match .disabled 切换 把 .selected`). So we split the event head off,
|
|
15622
|
-
* transform the guard through that path, and emit the event clause first (he and
|
|
15623
|
-
* zh are both SVO — event leads). Returns `null` (fall through) when the input
|
|
15624
|
-
* isn't an object-marking event handler with an un-terminated inline `unless`
|
|
15625
|
-
* guard.
|
|
15626
|
-
*/
|
|
15627
|
-
tryTransformEventWithUnlessGuard(input) {
|
|
15628
|
-
if (!UNLESS_GUARD_OBJECT_MARKING_LOCALES.has(this.targetProfile.code)) return null;
|
|
15629
|
-
const tokens = tokenize2(input, this.sourceProfile);
|
|
15630
|
-
if (tokens.length === 0) return null;
|
|
15631
|
-
if (!EVENT_KEYWORDS.has(tokens[0]?.toLowerCase())) return null;
|
|
15632
|
-
let guardIdx = -1;
|
|
15633
|
-
for (let i = 1; i < tokens.length; i++) {
|
|
15634
|
-
if (tokens[i].toLowerCase() === "unless") {
|
|
15635
|
-
guardIdx = i;
|
|
15636
|
-
break;
|
|
15637
|
-
}
|
|
15638
|
-
}
|
|
15639
|
-
if (guardIdx <= 0) return null;
|
|
15640
|
-
if (tokens[tokens.length - 1].toLowerCase() === "end") return null;
|
|
15641
|
-
const eventHead = tokens.slice(0, guardIdx);
|
|
15642
|
-
const guard = tokens.slice(guardIdx).join(" ");
|
|
15643
|
-
const guardOut = this.transform(guard);
|
|
15644
|
-
if (!guardOut) return null;
|
|
15645
|
-
const placeholder = "EVENTGUARDPLACEHOLDER";
|
|
15646
|
-
const headOut = this.transformSingle([...eventHead, placeholder].join(" "));
|
|
15647
|
-
if (!headOut.includes(placeholder)) return null;
|
|
15648
|
-
const eventClause = headOut.replace(placeholder, "").replace(/\s+/g, " ").trim();
|
|
15649
|
-
return [eventClause, guardOut].filter((s) => s.length > 0).join(" ");
|
|
15650
|
-
}
|
|
15651
|
-
/**
|
|
15652
|
-
* Transform an event handler whose body leads with a command-modifier
|
|
15653
|
-
* (`on <event> [from <src>] {async|once|debounced [at N]|throttled [at N]} <body>`).
|
|
15654
|
-
*
|
|
15655
|
-
* `parseEventHandler` reads the first token after the event as the **action**, so
|
|
15656
|
-
* a leading modifier is mistaken for the verb and the real verb (`fetch`/`add`) is
|
|
15657
|
-
* swept into the patient. For SOV targets the reorder then surfaces that verb
|
|
15658
|
-
* **first** (`取得 /api/data を クリック …`), and the semantic parser matches the
|
|
15659
|
-
* leading `<verb> <patient>` with the low-priority `*-generated-verb-first`
|
|
15660
|
-
* command pattern — returning a bare command and discarding the event + the rest
|
|
15661
|
-
* of the body (degenerate parse).
|
|
15662
|
-
*
|
|
15663
|
-
* Instead, lift the modifier out, transform the modifier-free handler through the
|
|
15664
|
-
* normal path (which keeps the body in canonical patient-first SOV order so the
|
|
15665
|
-
* event sits mid-stream and the existing SOV event-extraction recovers it), then
|
|
15666
|
-
* re-emit the modifier as a **leading English literal**. The semantic parser
|
|
15667
|
-
* strips a leading `once`/`debounced`/`throttled` (`extractStandaloneModifiers`)
|
|
15668
|
-
* and an `async` anywhere (`stripAsyncModifier`) before parsing, so the modifier
|
|
15669
|
-
* is consumed as handler metadata rather than shadowing the body.
|
|
15670
|
-
*
|
|
15671
|
-
* Returns `null` (fall through) when the input isn't an event handler or the body
|
|
15672
|
-
* doesn't lead with a modifier — leaving simple/Mode-B handlers byte-identical.
|
|
15673
|
-
*/
|
|
15674
|
-
tryTransformEventWithModifierBody(input) {
|
|
15675
|
-
if (this.targetProfile.wordOrder !== "SOV") return null;
|
|
15676
|
-
const tokens = tokenize2(input, this.sourceProfile);
|
|
15677
|
-
if (tokens.length === 0) return null;
|
|
15678
|
-
if (!EVENT_KEYWORDS.has(tokens[0]?.toLowerCase())) return null;
|
|
15679
|
-
let i = 1;
|
|
15680
|
-
if (!tokens[i]) return null;
|
|
15681
|
-
i++;
|
|
15682
|
-
while (tokens[i] && EVENT_CONJUNCTIONS.has(tokens[i].toLowerCase()) && tokens[i + 1]) {
|
|
15683
|
-
i += 2;
|
|
15684
|
-
}
|
|
15685
|
-
if (tokens[i]?.toLowerCase() === "from" && tokens[i + 1]) {
|
|
15686
|
-
i++;
|
|
15687
|
-
while (tokens[i] && !ENGLISH_COMMANDS.has(tokens[i].toLowerCase()) && !BODY_MODIFIER_KEYWORDS.has(tokens[i].toLowerCase())) {
|
|
15688
|
-
i++;
|
|
15689
|
-
}
|
|
15690
|
-
}
|
|
15691
|
-
const modWord = tokens[i]?.toLowerCase();
|
|
15692
|
-
if (!modWord || !BODY_MODIFIER_KEYWORDS.has(modWord)) return null;
|
|
15693
|
-
const modStart = i;
|
|
15694
|
-
let modEnd = i + 1;
|
|
15695
|
-
if (modWord !== "async" && modWord !== "once") {
|
|
15696
|
-
if (tokens[modEnd]?.toLowerCase() === "at") modEnd++;
|
|
15697
|
-
if (tokens[modEnd] && /^\d+(ms|s|m)?$/.test(tokens[modEnd])) modEnd++;
|
|
15698
|
-
}
|
|
15699
|
-
const modifierPhrase = tokens.slice(modStart, modEnd).join(" ");
|
|
15700
|
-
const rebuilt = [...tokens.slice(0, modStart), ...tokens.slice(modEnd)].join(" ");
|
|
15701
|
-
if (tokens.length - (modEnd - modStart) <= 2) return null;
|
|
15702
|
-
const bodyOut = this.transform(rebuilt);
|
|
15703
|
-
return [modifierPhrase, bodyOut].filter((s) => s.length > 0).join(" ");
|
|
15704
|
-
}
|
|
15705
|
-
/**
|
|
15706
|
-
* Transform a `set <stuff> on <scope>` clause (S1 tabs-aria). The trailing
|
|
15707
|
-
* `on <scope>` is the element(s) the attribute is set on — kept attached by
|
|
15708
|
-
* splitOnCommandBoundaries. The semantic parser captures it as a `scope` role
|
|
15709
|
-
* via the passthrough literal `on` (setSchema's scope markerOverride is `on`
|
|
15710
|
-
* in every language), so `on` is emitted verbatim and only the scope *value*
|
|
15711
|
-
* is translated (selectors pass through; `me`/`it`/`you` translate to the
|
|
15712
|
-
* native reference, which the parser also accepts).
|
|
15713
|
-
*
|
|
15714
|
-
* Positioning matches where the set patterns expect the scope: at the clause
|
|
15715
|
-
* end for verb-first orders (SVO/VSO), and immediately before the clause-final
|
|
15716
|
-
* verb for SOV (the generated SOV pattern is `{dest} {patient} on {scope}
|
|
15717
|
-
* {verb}`). Returns null (fall through) when there is no trailing `on <scope>`.
|
|
15718
|
-
*
|
|
15719
|
-
* Source is English in the sync-translations pipeline, so the `set` verb and
|
|
15720
|
-
* `on` marker are matched as English literals.
|
|
15721
|
-
*/
|
|
15722
|
-
transformSetWithScope(input) {
|
|
15723
|
-
const src = this.sourceProfile.code;
|
|
15724
|
-
const dst = this.targetProfile.code;
|
|
15725
|
-
const m = input.match(/^(.*\bset\b.*\S)\s+on\s+([#.<@[]\S*|me|it|you)\s*$/i);
|
|
15726
|
-
if (!m) return null;
|
|
15727
|
-
const head = m[1];
|
|
15728
|
-
const scopeRaw = m[2];
|
|
15729
|
-
const headOut = this.transformSingle(head);
|
|
15730
|
-
const scopeT = /^[#.<@[]/.test(scopeRaw) ? scopeRaw : translateWord(scopeRaw, src, dst);
|
|
15731
|
-
if (this.targetProfile.wordOrder === "SOV") {
|
|
15732
|
-
const verb = translateWord("set", "en", dst);
|
|
15733
|
-
const firstTok = input.trim().split(/\s+/)[0]?.toLowerCase();
|
|
15734
|
-
const isEventHandler = !!firstTok && EVENT_KEYWORDS.has(firstTok);
|
|
15735
|
-
const toks = headOut.split(/\s+/).filter(Boolean);
|
|
15736
|
-
if (!isEventHandler) {
|
|
15737
|
-
const vIdx = toks.indexOf(verb);
|
|
15738
|
-
if (vIdx >= 0) {
|
|
15739
|
-
toks.splice(vIdx, 1);
|
|
15740
|
-
toks.push("on", scopeT, verb);
|
|
15741
|
-
return toks.join(" ");
|
|
15742
|
-
}
|
|
15743
|
-
} else if (toks.length > 0 && toks[toks.length - 1] === verb) {
|
|
15744
|
-
toks.splice(toks.length - 1, 0, "on", scopeT);
|
|
15745
|
-
return toks.join(" ");
|
|
15746
|
-
}
|
|
15747
|
-
return `${headOut} on ${scopeT}`;
|
|
15748
|
-
}
|
|
15749
|
-
return `${headOut} on ${scopeT}`;
|
|
15750
|
-
}
|
|
15751
|
-
/**
|
|
15752
|
-
* Transform a self-contained block command (`{head} {clause?} {body} {end}`),
|
|
15753
|
-
* where head ∈ {if, repeat, unless, …}. The clause (condition / `until event …`)
|
|
15754
|
-
* runs up to the first command verb and is translated word-by-word; the body is
|
|
15755
|
-
* recursively transformed (so its inner commands reorder for the target); the
|
|
15756
|
-
* head/tail keywords are translated. The block is never word-order reordered as
|
|
15757
|
-
* a whole — delimiters stay at the edges regardless of target word order.
|
|
15758
|
-
*/
|
|
15759
|
-
transformBlockBody(blockTokens) {
|
|
15760
|
-
const src = this.sourceProfile.code;
|
|
15761
|
-
const dst = this.targetProfile.code;
|
|
15762
|
-
const head = blockTokens[0];
|
|
15763
|
-
const hasEnd = blockTokens[blockTokens.length - 1]?.toLowerCase() === "end";
|
|
15764
|
-
const tail = hasEnd ? blockTokens[blockTokens.length - 1] : "";
|
|
15765
|
-
const inner = blockTokens.slice(1, hasEnd ? -1 : void 0);
|
|
15766
|
-
const commands = getCommandKeywordsForLocale(src);
|
|
15767
|
-
const copulas = getCopulasForLocale(src);
|
|
15768
|
-
let bodyStart = inner.findIndex(
|
|
15769
|
-
(t, i) => commands.has(t.toLowerCase()) && !isPredicateAdjectivePosition(inner, i, copulas)
|
|
15770
|
-
);
|
|
15771
|
-
if (bodyStart < 0) bodyStart = inner.length;
|
|
15772
|
-
const clause = inner.slice(0, bodyStart).join(" ");
|
|
15773
|
-
const bodyTokens = inner.slice(bodyStart);
|
|
15774
|
-
const headT = translateWord(head, src, dst);
|
|
15775
|
-
const tailT = tail ? translateWord(tail, src, dst) : "";
|
|
15776
|
-
const clauseT = clause ? translateMultiWordValue(clause, src, dst) : "";
|
|
15777
|
-
const bodyT = this.transformConditionalBody(bodyTokens);
|
|
15778
|
-
const POSITIONAL_BRANCH_HEADS = /* @__PURE__ */ new Set(["first", "last", "next", "previous", "closest"]);
|
|
15779
|
-
const thenT = this.targetProfile.wordOrder === "SOV" && clauseT && POSITIONAL_BRANCH_HEADS.has(bodyTokens[1]?.toLowerCase()) && inner[bodyStart - 1]?.toLowerCase() !== "then" ? translateWord("then", src, dst) : "";
|
|
15780
|
-
return [headT, clauseT, thenT, bodyT, tailT].filter((s) => s.length > 0).join(" ");
|
|
15781
|
-
}
|
|
15782
|
-
/**
|
|
15783
|
-
* Transform an `if`/`unless` block body, splitting it at a top-level `else` into
|
|
15784
|
-
* a then-branch and an else-branch so each is reordered as a self-contained unit
|
|
15785
|
-
* and the `else` keyword itself is translated. Without this, the body is reordered
|
|
15786
|
-
* as one stream: `else` rides along glued to the preceding clause (and, when that
|
|
15787
|
-
* clause begins with a selector, is marked a selector and left *untranslated*),
|
|
15788
|
-
* and a spurious `then` is inserted around it — both of which break the target
|
|
15789
|
-
* text and the downstream parse. The split is depth-aware so an `else` belonging
|
|
15790
|
-
* to a nested block is not mistaken for this block's separator. Bodies without an
|
|
15791
|
-
* `else` transform exactly as before.
|
|
15792
|
-
*/
|
|
15793
|
-
transformConditionalBody(bodyTokens) {
|
|
15794
|
-
const src = this.sourceProfile.code;
|
|
15795
|
-
const dst = this.targetProfile.code;
|
|
15796
|
-
const sourceElse = translateWord("else", "en", src).toLowerCase();
|
|
15797
|
-
let depth = 0;
|
|
15798
|
-
let elseIdx = -1;
|
|
15799
|
-
for (let i = 0; i < bodyTokens.length; i++) {
|
|
15800
|
-
const t = bodyTokens[i].toLowerCase();
|
|
15801
|
-
if (BLOCK_BODY_KEYWORDS.has(t)) depth++;
|
|
15802
|
-
else if (t === "end" && depth > 0) depth--;
|
|
15803
|
-
else if (t === sourceElse && depth === 0) {
|
|
15804
|
-
elseIdx = i;
|
|
15805
|
-
break;
|
|
15806
|
-
}
|
|
15807
|
-
}
|
|
15808
|
-
if (elseIdx === -1) {
|
|
15809
|
-
const body = bodyTokens.join(" ");
|
|
15810
|
-
return body ? this.transform(body) : "";
|
|
15811
|
-
}
|
|
15812
|
-
const thenBranch = bodyTokens.slice(0, elseIdx).join(" ");
|
|
15813
|
-
const elseBranch = bodyTokens.slice(elseIdx + 1).join(" ");
|
|
15814
|
-
const elseT = translateWord(bodyTokens[elseIdx], src, dst);
|
|
15815
|
-
return [
|
|
15816
|
-
thenBranch ? this.transform(thenBranch) : "",
|
|
15817
|
-
elseT,
|
|
15818
|
-
elseBranch ? this.transform(elseBranch) : ""
|
|
15819
|
-
].filter((s) => s.length > 0).join(" ");
|
|
15820
|
-
}
|
|
15821
|
-
/**
|
|
15822
|
-
* Translate a reactive block by translating the head/tail/connector
|
|
15823
|
-
* via the dictionary, recursively transforming the body through the
|
|
15824
|
-
* regular pipeline, and rejoining in source-language position order.
|
|
15825
|
-
* Block-syntactic tokens are never reordered: they're delimiters, not
|
|
15826
|
-
* arguments, and authors expect them at start/end positions
|
|
15827
|
-
* regardless of target word order.
|
|
15828
|
-
*/
|
|
15829
|
-
transformBlock(block) {
|
|
15830
|
-
const src = this.sourceProfile.code;
|
|
15831
|
-
const dst = this.targetProfile.code;
|
|
15832
|
-
const head = translateWord(block.headKeyword, src, dst);
|
|
15833
|
-
const tail = block.tailKeyword ? translateWord(block.tailKeyword, src, dst) : "";
|
|
15834
|
-
const connector = block.connector ? translateWord(block.connector, src, dst) : "";
|
|
15835
|
-
const prefix = block.prefixExpr ? translateMultiWordValue(block.prefixExpr, src, dst) : "";
|
|
15836
|
-
const body = this.transform(block.body);
|
|
15837
|
-
return [head, prefix, connector, body, tail].filter((s) => s.length > 0).join(" ");
|
|
15838
|
-
}
|
|
15839
|
-
/**
|
|
15840
|
-
* Find the best matching rule for this statement
|
|
15841
|
-
*/
|
|
15842
|
-
findRule(parsed) {
|
|
15843
|
-
if (!this.targetProfile.rules) return void 0;
|
|
15844
|
-
const matchingRules = this.targetProfile.rules.filter((rule) => this.matchesRule(parsed, rule)).sort((a, b) => b.priority - a.priority);
|
|
15845
|
-
return matchingRules[0];
|
|
15846
|
-
}
|
|
15847
|
-
/**
|
|
15848
|
-
* Check if a parsed statement matches a rule
|
|
15849
|
-
*/
|
|
15850
|
-
matchesRule(parsed, rule) {
|
|
15851
|
-
const { match } = rule;
|
|
15852
|
-
for (const role of match.requiredRoles) {
|
|
15853
|
-
if (!parsed.roles.has(role)) {
|
|
15854
|
-
return false;
|
|
15855
|
-
}
|
|
15856
|
-
}
|
|
15857
|
-
if (match.commands && match.commands.length > 0) {
|
|
15858
|
-
const action = parsed.roles.get("action");
|
|
15859
|
-
if (!action) return false;
|
|
15860
|
-
const actionValue = action.value.toLowerCase();
|
|
15861
|
-
if (!match.commands.some((cmd) => cmd.toLowerCase() === actionValue)) {
|
|
15862
|
-
return false;
|
|
15863
|
-
}
|
|
15864
|
-
}
|
|
15865
|
-
if (match.predicate && !match.predicate(parsed)) {
|
|
15866
|
-
return false;
|
|
15867
|
-
}
|
|
15868
|
-
return true;
|
|
15869
|
-
}
|
|
15870
|
-
};
|
|
15871
|
-
function toLocale(input, targetLocale) {
|
|
15872
|
-
const transformer = new GrammarTransformer("en", targetLocale);
|
|
15873
|
-
return transformer.transform(input);
|
|
15874
|
-
}
|
|
15875
|
-
function toEnglish(input, sourceLocale) {
|
|
15876
|
-
const transformer = new GrammarTransformer(sourceLocale, "en");
|
|
15877
|
-
return transformer.transform(input);
|
|
15878
|
-
}
|
|
15879
|
-
function translate(input, sourceLocale, targetLocale) {
|
|
15880
|
-
if (sourceLocale === targetLocale) return input;
|
|
15881
|
-
if (sourceLocale === "en") return toLocale(input, targetLocale);
|
|
15882
|
-
if (targetLocale === "en") return toEnglish(input, sourceLocale);
|
|
15883
|
-
if (hasDirectMapping(sourceLocale, targetLocale)) {
|
|
15884
|
-
return translateDirect(input, sourceLocale, targetLocale);
|
|
15885
|
-
}
|
|
15886
|
-
const english = toEnglish(input, sourceLocale);
|
|
15887
|
-
return toLocale(english, targetLocale);
|
|
15888
|
-
}
|
|
15889
|
-
function translateDirect(input, sourceLocale, targetLocale) {
|
|
15890
|
-
const mapping = getDirectMapping(sourceLocale, targetLocale);
|
|
15891
|
-
if (!mapping) {
|
|
15892
|
-
return toLocale(toEnglish(input, sourceLocale), targetLocale);
|
|
15893
|
-
}
|
|
15894
|
-
const tokens = input.split(/\s+/);
|
|
15895
|
-
const translated = tokens.map((token) => {
|
|
15896
|
-
if (token.startsWith("#") || token.startsWith(".") || token.startsWith("@")) {
|
|
15897
|
-
return token;
|
|
15898
|
-
}
|
|
15899
|
-
if (token.startsWith('"') || token.startsWith("'")) {
|
|
15900
|
-
return token;
|
|
15901
|
-
}
|
|
15902
|
-
const directTranslation = mapping.words[token];
|
|
15903
|
-
if (directTranslation) {
|
|
15904
|
-
return directTranslation;
|
|
15905
|
-
}
|
|
15906
|
-
const suffixMatch = token.match(/^(.+?)(-.+)$/);
|
|
15907
|
-
if (suffixMatch) {
|
|
15908
|
-
const [, base, suffix] = suffixMatch;
|
|
15909
|
-
const translatedBase = mapping.words[base] || base;
|
|
15910
|
-
return translatedBase + suffix;
|
|
15911
|
-
}
|
|
15912
|
-
return token;
|
|
15913
|
-
});
|
|
15914
|
-
return translated.join(" ");
|
|
15915
|
-
}
|
|
15916
|
-
var examples = {
|
|
15917
|
-
english: {
|
|
15918
|
-
eventHandler: "on click increment #count",
|
|
15919
|
-
putInto: "put my value into #output",
|
|
15920
|
-
toggle: "toggle .active",
|
|
15921
|
-
wait: "wait 2 seconds"
|
|
15922
|
-
},
|
|
15923
|
-
// Expected outputs (approximate, for reference)
|
|
15924
|
-
japanese: {
|
|
15925
|
-
eventHandler: "#count \u3092 \u30AF\u30EA\u30C3\u30AF \u3067 \u5897\u52A0",
|
|
15926
|
-
putInto: "\u79C1\u306E \u5024 \u3092 #output \u306B \u7F6E\u304F",
|
|
15927
|
-
toggle: ".active \u3092 \u5207\u308A\u66FF\u3048",
|
|
15928
|
-
wait: "2\u79D2 \u5F85\u3064"
|
|
15929
|
-
},
|
|
15930
|
-
chinese: {
|
|
15931
|
-
eventHandler: "\u5F53 \u70B9\u51FB \u65F6 \u589E\u52A0 #count",
|
|
15932
|
-
putInto: "\u628A \u6211\u7684\u503C \u653E \u5230 #output",
|
|
15933
|
-
toggle: "\u5207\u6362 .active",
|
|
15934
|
-
wait: "\u7B49\u5F85 2\u79D2"
|
|
15935
|
-
},
|
|
15936
|
-
arabic: {
|
|
15937
|
-
eventHandler: "\u0632\u0650\u062F #count \u0639\u0646\u062F \u0627\u0644\u0646\u0642\u0631",
|
|
15938
|
-
putInto: "\u0636\u0639 \u0642\u064A\u0645\u062A\u064A \u0641\u064A #output",
|
|
15939
|
-
toggle: "\u0628\u062F\u0651\u0644 .active",
|
|
15940
|
-
wait: "\u0627\u0646\u062A\u0638\u0631 \u062B\u0627\u0646\u064A\u062A\u064A\u0646"
|
|
15941
|
-
}
|
|
15942
|
-
};
|
|
15943
|
-
|
|
15944
14088
|
// src/index.ts
|
|
15945
14089
|
var defaultTranslator = new HyperscriptTranslator({ locale: "en" });
|
|
15946
14090
|
var defaultRuntime = new RuntimeI18nManager({ locale: "en" });
|
|
15947
14091
|
|
|
15948
|
-
export { DICTIONARY_CATEGORIES, DateFormatter, ENGLISH_COMMANDS, ENGLISH_KEYWORDS, EnhancedI18nInputSchema, EnhancedI18nOutputSchema,
|
|
14092
|
+
export { DICTIONARY_CATEGORIES, DateFormatter, ENGLISH_COMMANDS, ENGLISH_KEYWORDS, EnhancedI18nInputSchema, EnhancedI18nOutputSchema, HyperscriptI18nWebpackPlugin, HyperscriptTranslator, LANGUAGE_FAMILY_DEFAULTS, LocaleFormatter, LocaleManager, NumberFormatter, PluralAwareTranslator, RuntimeI18nManager, SSRLocaleManager, TypedI18nContextImplementation, UNIVERSAL_ENGLISH_KEYWORDS, UNIVERSAL_PATTERNS, ar2 as ar, ar as arDictionary, arKeywords, arabicProfile, bn2 as bn, bn as bnDictionary, bnKeywords, chineseProfile, createEnglishProvider, createEnhancedI18n, createExpressI18nMiddleware, createI18nContext, createKeywordProvider, de2 as de, de as deDictionary, deKeywords, defaultRuntime, defaultTranslator, detectBrowserLocale, detectLocale, dictionaries, en2 as en, englishProfile, enhancedI18nImplementation, es2 as es, es as esDictionary, esKeywords, findInDictionary, forEachCategory, formatForLocale, fr2 as fr, fr as frDictionary, frKeywords, getBrowserLocales, getDictionary, getDictionaryCategory, getFormatter, getI18n, getPlural, getProfile, getSupportedLocales, hi, hindiDictionary as hiDictionary, hiKeywords, hyperscriptI18nVitePlugin, id2 as id, id as idDictionary, idKeywords, indonesianProfile, initializeI18n, insertMarkers, isDictionaryCategory, isLocaleSupported, isRTL, it2 as it, it as itDictionary, itKeywords, ja2 as ja, ja as jaDictionary, jaKeywords, japaneseProfile, ko2 as ko, ko as koDictionary, koKeywords, koreanProfile, malayProfile, ms2 as ms, ms as msDictionary, msKeywords, pl2 as pl, pl as plDictionary, plKeywords, pluralRules, pluralTimeExpressions, profiles, pt2 as pt, pt as ptDictionary, ptKeywords, qu2 as qu, qu as quDictionary, quKeywords, quechuaProfile, reorderRoles, ru, russianDictionary as ruDictionary, ruKeywords, runtimeI18n, spanishProfile, supportedLocales, sw2 as sw, sw as swDictionary, swKeywords, swahiliProfile, th2 as th, th as thDictionary, thKeywords, tl2 as tl, tl as tlDictionary, tlKeywords, tokenize, tr2 as tr, tr as trDictionary, trKeywords, transformStatement, translateFromEnglish, turkishProfile, uk, ukrainianDictionary as ukDictionary, ukKeywords, validate, vi2 as vi, vi as viDictionary, viKeywords, withI18n, zh2 as zh, zh as zhDictionary, zhKeywords };
|
|
15949
14093
|
//# sourceMappingURL=index.js.map
|
|
15950
14094
|
//# sourceMappingURL=index.js.map
|