@lokascript/i18n 1.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.
Files changed (96) hide show
  1. package/README.md +286 -0
  2. package/dist/browser.cjs +7669 -0
  3. package/dist/browser.cjs.map +1 -0
  4. package/dist/browser.d.cts +50 -0
  5. package/dist/browser.d.ts +50 -0
  6. package/dist/browser.js +7592 -0
  7. package/dist/browser.js.map +1 -0
  8. package/dist/hyperfixi-i18n.min.js +2 -0
  9. package/dist/hyperfixi-i18n.min.js.map +1 -0
  10. package/dist/hyperfixi-i18n.mjs +8558 -0
  11. package/dist/hyperfixi-i18n.mjs.map +1 -0
  12. package/dist/index.cjs +14205 -0
  13. package/dist/index.cjs.map +1 -0
  14. package/dist/index.d.cts +947 -0
  15. package/dist/index.d.ts +947 -0
  16. package/dist/index.js +14095 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/transformer-Ckask-yw.d.cts +1041 -0
  19. package/dist/transformer-Ckask-yw.d.ts +1041 -0
  20. package/package.json +84 -0
  21. package/src/browser.ts +122 -0
  22. package/src/compatibility/browser-tests/grammar-demo.spec.ts +169 -0
  23. package/src/constants.ts +366 -0
  24. package/src/dictionaries/ar.ts +233 -0
  25. package/src/dictionaries/bn.ts +156 -0
  26. package/src/dictionaries/de.ts +233 -0
  27. package/src/dictionaries/derive.ts +515 -0
  28. package/src/dictionaries/en.ts +237 -0
  29. package/src/dictionaries/es.ts +233 -0
  30. package/src/dictionaries/fr.ts +233 -0
  31. package/src/dictionaries/hi.ts +270 -0
  32. package/src/dictionaries/id.ts +233 -0
  33. package/src/dictionaries/index.ts +238 -0
  34. package/src/dictionaries/it.ts +233 -0
  35. package/src/dictionaries/ja.ts +233 -0
  36. package/src/dictionaries/ko.ts +233 -0
  37. package/src/dictionaries/ms.ts +276 -0
  38. package/src/dictionaries/pl.ts +239 -0
  39. package/src/dictionaries/pt.ts +237 -0
  40. package/src/dictionaries/qu.ts +233 -0
  41. package/src/dictionaries/ru.ts +270 -0
  42. package/src/dictionaries/sw.ts +233 -0
  43. package/src/dictionaries/th.ts +156 -0
  44. package/src/dictionaries/tl.ts +276 -0
  45. package/src/dictionaries/tr.ts +233 -0
  46. package/src/dictionaries/uk.ts +270 -0
  47. package/src/dictionaries/vi.ts +210 -0
  48. package/src/dictionaries/zh.ts +233 -0
  49. package/src/enhanced-i18n.test.ts +454 -0
  50. package/src/enhanced-i18n.ts +713 -0
  51. package/src/examples/new-languages.ts +326 -0
  52. package/src/formatting.test.ts +213 -0
  53. package/src/formatting.ts +416 -0
  54. package/src/grammar/direct-mappings.ts +353 -0
  55. package/src/grammar/grammar.test.ts +1053 -0
  56. package/src/grammar/index.ts +59 -0
  57. package/src/grammar/profiles/index.ts +860 -0
  58. package/src/grammar/transformer.ts +1318 -0
  59. package/src/grammar/types.ts +630 -0
  60. package/src/index.ts +202 -0
  61. package/src/new-languages.test.ts +389 -0
  62. package/src/parser/analyze-conflicts.test.ts +229 -0
  63. package/src/parser/ar.ts +40 -0
  64. package/src/parser/create-provider.ts +309 -0
  65. package/src/parser/de.ts +36 -0
  66. package/src/parser/es.ts +31 -0
  67. package/src/parser/fr.ts +31 -0
  68. package/src/parser/id.ts +34 -0
  69. package/src/parser/index.ts +50 -0
  70. package/src/parser/ja.ts +36 -0
  71. package/src/parser/ko.ts +37 -0
  72. package/src/parser/locale-manager.test.ts +198 -0
  73. package/src/parser/locale-manager.ts +197 -0
  74. package/src/parser/parser-integration.test.ts +439 -0
  75. package/src/parser/pt.ts +37 -0
  76. package/src/parser/qu.ts +37 -0
  77. package/src/parser/sw.ts +37 -0
  78. package/src/parser/tr.ts +38 -0
  79. package/src/parser/types.ts +113 -0
  80. package/src/parser/zh.ts +38 -0
  81. package/src/plugins/vite.ts +224 -0
  82. package/src/plugins/webpack.ts +124 -0
  83. package/src/pluralization.test.ts +197 -0
  84. package/src/pluralization.ts +393 -0
  85. package/src/runtime.ts +441 -0
  86. package/src/ssr-integration.ts +225 -0
  87. package/src/test-setup.ts +195 -0
  88. package/src/translation-validation.test.ts +171 -0
  89. package/src/translator.test.ts +252 -0
  90. package/src/translator.ts +297 -0
  91. package/src/types.ts +209 -0
  92. package/src/utils/locale.ts +190 -0
  93. package/src/utils/tokenizer-adapter.ts +469 -0
  94. package/src/utils/tokenizer.ts +19 -0
  95. package/src/validators/index.ts +174 -0
  96. package/src/validators/schema.ts +129 -0
