@lokascript/i18n 3.2.0 → 4.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.map +1 -1
- package/dist/browser.d.cts +4 -5
- package/dist/browser.d.ts +4 -5
- package/dist/browser.js.map +1 -1
- package/dist/{index-DuIef8O7.d.ts → index-BvvoluMH.d.ts} +31 -47
- package/dist/{index-BykxjYST.d.cts → index-C4L2RKNl.d.cts} +31 -47
- package/dist/index.cjs +19367 -3750
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -258
- package/dist/index.d.ts +34 -258
- package/dist/index.js +19367 -3750
- package/dist/index.js.map +1 -1
- package/dist/lokascript-i18n.min.js.map +1 -1
- package/dist/lokascript-i18n.mjs +27 -45
- package/dist/lokascript-i18n.mjs.map +1 -1
- package/package.json +4 -4
- package/src/browser.ts +4 -7
- package/src/compatibility/browser-tests/grammar-demo.spec.ts +1 -1
- package/src/grammar/index.ts +5 -4
- package/src/grammar/profiles.test.ts +3 -2
- package/src/parser/ar.ts +2 -3
- package/src/parser/de.ts +2 -3
- package/src/parser/es.ts +2 -3
- package/src/parser/fr.ts +2 -3
- package/src/parser/he.ts +2 -3
- package/src/parser/id.ts +2 -3
- package/src/parser/index.ts +4 -6
- package/src/parser/ja.ts +2 -3
- package/src/parser/ko.ts +2 -3
- package/src/parser/locale-manager.ts +2 -6
- package/src/parser/pt.ts +2 -3
- package/src/parser/qu.ts +2 -3
- package/src/parser/sw.ts +2 -3
- package/src/parser/tr.ts +2 -3
- package/src/parser/types.ts +6 -5
- package/src/parser/zh.ts +1 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lokascript/i18n",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Keyword dictionaries, keyword providers and grammar profiles for hyperscript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -64,8 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"homepage": "https://github.com/codetalcott/hyperfixi/tree/main/packages/i18n#readme",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@
|
|
68
|
-
"@lokascript/semantic": "^3.2.0",
|
|
67
|
+
"@lokascript/semantic": "^4.0.0",
|
|
69
68
|
"esbuild": "^0.25.12",
|
|
70
69
|
"happy-dom": "^20.14.5",
|
|
71
70
|
"vite": "^8.3.1"
|
|
@@ -79,7 +78,8 @@
|
|
|
79
78
|
"rollup": "^4.63.5",
|
|
80
79
|
"tsup": "^8.0.0",
|
|
81
80
|
"typescript": "^5.0.0",
|
|
82
|
-
"vitest": "^5.0.2"
|
|
81
|
+
"vitest": "^5.0.2",
|
|
82
|
+
"zod": "^4.6.5"
|
|
83
83
|
},
|
|
84
84
|
"files": [
|
|
85
85
|
"dist",
|
package/src/browser.ts
CHANGED
|
@@ -6,22 +6,19 @@
|
|
|
6
6
|
* - LocaleManager for runtime locale switching
|
|
7
7
|
* - Factory functions for custom providers
|
|
8
8
|
*
|
|
9
|
-
* Usage with
|
|
9
|
+
* Usage with the browser bundle (`lokascript-i18n.min.js`, global `LokaScriptI18n`):
|
|
10
10
|
* ```html
|
|
11
|
-
* <script src="
|
|
12
|
-
* <script src="hyperfixi-i18n.min.js"></script>
|
|
11
|
+
* <script src="lokascript-i18n.min.js"></script>
|
|
13
12
|
* <script>
|
|
14
|
-
* //
|
|
15
|
-
* HyperFixi.configure({ keywords: HyperFixiI18n.esKeywords });
|
|
13
|
+
* LokaScriptI18n.esKeywords.resolve('alternar'); // 'toggle'
|
|
16
14
|
* </script>
|
|
17
15
|
* ```
|
|
18
16
|
*
|
|
19
17
|
* Usage with ES modules:
|
|
20
18
|
* ```typescript
|
|
21
19
|
* import { esKeywords } from '@lokascript/i18n';
|
|
22
|
-
* import { Parser } from '@hyperfixi/core';
|
|
23
20
|
*
|
|
24
|
-
*
|
|
21
|
+
* esKeywords.resolve('alternar'); // 'toggle'
|
|
25
22
|
* ```
|
|
26
23
|
*/
|
|
27
24
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { test, expect } from '@playwright/test';
|
|
8
8
|
|
|
9
9
|
// NOTE (2026-08-28): no `playwright.config` in this package points at this
|
|
10
|
-
// directory — core's config has `testDir: './
|
|
10
|
+
// directory — core's config has `testDir: './browser-tests'`,
|
|
11
11
|
// which is core's own tree — so CI does not run this file. It is kept correct
|
|
12
12
|
// rather than deleted, but do not read a green CI as evidence it passes.
|
|
13
13
|
|
package/src/grammar/index.ts
CHANGED
|
@@ -70,7 +70,8 @@ export {
|
|
|
70
70
|
// them (#998).
|
|
71
71
|
//
|
|
72
72
|
// The rest of this directory STAYS and is not part of that retirement: `profiles/`
|
|
73
|
-
// is imported by i18n's own `runtime.ts` and re-exported to
|
|
74
|
-
// bundle; `types.ts` backs
|
|
75
|
-
// `direct-mappings.ts` is part of the
|
|
76
|
-
// declares it). This was never "delete
|
|
73
|
+
// is imported by i18n's own `runtime.ts` (and was re-exported to core's
|
|
74
|
+
// classic-i18n bundle until it retired in Phase C3); `types.ts` backs
|
|
75
|
+
// `constants.ts` and the role helpers above; `direct-mappings.ts` is part of the
|
|
76
|
+
// browser API (`types-browser/i18n-api.ts` declares it). This was never "delete
|
|
77
|
+
// the grammar directory".
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* (see grammar/index.ts); these are not.
|
|
8
8
|
*
|
|
9
9
|
* They cover the half of `grammar/` that STAYS and has its own consumers:
|
|
10
|
-
* `profiles/` (i18n's `runtime.ts
|
|
11
|
-
* `getProfile` / `getSupportedGrammarLocales` / `profiles`
|
|
10
|
+
* `profiles/` (i18n's `runtime.ts`; core's classic-i18n browser bundle exposed
|
|
11
|
+
* them as `getProfile` / `getSupportedGrammarLocales` / `profiles` until Phase
|
|
12
|
+
* C3 retired it), the role
|
|
12
13
|
* helpers in `types.ts` (`reorderRoles` / `insertMarkers` / `joinTokens`, which
|
|
13
14
|
* `constants.ts` imports from), and the has/have dictionary entries.
|
|
14
15
|
*/
|
package/src/parser/ar.ts
CHANGED
|
@@ -26,10 +26,9 @@ import type { KeywordProvider } from './types';
|
|
|
26
26
|
* @example
|
|
27
27
|
* ```typescript
|
|
28
28
|
* import { arKeywords } from '@lokascript/i18n/parser/ar';
|
|
29
|
-
* import { Parser } from '@hyperfixi/core';
|
|
30
29
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
30
|
+
* arKeywords.resolve('بدل'); // 'toggle'
|
|
31
|
+
* arKeywords.toLocale('on'); // 'على'
|
|
33
32
|
* ```
|
|
34
33
|
*/
|
|
35
34
|
export const arKeywords: KeywordProvider = createKeywordProvider(ar, 'ar', {
|
package/src/parser/de.ts
CHANGED
|
@@ -22,10 +22,9 @@ import type { KeywordProvider } from './types';
|
|
|
22
22
|
* @example
|
|
23
23
|
* ```typescript
|
|
24
24
|
* import { deKeywords } from '@lokascript/i18n/parser/de';
|
|
25
|
-
* import { Parser } from '@hyperfixi/core';
|
|
26
25
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* deKeywords.resolve('umschalten'); // 'toggle'
|
|
27
|
+
* deKeywords.toLocale('on'); // 'bei'
|
|
29
28
|
* ```
|
|
30
29
|
*/
|
|
31
30
|
export const deKeywords: KeywordProvider = createKeywordProvider(de, 'de', {
|
package/src/parser/es.ts
CHANGED
|
@@ -17,10 +17,9 @@ import type { KeywordProvider } from './types';
|
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
|
19
19
|
* import { esKeywords } from '@lokascript/i18n/parser/es';
|
|
20
|
-
* import { Parser } from '@hyperfixi/core';
|
|
21
20
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* esKeywords.resolve('alternar'); // 'toggle'
|
|
22
|
+
* esKeywords.toLocale('on'); // 'en'
|
|
24
23
|
* ```
|
|
25
24
|
*/
|
|
26
25
|
export const esKeywords: KeywordProvider = createKeywordProvider(es, 'es', {
|
package/src/parser/fr.ts
CHANGED
|
@@ -17,10 +17,9 @@ import type { KeywordProvider } from './types';
|
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
|
19
19
|
* import { frKeywords } from '@lokascript/i18n/parser/fr';
|
|
20
|
-
* import { Parser } from '@hyperfixi/core';
|
|
21
20
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* frKeywords.resolve('basculer'); // 'toggle'
|
|
22
|
+
* frKeywords.toLocale('on'); // 'sur'
|
|
24
23
|
* ```
|
|
25
24
|
*/
|
|
26
25
|
export const frKeywords: KeywordProvider = createKeywordProvider(fr, 'fr', {
|
package/src/parser/he.ts
CHANGED
|
@@ -15,10 +15,9 @@ import type { KeywordProvider } from './types';
|
|
|
15
15
|
* @example
|
|
16
16
|
* ```typescript
|
|
17
17
|
* import { heKeywords } from '@lokascript/i18n/parser/he';
|
|
18
|
-
* import { Parser } from '@hyperfixi/core';
|
|
19
18
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* heKeywords.resolve('מתג'); // 'toggle'
|
|
20
|
+
* heKeywords.toLocale('on'); // 'ב'
|
|
22
21
|
* ```
|
|
23
22
|
*/
|
|
24
23
|
export const heKeywords: KeywordProvider = createKeywordProvider(he, 'he', {
|
package/src/parser/id.ts
CHANGED
|
@@ -20,10 +20,9 @@ import type { KeywordProvider } from './types';
|
|
|
20
20
|
* @example
|
|
21
21
|
* ```typescript
|
|
22
22
|
* import { idKeywords } from '@lokascript/i18n/parser/id';
|
|
23
|
-
* import { Parser } from '@hyperfixi/core';
|
|
24
23
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* idKeywords.resolve('alihkan'); // 'toggle'
|
|
25
|
+
* idKeywords.toLocale('on'); // 'pada'
|
|
27
26
|
* ```
|
|
28
27
|
*/
|
|
29
28
|
export const idKeywords: KeywordProvider = createKeywordProvider(id, 'id', {
|
package/src/parser/index.ts
CHANGED
|
@@ -3,20 +3,18 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Parser integration for multilingual hyperscript.
|
|
5
5
|
*
|
|
6
|
-
* This module provides KeywordProvider implementations
|
|
7
|
-
*
|
|
6
|
+
* This module provides KeywordProvider implementations: each resolves a
|
|
7
|
+
* locale's hyperscript keywords to canonical English and back.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
11
|
* // Spanish
|
|
12
12
|
* import { esKeywords } from '@lokascript/i18n/parser';
|
|
13
|
-
*
|
|
14
|
-
* parser.parse('en clic alternar .active');
|
|
13
|
+
* esKeywords.resolve('alternar'); // 'toggle'
|
|
15
14
|
*
|
|
16
15
|
* // Japanese
|
|
17
16
|
* import { jaKeywords } from '@lokascript/i18n/parser';
|
|
18
|
-
*
|
|
19
|
-
* parser.parse('クリック で 切り替え .active');
|
|
17
|
+
* jaKeywords.resolve('切り替え'); // 'toggle'
|
|
20
18
|
*
|
|
21
19
|
* // Custom locale
|
|
22
20
|
* import { createKeywordProvider } from '@lokascript/i18n/parser';
|
package/src/parser/ja.ts
CHANGED
|
@@ -22,10 +22,9 @@ import type { KeywordProvider } from './types';
|
|
|
22
22
|
* @example
|
|
23
23
|
* ```typescript
|
|
24
24
|
* import { jaKeywords } from '@lokascript/i18n/parser/ja';
|
|
25
|
-
* import { Parser } from '@hyperfixi/core';
|
|
26
25
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* jaKeywords.resolve('切り替え'); // 'toggle'
|
|
27
|
+
* jaKeywords.toLocale('on'); // 'で'
|
|
29
28
|
* ```
|
|
30
29
|
*/
|
|
31
30
|
export const jaKeywords: KeywordProvider = createKeywordProvider(ja, 'ja', {
|
package/src/parser/ko.ts
CHANGED
|
@@ -23,10 +23,9 @@ import type { KeywordProvider } from './types';
|
|
|
23
23
|
* @example
|
|
24
24
|
* ```typescript
|
|
25
25
|
* import { koKeywords } from '@lokascript/i18n/parser/ko';
|
|
26
|
-
* import { Parser } from '@hyperfixi/core';
|
|
27
26
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* koKeywords.resolve('토글'); // 'toggle'
|
|
28
|
+
* koKeywords.toLocale('on'); // '에'
|
|
30
29
|
* ```
|
|
31
30
|
*/
|
|
32
31
|
export const koKeywords: KeywordProvider = createKeywordProvider(ko, 'ko', {
|
|
@@ -26,9 +26,6 @@ import { createEnglishProvider } from './create-provider';
|
|
|
26
26
|
* // Get keyword provider for parsing
|
|
27
27
|
* const provider = LocaleManager.get(); // Returns esKeywords
|
|
28
28
|
* const frProvider = LocaleManager.get('fr'); // Returns frKeywords
|
|
29
|
-
*
|
|
30
|
-
* // Use with parser
|
|
31
|
-
* const parser = new Parser({ keywords: LocaleManager.get() });
|
|
32
29
|
* ```
|
|
33
30
|
*/
|
|
34
31
|
export class LocaleManager {
|
|
@@ -169,10 +166,9 @@ export class LocaleManager {
|
|
|
169
166
|
* @example
|
|
170
167
|
* ```typescript
|
|
171
168
|
* import { detectBrowserLocale } from '@lokascript/i18n/parser';
|
|
172
|
-
* import { Parser } from '@hyperfixi/core';
|
|
173
169
|
*
|
|
174
|
-
* //
|
|
175
|
-
*
|
|
170
|
+
* // The provider for the browser's language (navigator.languages), or English
|
|
171
|
+
* detectBrowserLocale().locale; // e.g. 'es'
|
|
176
172
|
* ```
|
|
177
173
|
*/
|
|
178
174
|
export function detectBrowserLocale(): KeywordProvider {
|
package/src/parser/pt.ts
CHANGED
|
@@ -23,10 +23,9 @@ import type { KeywordProvider } from './types';
|
|
|
23
23
|
* @example
|
|
24
24
|
* ```typescript
|
|
25
25
|
* import { ptKeywords } from '@lokascript/i18n/parser/pt';
|
|
26
|
-
* import { Parser } from '@hyperfixi/core';
|
|
27
26
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* ptKeywords.resolve('alternar'); // 'toggle'
|
|
28
|
+
* ptKeywords.toLocale('on'); // 'em'
|
|
30
29
|
* ```
|
|
31
30
|
*/
|
|
32
31
|
export const ptKeywords: KeywordProvider = createKeywordProvider(pt, 'pt', {
|
package/src/parser/qu.ts
CHANGED
|
@@ -23,10 +23,9 @@ import type { KeywordProvider } from './types';
|
|
|
23
23
|
* @example
|
|
24
24
|
* ```typescript
|
|
25
25
|
* import { quKeywords } from '@lokascript/i18n/parser/qu';
|
|
26
|
-
* import { Parser } from '@hyperfixi/core';
|
|
27
26
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* quKeywords.resolve('tikray'); // 'toggle'
|
|
28
|
+
* quKeywords.toLocale('on'); // 'kaqpi'
|
|
30
29
|
* ```
|
|
31
30
|
*/
|
|
32
31
|
export const quKeywords: KeywordProvider = createKeywordProvider(qu, 'qu', {
|
package/src/parser/sw.ts
CHANGED
|
@@ -23,10 +23,9 @@ import type { KeywordProvider } from './types';
|
|
|
23
23
|
* @example
|
|
24
24
|
* ```typescript
|
|
25
25
|
* import { swKeywords } from '@lokascript/i18n/parser/sw';
|
|
26
|
-
* import { Parser } from '@hyperfixi/core';
|
|
27
26
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* swKeywords.resolve('badilisha'); // 'toggle'
|
|
28
|
+
* swKeywords.toLocale('on'); // 'kwenye'
|
|
30
29
|
* ```
|
|
31
30
|
*/
|
|
32
31
|
export const swKeywords: KeywordProvider = createKeywordProvider(sw, 'sw', {
|
package/src/parser/tr.ts
CHANGED
|
@@ -24,10 +24,9 @@ import type { KeywordProvider } from './types';
|
|
|
24
24
|
* @example
|
|
25
25
|
* ```typescript
|
|
26
26
|
* import { trKeywords } from '@lokascript/i18n/parser/tr';
|
|
27
|
-
* import { Parser } from '@hyperfixi/core';
|
|
28
27
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* trKeywords.resolve('değiştir'); // 'toggle'
|
|
29
|
+
* trKeywords.toLocale('on'); // 'üzerinde'
|
|
31
30
|
* ```
|
|
32
31
|
*/
|
|
33
32
|
export const trKeywords: KeywordProvider = createKeywordProvider(tr, 'tr', {
|
package/src/parser/types.ts
CHANGED
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* KeywordProvider interface for locale-aware parsing.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* A provider resolves a locale's keywords to their canonical English
|
|
7
|
+
* equivalents and back (`@hyperfixi/core` 3.x's parser reads one through its
|
|
8
|
+
* `keywords` parse option).
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```typescript
|
|
12
12
|
* import { esKeywords } from '@lokascript/i18n/parser/es';
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
*
|
|
14
|
+
* esKeywords.resolve('alternar'); // 'toggle'
|
|
15
|
+
* esKeywords.toLocale('toggle'); // 'alternar'
|
|
15
16
|
* ```
|
|
16
17
|
*/
|
|
17
18
|
export interface KeywordProvider {
|
package/src/parser/zh.ts
CHANGED
|
@@ -24,10 +24,8 @@ import type { KeywordProvider } from './types';
|
|
|
24
24
|
* @example
|
|
25
25
|
* ```typescript
|
|
26
26
|
* import { zhKeywords } from '@lokascript/i18n/parser/zh';
|
|
27
|
-
* import { Parser } from '@hyperfixi/core';
|
|
28
27
|
*
|
|
29
|
-
*
|
|
30
|
-
* parser.parse('当 点击 切换 .active');
|
|
28
|
+
* zhKeywords.resolve('切换'); // 'toggle'
|
|
31
29
|
* ```
|
|
32
30
|
*/
|
|
33
31
|
export const zhKeywords: KeywordProvider = createKeywordProvider(zh, 'zh', {
|