@lokascript/i18n 1.3.0 → 2.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/dist/browser.cjs +3625 -3581
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +9 -3
- package/dist/browser.d.ts +9 -3
- package/dist/browser.js +3595 -3582
- package/dist/browser.js.map +1 -1
- package/dist/dictionaries/index.cjs +0 -44
- package/dist/dictionaries/index.cjs.map +1 -1
- package/dist/dictionaries/index.d.cts +29 -80
- package/dist/dictionaries/index.d.ts +29 -80
- package/dist/dictionaries/index.js +0 -44
- package/dist/dictionaries/index.js.map +1 -1
- package/dist/index.cjs +7605 -7544
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -36
- package/dist/index.d.ts +36 -36
- package/dist/index.js +7576 -7545
- 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 +3792 -3813
- package/dist/lokascript-i18n.mjs.map +1 -1
- package/dist/plugins/vite.cjs +0 -42
- package/dist/plugins/vite.cjs.map +1 -1
- package/dist/plugins/vite.js +0 -42
- package/dist/plugins/vite.js.map +1 -1
- package/dist/plugins/webpack.cjs +0 -42
- package/dist/plugins/webpack.cjs.map +1 -1
- package/dist/plugins/webpack.js +0 -42
- package/dist/plugins/webpack.js.map +1 -1
- package/dist/{transformer-BBKJJ2vd.d.ts → transformer-DN_HqdDB.d.ts} +107 -14
- package/dist/{transformer-D8MM2_rz.d.cts → transformer-kXwlqa5b.d.cts} +107 -14
- package/package.json +7 -6
- package/src/browser.ts +22 -1
- package/src/dictionaries/ar.ts +0 -2
- package/src/dictionaries/de.ts +0 -2
- package/src/dictionaries/derive.ts +0 -2
- package/src/dictionaries/en.ts +0 -2
- package/src/dictionaries/es.ts +0 -2
- package/src/dictionaries/fr.ts +0 -2
- package/src/dictionaries/hi.ts +0 -2
- package/src/dictionaries/id.ts +0 -2
- package/src/dictionaries/index.ts +79 -163
- package/src/dictionaries/it.ts +0 -2
- package/src/dictionaries/ja.ts +0 -2
- package/src/dictionaries/ko.ts +0 -2
- package/src/dictionaries/ms.ts +0 -2
- package/src/dictionaries/pl.ts +0 -2
- package/src/dictionaries/pt.ts +0 -2
- package/src/dictionaries/qu.ts +0 -2
- package/src/dictionaries/ru.ts +0 -2
- package/src/dictionaries/sw.ts +0 -2
- package/src/dictionaries/tl.ts +0 -2
- package/src/dictionaries/tr.ts +0 -2
- package/src/dictionaries/uk.ts +0 -2
- package/src/dictionaries/vi.ts +0 -2
- package/src/dictionaries/zh.ts +0 -2
- package/src/grammar/direct-mappings.ts +0 -2
- package/src/grammar/grammar.test.ts +98 -0
- package/src/grammar/index.ts +9 -0
- package/src/grammar/transformer.ts +125 -73
- package/src/index.ts +30 -0
- package/src/parser/ar.ts +1 -1
- package/src/parser/bn.ts +9 -0
- package/src/parser/de.ts +1 -1
- package/src/parser/es.ts +1 -1
- package/src/parser/fr.ts +1 -1
- package/src/parser/hi.ts +9 -0
- package/src/parser/id.ts +1 -1
- package/src/parser/index.ts +10 -0
- package/src/parser/it.ts +9 -0
- package/src/parser/ja.ts +1 -1
- package/src/parser/ko.ts +1 -1
- package/src/parser/locale-manager.ts +1 -1
- package/src/parser/ms.ts +9 -0
- package/src/parser/pl.ts +9 -0
- package/src/parser/pt.ts +1 -1
- package/src/parser/qu.ts +1 -1
- package/src/parser/ru.ts +9 -0
- package/src/parser/sw.ts +1 -1
- package/src/parser/th.ts +9 -0
- package/src/parser/tl.ts +9 -0
- package/src/parser/tr.ts +1 -1
- package/src/parser/uk.ts +9 -0
- package/src/parser/vi.ts +9 -0
- package/src/parser/zh.ts +1 -1
- package/src/runtime.test.ts +152 -0
- package/src/runtime.ts +32 -13
- package/src/utils/locale.test.ts +108 -0
- package/src/utils/locale.ts +19 -25
|
@@ -19,70 +19,22 @@ import { getProfile, profiles } from './profiles';
|
|
|
19
19
|
import { hasDirectMapping, getDirectMapping } from './direct-mappings';
|
|
20
20
|
import { dictionaries } from '../dictionaries';
|
|
21
21
|
import { findInDictionary, translateFromEnglish } from '../types';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
ENGLISH_MODIFIER_ROLES,
|
|
24
|
+
ENGLISH_COMMANDS,
|
|
25
|
+
CONDITIONAL_KEYWORDS,
|
|
26
|
+
THEN_KEYWORDS,
|
|
27
|
+
} from '../constants';
|
|
23
28
|
|
|
24
29
|
// =============================================================================
|
|
25
30
|
// Compound Statement Handling
|
|
26
31
|
// =============================================================================
|
|
27
32
|
|
|
28
|
-
/**
|
|
29
|
-
* English commands that can start a new statement.
|
|
30
|
-
* Used to detect command boundaries in space-chained statements.
|
|
31
|
-
*/
|
|
32
|
-
const COMMAND_KEYWORDS = new Set([
|
|
33
|
-
'add',
|
|
34
|
-
'append',
|
|
35
|
-
'async',
|
|
36
|
-
'beep',
|
|
37
|
-
'break',
|
|
38
|
-
'call',
|
|
39
|
-
'continue',
|
|
40
|
-
'decrement',
|
|
41
|
-
'default',
|
|
42
|
-
'exit',
|
|
43
|
-
'fetch',
|
|
44
|
-
'for',
|
|
45
|
-
'get',
|
|
46
|
-
'go',
|
|
47
|
-
'halt',
|
|
48
|
-
'hide',
|
|
49
|
-
'if',
|
|
50
|
-
'increment',
|
|
51
|
-
'install',
|
|
52
|
-
'js',
|
|
53
|
-
'log',
|
|
54
|
-
'make',
|
|
55
|
-
'measure',
|
|
56
|
-
'morph',
|
|
57
|
-
'pick',
|
|
58
|
-
'process',
|
|
59
|
-
'push',
|
|
60
|
-
'put',
|
|
61
|
-
'remove',
|
|
62
|
-
'render',
|
|
63
|
-
'repeat',
|
|
64
|
-
'replace',
|
|
65
|
-
'return',
|
|
66
|
-
'send',
|
|
67
|
-
'set',
|
|
68
|
-
'settle',
|
|
69
|
-
'show',
|
|
70
|
-
'swap',
|
|
71
|
-
'take',
|
|
72
|
-
'tell',
|
|
73
|
-
'throw',
|
|
74
|
-
'toggle',
|
|
75
|
-
'transition',
|
|
76
|
-
'trigger',
|
|
77
|
-
'unless',
|
|
78
|
-
'wait',
|
|
79
|
-
]);
|
|
80
|
-
|
|
81
33
|
/**
|
|
82
34
|
* Get all command keywords including translated ones for a locale.
|
|
83
35
|
*/
|
|
84
36
|
function getCommandKeywordsForLocale(locale: string): Set<string> {
|
|
85
|
-
const keywords = new Set(
|
|
37
|
+
const keywords = new Set(ENGLISH_COMMANDS);
|
|
86
38
|
|
|
87
39
|
// Add translated command keywords from dictionaries
|
|
88
40
|
const dict = dictionaries[locale];
|
|
@@ -119,7 +71,7 @@ function splitCompoundStatement(input: string, sourceLocale: string): string[] {
|
|
|
119
71
|
|
|
120
72
|
// If we have multiple lines, treat each as a separate part
|
|
121
73
|
// (but still need to handle "then" within each line)
|
|
122
|
-
|
|
74
|
+
const parts: string[] = [];
|
|
123
75
|
|
|
124
76
|
for (const line of lines) {
|
|
125
77
|
const lineParts = splitOnThen(line, sourceLocale);
|
|
@@ -298,6 +250,21 @@ function reconstructWithLineStructure(
|
|
|
298
250
|
* - "on <event> <command>" stays together (event handler with first command)
|
|
299
251
|
* - Modifiers like "to", "from" don't trigger splits
|
|
300
252
|
*/
|
|
253
|
+
/** Modifier keywords that should not trigger command boundary splits */
|
|
254
|
+
const BOUNDARY_MODIFIERS = new Set([
|
|
255
|
+
'to',
|
|
256
|
+
'into',
|
|
257
|
+
'from',
|
|
258
|
+
'with',
|
|
259
|
+
'by',
|
|
260
|
+
'as',
|
|
261
|
+
'at',
|
|
262
|
+
'in',
|
|
263
|
+
'on',
|
|
264
|
+
'of',
|
|
265
|
+
'over',
|
|
266
|
+
]);
|
|
267
|
+
|
|
301
268
|
function splitOnCommandBoundaries(input: string, sourceLocale: string): string[] {
|
|
302
269
|
const commandKeywords = getCommandKeywordsForLocale(sourceLocale);
|
|
303
270
|
const tokens = input.split(/\s+/);
|
|
@@ -325,21 +292,6 @@ function splitOnCommandBoundaries(input: string, sourceLocale: string): string[]
|
|
|
325
292
|
const prevToken = currentPart[currentPart.length - 1];
|
|
326
293
|
const prevLower = prevToken.toLowerCase();
|
|
327
294
|
|
|
328
|
-
// Don't split if the previous token is a modifier like "to", "from", "by", etc.
|
|
329
|
-
const modifiers = new Set([
|
|
330
|
-
'to',
|
|
331
|
-
'into',
|
|
332
|
-
'from',
|
|
333
|
-
'with',
|
|
334
|
-
'by',
|
|
335
|
-
'as',
|
|
336
|
-
'at',
|
|
337
|
-
'in',
|
|
338
|
-
'on',
|
|
339
|
-
'of',
|
|
340
|
-
'over',
|
|
341
|
-
]);
|
|
342
|
-
|
|
343
295
|
// For event handlers: don't split before the first command
|
|
344
296
|
// E.g., "on click wait 1s" should stay together
|
|
345
297
|
if (!seenFirstCommand) {
|
|
@@ -349,7 +301,7 @@ function splitOnCommandBoundaries(input: string, sourceLocale: string): string[]
|
|
|
349
301
|
continue;
|
|
350
302
|
}
|
|
351
303
|
|
|
352
|
-
if (!
|
|
304
|
+
if (!BOUNDARY_MODIFIERS.has(prevLower) && !commandKeywords.has(prevLower)) {
|
|
353
305
|
// This looks like a command boundary - save current part and start new one
|
|
354
306
|
parts.push(currentPart.join(' '));
|
|
355
307
|
currentPart = [token];
|
|
@@ -693,7 +645,28 @@ function parseEventHandler(tokens: string[], profile: LanguageProfile): ParsedSt
|
|
|
693
645
|
startIndex++;
|
|
694
646
|
}
|
|
695
647
|
|
|
696
|
-
//
|
|
648
|
+
// Check for event source modifier before the action (e.g., "from #source" in "on input from #firstName set ...")
|
|
649
|
+
// Only handle 'from' (event source) — other modifiers like circumfix markers (Chinese 时) should not be consumed.
|
|
650
|
+
if (tokens[startIndex] && tokens[startIndex].toLowerCase() === 'from' && tokens[startIndex + 1]) {
|
|
651
|
+
startIndex++; // skip 'from'
|
|
652
|
+
// Collect source value tokens until a command keyword is found
|
|
653
|
+
const sourceValue: string[] = [];
|
|
654
|
+
while (tokens[startIndex]) {
|
|
655
|
+
if (ENGLISH_COMMANDS.has(tokens[startIndex].toLowerCase())) break;
|
|
656
|
+
sourceValue.push(tokens[startIndex]);
|
|
657
|
+
startIndex++;
|
|
658
|
+
}
|
|
659
|
+
if (sourceValue.length > 0) {
|
|
660
|
+
const value = sourceValue.join(' ');
|
|
661
|
+
roles.set('source', {
|
|
662
|
+
role: 'source',
|
|
663
|
+
value,
|
|
664
|
+
isSelector: /^[#.<@]/.test(value),
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// Next token is the action (command verb)
|
|
697
670
|
if (tokens[startIndex]) {
|
|
698
671
|
roles.set('action', {
|
|
699
672
|
role: 'action',
|
|
@@ -948,10 +921,77 @@ function translatePossessive(token: string, sourceLocale: string, targetLocale:
|
|
|
948
921
|
}
|
|
949
922
|
}
|
|
950
923
|
|
|
924
|
+
// =============================================================================
|
|
925
|
+
// Possessive Dot Notation
|
|
926
|
+
// =============================================================================
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* Regex to match possessive dot notation patterns.
|
|
930
|
+
* Matches: my.prop, its.prop, your.prop, me.prop, it.prop, you.prop
|
|
931
|
+
* Also matches optional chaining: my?.prop, me?.prop, etc.
|
|
932
|
+
*/
|
|
933
|
+
const POSSESSIVE_DOT_REGEX = /^(my|its|your|me|it|you)(\??\..+)$/i;
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Map pronoun forms to possessive adjective forms for dictionary lookup.
|
|
937
|
+
*/
|
|
938
|
+
const POSSESSIVE_DOT_PRONOUNS: Record<string, string> = {
|
|
939
|
+
me: 'my',
|
|
940
|
+
it: 'its',
|
|
941
|
+
you: 'your',
|
|
942
|
+
my: 'my',
|
|
943
|
+
its: 'its',
|
|
944
|
+
your: 'your',
|
|
945
|
+
};
|
|
946
|
+
|
|
947
|
+
/**
|
|
948
|
+
* Translate possessive dot notation like my.textContent → mi.textContent.
|
|
949
|
+
* Handles both possessive adjective forms (my, its, your) and pronoun forms (me, it, you).
|
|
950
|
+
* Also handles optional chaining (my?.prop).
|
|
951
|
+
* Returns null if the value doesn't match or no translation is available.
|
|
952
|
+
*/
|
|
953
|
+
function translatePossessiveDotNotation(
|
|
954
|
+
value: string,
|
|
955
|
+
sourceLocale: string,
|
|
956
|
+
targetLocale: string
|
|
957
|
+
): string | null {
|
|
958
|
+
const match = value.match(POSSESSIVE_DOT_REGEX);
|
|
959
|
+
if (!match) return null;
|
|
960
|
+
|
|
961
|
+
const possessiveWord = match[1].toLowerCase();
|
|
962
|
+
const propertySuffix = match[2]; // ".textContent" or "?.textContent"
|
|
963
|
+
|
|
964
|
+
// Normalize to possessive adjective form for dictionary lookup
|
|
965
|
+
const possessiveKey = POSSESSIVE_DOT_PRONOUNS[possessiveWord] || possessiveWord;
|
|
966
|
+
const translated = translateWord(possessiveKey, sourceLocale, targetLocale);
|
|
967
|
+
|
|
968
|
+
// Skip if translation is multi-word (can't prefix dot notation)
|
|
969
|
+
if (translated.includes(' ')) return null;
|
|
970
|
+
|
|
971
|
+
if (translated !== possessiveKey) {
|
|
972
|
+
return translated + propertySuffix;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
// Try original pronoun form if different from possessive key
|
|
976
|
+
if (possessiveWord !== possessiveKey) {
|
|
977
|
+
const alt = translateWord(possessiveWord, sourceLocale, targetLocale);
|
|
978
|
+
if (alt !== possessiveWord && !alt.includes(' ')) {
|
|
979
|
+
return alt + propertySuffix;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
return null;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
// =============================================================================
|
|
987
|
+
// Multi-Word Value Translation
|
|
988
|
+
// =============================================================================
|
|
989
|
+
|
|
951
990
|
/**
|
|
952
991
|
* Translate a multi-word value, translating each word individually.
|
|
953
992
|
* Handles possessives like "my value" → "mi valor" in Spanish.
|
|
954
993
|
* Also handles 's possessive syntax like "me's value" → "mi valor".
|
|
994
|
+
* Also handles possessive dot notation like "my.textContent" → "mi.textContent".
|
|
955
995
|
*/
|
|
956
996
|
function translateMultiWordValue(
|
|
957
997
|
value: string,
|
|
@@ -964,6 +1004,10 @@ function translateMultiWordValue(
|
|
|
964
1004
|
if (value.includes("'s")) {
|
|
965
1005
|
return translatePossessive(value, sourceLocale, targetLocale);
|
|
966
1006
|
}
|
|
1007
|
+
// Check for possessive dot notation (my.prop, its.prop, me.prop, etc.)
|
|
1008
|
+
const dotResult = translatePossessiveDotNotation(value, sourceLocale, targetLocale);
|
|
1009
|
+
if (dotResult !== null) return dotResult;
|
|
1010
|
+
|
|
967
1011
|
return translateWord(value, sourceLocale, targetLocale);
|
|
968
1012
|
}
|
|
969
1013
|
|
|
@@ -1020,6 +1064,14 @@ function translateMultiWordValue(
|
|
|
1020
1064
|
continue;
|
|
1021
1065
|
}
|
|
1022
1066
|
|
|
1067
|
+
// Check for possessive dot notation (my.prop, its.prop, me.prop, etc.)
|
|
1068
|
+
const dotResult = translatePossessiveDotNotation(word, sourceLocale, targetLocale);
|
|
1069
|
+
if (dotResult !== null) {
|
|
1070
|
+
translated.push(dotResult);
|
|
1071
|
+
i++;
|
|
1072
|
+
continue;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1023
1075
|
translated.push(translateWord(word, sourceLocale, targetLocale));
|
|
1024
1076
|
i++;
|
|
1025
1077
|
}
|
package/src/index.ts
CHANGED
|
@@ -53,6 +53,16 @@ export {
|
|
|
53
53
|
qu,
|
|
54
54
|
sw,
|
|
55
55
|
pt,
|
|
56
|
+
it,
|
|
57
|
+
vi,
|
|
58
|
+
pl,
|
|
59
|
+
ru,
|
|
60
|
+
uk,
|
|
61
|
+
hi,
|
|
62
|
+
bn,
|
|
63
|
+
th,
|
|
64
|
+
ms,
|
|
65
|
+
tl,
|
|
56
66
|
supportedLocales,
|
|
57
67
|
isLocaleSupported,
|
|
58
68
|
getDictionary,
|
|
@@ -95,6 +105,26 @@ export {
|
|
|
95
105
|
swDictionary,
|
|
96
106
|
ptKeywords,
|
|
97
107
|
ptDictionary,
|
|
108
|
+
itKeywords,
|
|
109
|
+
itDictionary,
|
|
110
|
+
viKeywords,
|
|
111
|
+
viDictionary,
|
|
112
|
+
plKeywords,
|
|
113
|
+
plDictionary,
|
|
114
|
+
ruKeywords,
|
|
115
|
+
ruDictionary,
|
|
116
|
+
ukKeywords,
|
|
117
|
+
ukDictionary,
|
|
118
|
+
hiKeywords,
|
|
119
|
+
hiDictionary,
|
|
120
|
+
bnKeywords,
|
|
121
|
+
bnDictionary,
|
|
122
|
+
thKeywords,
|
|
123
|
+
thDictionary,
|
|
124
|
+
msKeywords,
|
|
125
|
+
msDictionary,
|
|
126
|
+
tlKeywords,
|
|
127
|
+
tlDictionary,
|
|
98
128
|
// Locale management
|
|
99
129
|
LocaleManager,
|
|
100
130
|
detectBrowserLocale,
|
package/src/parser/ar.ts
CHANGED
|
@@ -26,7 +26,7 @@ import type { KeywordProvider } from './types';
|
|
|
26
26
|
* @example
|
|
27
27
|
* ```typescript
|
|
28
28
|
* import { arKeywords } from '@lokascript/i18n/parser/ar';
|
|
29
|
-
* import { Parser } from '@
|
|
29
|
+
* import { Parser } from '@hyperfixi/core';
|
|
30
30
|
*
|
|
31
31
|
* const parser = new Parser({ keywords: arKeywords });
|
|
32
32
|
* parser.parse('على نقر بدل .active');
|
package/src/parser/bn.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { bn } from '../dictionaries/bn';
|
|
2
|
+
import { createKeywordProvider } from './create-provider';
|
|
3
|
+
import type { KeywordProvider } from './types';
|
|
4
|
+
|
|
5
|
+
export const bnKeywords: KeywordProvider = createKeywordProvider(bn, 'bn', {
|
|
6
|
+
allowEnglishFallback: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { bn as bnDictionary } from '../dictionaries/bn';
|
package/src/parser/de.ts
CHANGED
|
@@ -22,7 +22,7 @@ import type { KeywordProvider } from './types';
|
|
|
22
22
|
* @example
|
|
23
23
|
* ```typescript
|
|
24
24
|
* import { deKeywords } from '@lokascript/i18n/parser/de';
|
|
25
|
-
* import { Parser } from '@
|
|
25
|
+
* import { Parser } from '@hyperfixi/core';
|
|
26
26
|
*
|
|
27
27
|
* const parser = new Parser({ keywords: deKeywords });
|
|
28
28
|
* parser.parse('bei klick umschalten .active');
|
package/src/parser/es.ts
CHANGED
|
@@ -17,7 +17,7 @@ import type { KeywordProvider } from './types';
|
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
|
19
19
|
* import { esKeywords } from '@lokascript/i18n/parser/es';
|
|
20
|
-
* import { Parser } from '@
|
|
20
|
+
* import { Parser } from '@hyperfixi/core';
|
|
21
21
|
*
|
|
22
22
|
* const parser = new Parser({ keywords: esKeywords });
|
|
23
23
|
* parser.parse('en clic alternar .active');
|
package/src/parser/fr.ts
CHANGED
|
@@ -17,7 +17,7 @@ import type { KeywordProvider } from './types';
|
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
|
19
19
|
* import { frKeywords } from '@lokascript/i18n/parser/fr';
|
|
20
|
-
* import { Parser } from '@
|
|
20
|
+
* import { Parser } from '@hyperfixi/core';
|
|
21
21
|
*
|
|
22
22
|
* const parser = new Parser({ keywords: frKeywords });
|
|
23
23
|
* parser.parse('sur clic basculer .active');
|
package/src/parser/hi.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { hindiDictionary } from '../dictionaries/hi';
|
|
2
|
+
import { createKeywordProvider } from './create-provider';
|
|
3
|
+
import type { KeywordProvider } from './types';
|
|
4
|
+
|
|
5
|
+
export const hiKeywords: KeywordProvider = createKeywordProvider(hindiDictionary, 'hi', {
|
|
6
|
+
allowEnglishFallback: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { hindiDictionary as hiDictionary } from '../dictionaries/hi';
|
package/src/parser/id.ts
CHANGED
|
@@ -20,7 +20,7 @@ import type { KeywordProvider } from './types';
|
|
|
20
20
|
* @example
|
|
21
21
|
* ```typescript
|
|
22
22
|
* import { idKeywords } from '@lokascript/i18n/parser/id';
|
|
23
|
-
* import { Parser } from '@
|
|
23
|
+
* import { Parser } from '@hyperfixi/core';
|
|
24
24
|
*
|
|
25
25
|
* const parser = new Parser({ keywords: idKeywords });
|
|
26
26
|
* parser.parse('pada klik ganti .active');
|
package/src/parser/index.ts
CHANGED
|
@@ -45,6 +45,16 @@ export { idKeywords, idDictionary } from './id';
|
|
|
45
45
|
export { quKeywords, quDictionary } from './qu';
|
|
46
46
|
export { swKeywords, swDictionary } from './sw';
|
|
47
47
|
export { ptKeywords, ptDictionary } from './pt';
|
|
48
|
+
export { itKeywords, itDictionary } from './it';
|
|
49
|
+
export { viKeywords, viDictionary } from './vi';
|
|
50
|
+
export { plKeywords, plDictionary } from './pl';
|
|
51
|
+
export { ruKeywords, ruDictionary } from './ru';
|
|
52
|
+
export { ukKeywords, ukDictionary } from './uk';
|
|
53
|
+
export { hiKeywords, hiDictionary } from './hi';
|
|
54
|
+
export { bnKeywords, bnDictionary } from './bn';
|
|
55
|
+
export { thKeywords, thDictionary } from './th';
|
|
56
|
+
export { msKeywords, msDictionary } from './ms';
|
|
57
|
+
export { tlKeywords, tlDictionary } from './tl';
|
|
48
58
|
|
|
49
59
|
// Locale management
|
|
50
60
|
export { LocaleManager, detectBrowserLocale } from './locale-manager';
|
package/src/parser/it.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { it } from '../dictionaries/it';
|
|
2
|
+
import { createKeywordProvider } from './create-provider';
|
|
3
|
+
import type { KeywordProvider } from './types';
|
|
4
|
+
|
|
5
|
+
export const itKeywords: KeywordProvider = createKeywordProvider(it, 'it', {
|
|
6
|
+
allowEnglishFallback: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { it as itDictionary } from '../dictionaries/it';
|
package/src/parser/ja.ts
CHANGED
|
@@ -22,7 +22,7 @@ import type { KeywordProvider } from './types';
|
|
|
22
22
|
* @example
|
|
23
23
|
* ```typescript
|
|
24
24
|
* import { jaKeywords } from '@lokascript/i18n/parser/ja';
|
|
25
|
-
* import { Parser } from '@
|
|
25
|
+
* import { Parser } from '@hyperfixi/core';
|
|
26
26
|
*
|
|
27
27
|
* const parser = new Parser({ keywords: jaKeywords });
|
|
28
28
|
* parser.parse('クリック で 切り替え .active');
|
package/src/parser/ko.ts
CHANGED
|
@@ -23,7 +23,7 @@ import type { KeywordProvider } from './types';
|
|
|
23
23
|
* @example
|
|
24
24
|
* ```typescript
|
|
25
25
|
* import { koKeywords } from '@lokascript/i18n/parser/ko';
|
|
26
|
-
* import { Parser } from '@
|
|
26
|
+
* import { Parser } from '@hyperfixi/core';
|
|
27
27
|
*
|
|
28
28
|
* const parser = new Parser({ keywords: koKeywords });
|
|
29
29
|
* parser.parse('에 클릭 토글 .active');
|
|
@@ -169,7 +169,7 @@ export class LocaleManager {
|
|
|
169
169
|
* @example
|
|
170
170
|
* ```typescript
|
|
171
171
|
* import { detectBrowserLocale } from '@lokascript/i18n/parser';
|
|
172
|
-
* import { Parser } from '@
|
|
172
|
+
* import { Parser } from '@hyperfixi/core';
|
|
173
173
|
*
|
|
174
174
|
* // Auto-detect and use browser locale
|
|
175
175
|
* const parser = new Parser({ keywords: detectBrowserLocale() });
|
package/src/parser/ms.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ms } from '../dictionaries/ms';
|
|
2
|
+
import { createKeywordProvider } from './create-provider';
|
|
3
|
+
import type { KeywordProvider } from './types';
|
|
4
|
+
|
|
5
|
+
export const msKeywords: KeywordProvider = createKeywordProvider(ms, 'ms', {
|
|
6
|
+
allowEnglishFallback: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { ms as msDictionary } from '../dictionaries/ms';
|
package/src/parser/pl.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { pl } from '../dictionaries/pl';
|
|
2
|
+
import { createKeywordProvider } from './create-provider';
|
|
3
|
+
import type { KeywordProvider } from './types';
|
|
4
|
+
|
|
5
|
+
export const plKeywords: KeywordProvider = createKeywordProvider(pl, 'pl', {
|
|
6
|
+
allowEnglishFallback: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { pl as plDictionary } from '../dictionaries/pl';
|
package/src/parser/pt.ts
CHANGED
|
@@ -23,7 +23,7 @@ import type { KeywordProvider } from './types';
|
|
|
23
23
|
* @example
|
|
24
24
|
* ```typescript
|
|
25
25
|
* import { ptKeywords } from '@lokascript/i18n/parser/pt';
|
|
26
|
-
* import { Parser } from '@
|
|
26
|
+
* import { Parser } from '@hyperfixi/core';
|
|
27
27
|
*
|
|
28
28
|
* const parser = new Parser({ keywords: ptKeywords });
|
|
29
29
|
* parser.parse('em clique alternar .active');
|
package/src/parser/qu.ts
CHANGED
|
@@ -23,7 +23,7 @@ import type { KeywordProvider } from './types';
|
|
|
23
23
|
* @example
|
|
24
24
|
* ```typescript
|
|
25
25
|
* import { quKeywords } from '@lokascript/i18n/parser/qu';
|
|
26
|
-
* import { Parser } from '@
|
|
26
|
+
* import { Parser } from '@hyperfixi/core';
|
|
27
27
|
*
|
|
28
28
|
* const parser = new Parser({ keywords: quKeywords });
|
|
29
29
|
* parser.parse('ñitiy-pi yapay #count-ta');
|
package/src/parser/ru.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { russianDictionary } from '../dictionaries/ru';
|
|
2
|
+
import { createKeywordProvider } from './create-provider';
|
|
3
|
+
import type { KeywordProvider } from './types';
|
|
4
|
+
|
|
5
|
+
export const ruKeywords: KeywordProvider = createKeywordProvider(russianDictionary, 'ru', {
|
|
6
|
+
allowEnglishFallback: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { russianDictionary as ruDictionary } from '../dictionaries/ru';
|
package/src/parser/sw.ts
CHANGED
|
@@ -23,7 +23,7 @@ import type { KeywordProvider } from './types';
|
|
|
23
23
|
* @example
|
|
24
24
|
* ```typescript
|
|
25
25
|
* import { swKeywords } from '@lokascript/i18n/parser/sw';
|
|
26
|
-
* import { Parser } from '@
|
|
26
|
+
* import { Parser } from '@hyperfixi/core';
|
|
27
27
|
*
|
|
28
28
|
* const parser = new Parser({ keywords: swKeywords });
|
|
29
29
|
* parser.parse('kwenye bonyeza badilisha .active');
|
package/src/parser/th.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { th } from '../dictionaries/th';
|
|
2
|
+
import { createKeywordProvider } from './create-provider';
|
|
3
|
+
import type { KeywordProvider } from './types';
|
|
4
|
+
|
|
5
|
+
export const thKeywords: KeywordProvider = createKeywordProvider(th, 'th', {
|
|
6
|
+
allowEnglishFallback: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { th as thDictionary } from '../dictionaries/th';
|
package/src/parser/tl.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { tl } from '../dictionaries/tl';
|
|
2
|
+
import { createKeywordProvider } from './create-provider';
|
|
3
|
+
import type { KeywordProvider } from './types';
|
|
4
|
+
|
|
5
|
+
export const tlKeywords: KeywordProvider = createKeywordProvider(tl, 'tl', {
|
|
6
|
+
allowEnglishFallback: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { tl as tlDictionary } from '../dictionaries/tl';
|
package/src/parser/tr.ts
CHANGED
|
@@ -24,7 +24,7 @@ import type { KeywordProvider } from './types';
|
|
|
24
24
|
* @example
|
|
25
25
|
* ```typescript
|
|
26
26
|
* import { trKeywords } from '@lokascript/i18n/parser/tr';
|
|
27
|
-
* import { Parser } from '@
|
|
27
|
+
* import { Parser } from '@hyperfixi/core';
|
|
28
28
|
*
|
|
29
29
|
* const parser = new Parser({ keywords: trKeywords });
|
|
30
30
|
* parser.parse('üzerinde tıklama değiştir .active');
|
package/src/parser/uk.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ukrainianDictionary } from '../dictionaries/uk';
|
|
2
|
+
import { createKeywordProvider } from './create-provider';
|
|
3
|
+
import type { KeywordProvider } from './types';
|
|
4
|
+
|
|
5
|
+
export const ukKeywords: KeywordProvider = createKeywordProvider(ukrainianDictionary, 'uk', {
|
|
6
|
+
allowEnglishFallback: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { ukrainianDictionary as ukDictionary } from '../dictionaries/uk';
|
package/src/parser/vi.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { vi } from '../dictionaries/vi';
|
|
2
|
+
import { createKeywordProvider } from './create-provider';
|
|
3
|
+
import type { KeywordProvider } from './types';
|
|
4
|
+
|
|
5
|
+
export const viKeywords: KeywordProvider = createKeywordProvider(vi, 'vi', {
|
|
6
|
+
allowEnglishFallback: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { vi as viDictionary } from '../dictionaries/vi';
|
package/src/parser/zh.ts
CHANGED
|
@@ -24,7 +24,7 @@ import type { KeywordProvider } from './types';
|
|
|
24
24
|
* @example
|
|
25
25
|
* ```typescript
|
|
26
26
|
* import { zhKeywords } from '@lokascript/i18n/parser/zh';
|
|
27
|
-
* import { Parser } from '@
|
|
27
|
+
* import { Parser } from '@hyperfixi/core';
|
|
28
28
|
*
|
|
29
29
|
* const parser = new Parser({ keywords: zhKeywords });
|
|
30
30
|
* parser.parse('当 点击 切换 .active');
|