@@ -0,0 +1,50 @@
1
+ export { D as AdpositionType, E as ENGLISH_COMMANDS, d as ENGLISH_KEYWORDS, H as GrammarRule, ac as GrammarTransformer, G as GrammaticalMarker, K as KeywordProvider, a as KeywordProviderOptions, Q as LANGUAGE_FAMILY_DEFAULTS, F as LanguageProfile, L as LocaleManager, M as MorphologyType, N as ParsedElement, J as ParsedStatement, P as PatternMatcher, I as PatternTransform, S as SemanticRole, U as UNIVERSAL_ENGLISH_KEYWORDS, O as UNIVERSAL_PATTERNS, W as WordOrder, n as ar, n as arDictionary, m as arKeywords, a3 as arabicProfile, a2 as chineseProfile, b as createEnglishProvider, c as createKeywordProvider, l as de, l as deDictionary, k as deKeywords, C as detectBrowserLocale, $ as englishProfile, f as es, f as esDictionary, e as esKeywords, i as fr, i as frDictionary, h as frKeywords, a7 as frenchProfile, a6 as germanProfile, Z as getProfile, _ as getSupportedLocales, ah as grammarExamples, u as id, u as idDictionary, s as idKeywords, a9 as indonesianProfile, T as insertMarkers, g as ja, g as jaDictionary, j as jaKeywords, a0 as japaneseProfile, V as joinTokens, p as ko, p as koDictionary, o as koKeywords, a1 as koreanProfile, ad as parseStatement, a8 as portugueseProfile, Y as profiles, B as pt, B as ptDictionary, A as ptKeywords, w as qu, w as quDictionary, v as quKeywords, aa as quechuaProfile, R as reorderRoles, a5 as spanishProfile, y as sw, y as swDictionary, x as swKeywords, ab as swahiliProfile, af as toEnglish, ae as toLocale, r as tr, r as trDictionary, t as trKeywords, X as transformStatement, ag as translate, a4 as turkishProfile, q as zh, q as zhDictionary, z as zhKeywords } from './transformer-Ckask-yw.cjs';
2
+
3
+ /**
4
+ * Direct Language-Pair Mappings
5
+ *
6
+ * Enables translation between language pairs without English pivot.
7
+ * This reduces error compounding and provides more natural translations
8
+ * for closely related languages or those with shared vocabulary.
9
+ *
10
+ * Currently supported pairs:
11
+ * - Japanese ↔ Chinese (shared Kanji concepts)
12
+ * - Spanish ↔ Portuguese (Romance language mutual intelligibility)
13
+ * - Korean ↔ Japanese (SOV grammar similarity)
14
+ */
15
+ interface DirectMapping {
16
+ /** Source language code */
17
+ source: string;
18
+ /** Target language code */
19
+ target: string;
20
+ /** Word mappings: source word -> target word */
21
+ words: Record<string, string>;
22
+ /** Category mappings for structured translation */
23
+ categories?: Record<string, Record<string, string>>;
24
+ }
25
+ /**
26
+ * Registry of direct translation pairs.
27
+ * Key format: "source->target" (e.g., "ja->zh")
28
+ */
29
+ declare const directMappings: Map<string, DirectMapping>;
30
+ /**
31
+ * Check if direct mapping exists for a language pair
32
+ */
33
+ declare function hasDirectMapping(source: string, target: string): boolean;
34
+ /**
35
+ * Get direct mapping for a language pair
36
+ */
37
+ declare function getDirectMapping(source: string, target: string): DirectMapping | undefined;
38
+ /**
39
+ * Translate a single word using direct mapping
40
+ */
41
+ declare function translateWordDirect(word: string, source: string, target: string): string | undefined;
42
+ /**
43
+ * Get all supported direct translation pairs
44
+ */
45
+ declare function getSupportedDirectPairs(): Array<{
46
+ source: string;
47
+ target: string;
48
+ }>;
49
+
50
+ export { directMappings, getDirectMapping, getSupportedDirectPairs, hasDirectMapping, translateWordDirect };
@@ -0,0 +1,50 @@
1
+ export { D as AdpositionType, E as ENGLISH_COMMANDS, d as ENGLISH_KEYWORDS, H as GrammarRule, ac as GrammarTransformer, G as GrammaticalMarker, K as KeywordProvider, a as KeywordProviderOptions, Q as LANGUAGE_FAMILY_DEFAULTS, F as LanguageProfile, L as LocaleManager, M as MorphologyType, N as ParsedElement, J as ParsedStatement, P as PatternMatcher, I as PatternTransform, S as SemanticRole, U as UNIVERSAL_ENGLISH_KEYWORDS, O as UNIVERSAL_PATTERNS, W as WordOrder, n as ar, n as arDictionary, m as arKeywords, a3 as arabicProfile, a2 as chineseProfile, b as createEnglishProvider, c as createKeywordProvider, l as de, l as deDictionary, k as deKeywords, C as detectBrowserLocale, $ as englishProfile, f as es, f as esDictionary, e as esKeywords, i as fr, i as frDictionary, h as frKeywords, a7 as frenchProfile, a6 as germanProfile, Z as getProfile, _ as getSupportedLocales, ah as grammarExamples, u as id, u as idDictionary, s as idKeywords, a9 as indonesianProfile, T as insertMarkers, g as ja, g as jaDictionary, j as jaKeywords, a0 as japaneseProfile, V as joinTokens, p as ko, p as koDictionary, o as koKeywords, a1 as koreanProfile, ad as parseStatement, a8 as portugueseProfile, Y as profiles, B as pt, B as ptDictionary, A as ptKeywords, w as qu, w as quDictionary, v as quKeywords, aa as quechuaProfile, R as reorderRoles, a5 as spanishProfile, y as sw, y as swDictionary, x as swKeywords, ab as swahiliProfile, af as toEnglish, ae as toLocale, r as tr, r as trDictionary, t as trKeywords, X as transformStatement, ag as translate, a4 as turkishProfile, q as zh, q as zhDictionary, z as zhKeywords } from './transformer-Ckask-yw.js';
2
+
3
+ /**
4
+ * Direct Language-Pair Mappings
5
+ *
6
+ * Enables translation between language pairs without English pivot.
7
+ * This reduces error compounding and provides more natural translations
8
+ * for closely related languages or those with shared vocabulary.
9
+ *
10
+ * Currently supported pairs:
11
+ * - Japanese ↔ Chinese (shared Kanji concepts)
12
+ * - Spanish ↔ Portuguese (Romance language mutual intelligibility)
13
+ * - Korean ↔ Japanese (SOV grammar similarity)
14
+ */
15
+ interface DirectMapping {
16
+ /** Source language code */
17
+ source: string;
18
+ /** Target language code */
19
+ target: string;
20
+ /** Word mappings: source word -> target word */
21
+ words: Record<string, string>;
22
+ /** Category mappings for structured translation */
23
+ categories?: Record<string, Record<string, string>>;
24
+ }
25
+ /**
26
+ * Registry of direct translation pairs.
27
+ * Key format: "source->target" (e.g., "ja->zh")
28
+ */
29
+ declare const directMappings: Map<string, DirectMapping>;
30
+ /**
31
+ * Check if direct mapping exists for a language pair
32
+ */
33
+ declare function hasDirectMapping(source: string, target: string): boolean;
34
+ /**
35
+ * Get direct mapping for a language pair
36
+ */
37
+ declare function getDirectMapping(source: string, target: string): DirectMapping | undefined;
38
+ /**
39
+ * Translate a single word using direct mapping
40
+ */
41
+ declare function translateWordDirect(word: string, source: string, target: string): string | undefined;
42
+ /**
43
+ * Get all supported direct translation pairs
44
+ */
45
+ declare function getSupportedDirectPairs(): Array<{
46
+ source: string;
47
+ target: string;
48
+ }>;
49
+
50
+ export { directMappings, getDirectMapping, getSupportedDirectPairs, hasDirectMapping, translateWordDirect };