@lokascript/i18n 3.3.0 → 4.0.1
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
|
@@ -3,15 +3,16 @@ import { D as Dictionary } from './types-BYtpqGq3.js';
|
|
|
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
|
interface KeywordProvider {
|
|
@@ -369,10 +370,9 @@ declare const es: Dictionary;
|
|
|
369
370
|
* @example
|
|
370
371
|
* ```typescript
|
|
371
372
|
* import { esKeywords } from '@lokascript/i18n/parser/es';
|
|
372
|
-
* import { Parser } from '@hyperfixi/core';
|
|
373
373
|
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
374
|
+
* esKeywords.resolve('alternar'); // 'toggle'
|
|
375
|
+
* esKeywords.toLocale('on'); // 'en'
|
|
376
376
|
* ```
|
|
377
377
|
*/
|
|
378
378
|
declare const esKeywords: KeywordProvider;
|
|
@@ -397,10 +397,9 @@ declare const ja: Dictionary;
|
|
|
397
397
|
* @example
|
|
398
398
|
* ```typescript
|
|
399
399
|
* import { jaKeywords } from '@lokascript/i18n/parser/ja';
|
|
400
|
-
* import { Parser } from '@hyperfixi/core';
|
|
401
400
|
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
401
|
+
* jaKeywords.resolve('切り替え'); // 'toggle'
|
|
402
|
+
* jaKeywords.toLocale('on'); // 'で'
|
|
404
403
|
* ```
|
|
405
404
|
*/
|
|
406
405
|
declare const jaKeywords: KeywordProvider;
|
|
@@ -420,10 +419,9 @@ declare const fr: Dictionary;
|
|
|
420
419
|
* @example
|
|
421
420
|
* ```typescript
|
|
422
421
|
* import { frKeywords } from '@lokascript/i18n/parser/fr';
|
|
423
|
-
* import { Parser } from '@hyperfixi/core';
|
|
424
422
|
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
423
|
+
* frKeywords.resolve('basculer'); // 'toggle'
|
|
424
|
+
* frKeywords.toLocale('on'); // 'sur'
|
|
427
425
|
* ```
|
|
428
426
|
*/
|
|
429
427
|
declare const frKeywords: KeywordProvider;
|
|
@@ -448,10 +446,9 @@ declare const de: Dictionary;
|
|
|
448
446
|
* @example
|
|
449
447
|
* ```typescript
|
|
450
448
|
* import { deKeywords } from '@lokascript/i18n/parser/de';
|
|
451
|
-
* import { Parser } from '@hyperfixi/core';
|
|
452
449
|
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
450
|
+
* deKeywords.resolve('umschalten'); // 'toggle'
|
|
451
|
+
* deKeywords.toLocale('on'); // 'bei'
|
|
455
452
|
* ```
|
|
456
453
|
*/
|
|
457
454
|
declare const deKeywords: KeywordProvider;
|
|
@@ -480,10 +477,9 @@ declare const ar: Dictionary;
|
|
|
480
477
|
* @example
|
|
481
478
|
* ```typescript
|
|
482
479
|
* import { arKeywords } from '@lokascript/i18n/parser/ar';
|
|
483
|
-
* import { Parser } from '@hyperfixi/core';
|
|
484
480
|
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
481
|
+
* arKeywords.resolve('بدل'); // 'toggle'
|
|
482
|
+
* arKeywords.toLocale('on'); // 'على'
|
|
487
483
|
* ```
|
|
488
484
|
*/
|
|
489
485
|
declare const arKeywords: KeywordProvider;
|
|
@@ -509,10 +505,9 @@ declare const ko: Dictionary;
|
|
|
509
505
|
* @example
|
|
510
506
|
* ```typescript
|
|
511
507
|
* import { koKeywords } from '@lokascript/i18n/parser/ko';
|
|
512
|
-
* import { Parser } from '@hyperfixi/core';
|
|
513
508
|
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
509
|
+
* koKeywords.resolve('토글'); // 'toggle'
|
|
510
|
+
* koKeywords.toLocale('on'); // '에'
|
|
516
511
|
* ```
|
|
517
512
|
*/
|
|
518
513
|
declare const koKeywords: KeywordProvider;
|
|
@@ -539,10 +534,8 @@ declare const zh: Dictionary;
|
|
|
539
534
|
* @example
|
|
540
535
|
* ```typescript
|
|
541
536
|
* import { zhKeywords } from '@lokascript/i18n/parser/zh';
|
|
542
|
-
* import { Parser } from '@hyperfixi/core';
|
|
543
537
|
*
|
|
544
|
-
*
|
|
545
|
-
* parser.parse('当 点击 切换 .active');
|
|
538
|
+
* zhKeywords.resolve('切换'); // 'toggle'
|
|
546
539
|
* ```
|
|
547
540
|
*/
|
|
548
541
|
declare const zhKeywords: KeywordProvider;
|
|
@@ -569,10 +562,9 @@ declare const tr: Dictionary;
|
|
|
569
562
|
* @example
|
|
570
563
|
* ```typescript
|
|
571
564
|
* import { trKeywords } from '@lokascript/i18n/parser/tr';
|
|
572
|
-
* import { Parser } from '@hyperfixi/core';
|
|
573
565
|
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
566
|
+
* trKeywords.resolve('değiştir'); // 'toggle'
|
|
567
|
+
* trKeywords.toLocale('on'); // 'üzerinde'
|
|
576
568
|
* ```
|
|
577
569
|
*/
|
|
578
570
|
declare const trKeywords: KeywordProvider;
|
|
@@ -595,10 +587,9 @@ declare const id: Dictionary;
|
|
|
595
587
|
* @example
|
|
596
588
|
* ```typescript
|
|
597
589
|
* import { idKeywords } from '@lokascript/i18n/parser/id';
|
|
598
|
-
* import { Parser } from '@hyperfixi/core';
|
|
599
590
|
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
591
|
+
* idKeywords.resolve('alihkan'); // 'toggle'
|
|
592
|
+
* idKeywords.toLocale('on'); // 'pada'
|
|
602
593
|
* ```
|
|
603
594
|
*/
|
|
604
595
|
declare const idKeywords: KeywordProvider;
|
|
@@ -624,10 +615,9 @@ declare const qu: Dictionary;
|
|
|
624
615
|
* @example
|
|
625
616
|
* ```typescript
|
|
626
617
|
* import { quKeywords } from '@lokascript/i18n/parser/qu';
|
|
627
|
-
* import { Parser } from '@hyperfixi/core';
|
|
628
618
|
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
619
|
+
* quKeywords.resolve('tikray'); // 'toggle'
|
|
620
|
+
* quKeywords.toLocale('on'); // 'kaqpi'
|
|
631
621
|
* ```
|
|
632
622
|
*/
|
|
633
623
|
declare const quKeywords: KeywordProvider;
|
|
@@ -653,10 +643,9 @@ declare const sw: Dictionary;
|
|
|
653
643
|
* @example
|
|
654
644
|
* ```typescript
|
|
655
645
|
* import { swKeywords } from '@lokascript/i18n/parser/sw';
|
|
656
|
-
* import { Parser } from '@hyperfixi/core';
|
|
657
646
|
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
647
|
+
* swKeywords.resolve('badilisha'); // 'toggle'
|
|
648
|
+
* swKeywords.toLocale('on'); // 'kwenye'
|
|
660
649
|
* ```
|
|
661
650
|
*/
|
|
662
651
|
declare const swKeywords: KeywordProvider;
|
|
@@ -682,10 +671,9 @@ declare const pt: Dictionary;
|
|
|
682
671
|
* @example
|
|
683
672
|
* ```typescript
|
|
684
673
|
* import { ptKeywords } from '@lokascript/i18n/parser/pt';
|
|
685
|
-
* import { Parser } from '@hyperfixi/core';
|
|
686
674
|
*
|
|
687
|
-
*
|
|
688
|
-
*
|
|
675
|
+
* ptKeywords.resolve('alternar'); // 'toggle'
|
|
676
|
+
* ptKeywords.toLocale('on'); // 'em'
|
|
689
677
|
* ```
|
|
690
678
|
*/
|
|
691
679
|
declare const ptKeywords: KeywordProvider;
|
|
@@ -753,9 +741,6 @@ declare const tlKeywords: KeywordProvider;
|
|
|
753
741
|
* // Get keyword provider for parsing
|
|
754
742
|
* const provider = LocaleManager.get(); // Returns esKeywords
|
|
755
743
|
* const frProvider = LocaleManager.get('fr'); // Returns frKeywords
|
|
756
|
-
*
|
|
757
|
-
* // Use with parser
|
|
758
|
-
* const parser = new Parser({ keywords: LocaleManager.get() });
|
|
759
744
|
* ```
|
|
760
745
|
*/
|
|
761
746
|
declare class LocaleManager {
|
|
@@ -842,10 +827,9 @@ declare class LocaleManager {
|
|
|
842
827
|
* @example
|
|
843
828
|
* ```typescript
|
|
844
829
|
* import { detectBrowserLocale } from '@lokascript/i18n/parser';
|
|
845
|
-
* import { Parser } from '@hyperfixi/core';
|
|
846
830
|
*
|
|
847
|
-
* //
|
|
848
|
-
*
|
|
831
|
+
* // The provider for the browser's language (navigator.languages), or English
|
|
832
|
+
* detectBrowserLocale().locale; // e.g. 'es'
|
|
849
833
|
* ```
|
|
850
834
|
*/
|
|
851
835
|
declare function detectBrowserLocale(): KeywordProvider;
|
|
@@ -3,15 +3,16 @@ import { D as Dictionary } from './types-BYtpqGq3.cjs';
|
|
|
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
|
interface KeywordProvider {
|
|
@@ -369,10 +370,9 @@ declare const es: Dictionary;
|
|
|
369
370
|
* @example
|
|
370
371
|
* ```typescript
|
|
371
372
|
* import { esKeywords } from '@lokascript/i18n/parser/es';
|
|
372
|
-
* import { Parser } from '@hyperfixi/core';
|
|
373
373
|
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
374
|
+
* esKeywords.resolve('alternar'); // 'toggle'
|
|
375
|
+
* esKeywords.toLocale('on'); // 'en'
|
|
376
376
|
* ```
|
|
377
377
|
*/
|
|
378
378
|
declare const esKeywords: KeywordProvider;
|
|
@@ -397,10 +397,9 @@ declare const ja: Dictionary;
|
|
|
397
397
|
* @example
|
|
398
398
|
* ```typescript
|
|
399
399
|
* import { jaKeywords } from '@lokascript/i18n/parser/ja';
|
|
400
|
-
* import { Parser } from '@hyperfixi/core';
|
|
401
400
|
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
401
|
+
* jaKeywords.resolve('切り替え'); // 'toggle'
|
|
402
|
+
* jaKeywords.toLocale('on'); // 'で'
|
|
404
403
|
* ```
|
|
405
404
|
*/
|
|
406
405
|
declare const jaKeywords: KeywordProvider;
|
|
@@ -420,10 +419,9 @@ declare const fr: Dictionary;
|
|
|
420
419
|
* @example
|
|
421
420
|
* ```typescript
|
|
422
421
|
* import { frKeywords } from '@lokascript/i18n/parser/fr';
|
|
423
|
-
* import { Parser } from '@hyperfixi/core';
|
|
424
422
|
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
423
|
+
* frKeywords.resolve('basculer'); // 'toggle'
|
|
424
|
+
* frKeywords.toLocale('on'); // 'sur'
|
|
427
425
|
* ```
|
|
428
426
|
*/
|
|
429
427
|
declare const frKeywords: KeywordProvider;
|
|
@@ -448,10 +446,9 @@ declare const de: Dictionary;
|
|
|
448
446
|
* @example
|
|
449
447
|
* ```typescript
|
|
450
448
|
* import { deKeywords } from '@lokascript/i18n/parser/de';
|
|
451
|
-
* import { Parser } from '@hyperfixi/core';
|
|
452
449
|
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
450
|
+
* deKeywords.resolve('umschalten'); // 'toggle'
|
|
451
|
+
* deKeywords.toLocale('on'); // 'bei'
|
|
455
452
|
* ```
|
|
456
453
|
*/
|
|
457
454
|
declare const deKeywords: KeywordProvider;
|
|
@@ -480,10 +477,9 @@ declare const ar: Dictionary;
|
|
|
480
477
|
* @example
|
|
481
478
|
* ```typescript
|
|
482
479
|
* import { arKeywords } from '@lokascript/i18n/parser/ar';
|
|
483
|
-
* import { Parser } from '@hyperfixi/core';
|
|
484
480
|
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
481
|
+
* arKeywords.resolve('بدل'); // 'toggle'
|
|
482
|
+
* arKeywords.toLocale('on'); // 'على'
|
|
487
483
|
* ```
|
|
488
484
|
*/
|
|
489
485
|
declare const arKeywords: KeywordProvider;
|
|
@@ -509,10 +505,9 @@ declare const ko: Dictionary;
|
|
|
509
505
|
* @example
|
|
510
506
|
* ```typescript
|
|
511
507
|
* import { koKeywords } from '@lokascript/i18n/parser/ko';
|
|
512
|
-
* import { Parser } from '@hyperfixi/core';
|
|
513
508
|
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
509
|
+
* koKeywords.resolve('토글'); // 'toggle'
|
|
510
|
+
* koKeywords.toLocale('on'); // '에'
|
|
516
511
|
* ```
|
|
517
512
|
*/
|
|
518
513
|
declare const koKeywords: KeywordProvider;
|
|
@@ -539,10 +534,8 @@ declare const zh: Dictionary;
|
|
|
539
534
|
* @example
|
|
540
535
|
* ```typescript
|
|
541
536
|
* import { zhKeywords } from '@lokascript/i18n/parser/zh';
|
|
542
|
-
* import { Parser } from '@hyperfixi/core';
|
|
543
537
|
*
|
|
544
|
-
*
|
|
545
|
-
* parser.parse('当 点击 切换 .active');
|
|
538
|
+
* zhKeywords.resolve('切换'); // 'toggle'
|
|
546
539
|
* ```
|
|
547
540
|
*/
|
|
548
541
|
declare const zhKeywords: KeywordProvider;
|
|
@@ -569,10 +562,9 @@ declare const tr: Dictionary;
|
|
|
569
562
|
* @example
|
|
570
563
|
* ```typescript
|
|
571
564
|
* import { trKeywords } from '@lokascript/i18n/parser/tr';
|
|
572
|
-
* import { Parser } from '@hyperfixi/core';
|
|
573
565
|
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
566
|
+
* trKeywords.resolve('değiştir'); // 'toggle'
|
|
567
|
+
* trKeywords.toLocale('on'); // 'üzerinde'
|
|
576
568
|
* ```
|
|
577
569
|
*/
|
|
578
570
|
declare const trKeywords: KeywordProvider;
|
|
@@ -595,10 +587,9 @@ declare const id: Dictionary;
|
|
|
595
587
|
* @example
|
|
596
588
|
* ```typescript
|
|
597
589
|
* import { idKeywords } from '@lokascript/i18n/parser/id';
|
|
598
|
-
* import { Parser } from '@hyperfixi/core';
|
|
599
590
|
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
591
|
+
* idKeywords.resolve('alihkan'); // 'toggle'
|
|
592
|
+
* idKeywords.toLocale('on'); // 'pada'
|
|
602
593
|
* ```
|
|
603
594
|
*/
|
|
604
595
|
declare const idKeywords: KeywordProvider;
|
|
@@ -624,10 +615,9 @@ declare const qu: Dictionary;
|
|
|
624
615
|
* @example
|
|
625
616
|
* ```typescript
|
|
626
617
|
* import { quKeywords } from '@lokascript/i18n/parser/qu';
|
|
627
|
-
* import { Parser } from '@hyperfixi/core';
|
|
628
618
|
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
619
|
+
* quKeywords.resolve('tikray'); // 'toggle'
|
|
620
|
+
* quKeywords.toLocale('on'); // 'kaqpi'
|
|
631
621
|
* ```
|
|
632
622
|
*/
|
|
633
623
|
declare const quKeywords: KeywordProvider;
|
|
@@ -653,10 +643,9 @@ declare const sw: Dictionary;
|
|
|
653
643
|
* @example
|
|
654
644
|
* ```typescript
|
|
655
645
|
* import { swKeywords } from '@lokascript/i18n/parser/sw';
|
|
656
|
-
* import { Parser } from '@hyperfixi/core';
|
|
657
646
|
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
647
|
+
* swKeywords.resolve('badilisha'); // 'toggle'
|
|
648
|
+
* swKeywords.toLocale('on'); // 'kwenye'
|
|
660
649
|
* ```
|
|
661
650
|
*/
|
|
662
651
|
declare const swKeywords: KeywordProvider;
|
|
@@ -682,10 +671,9 @@ declare const pt: Dictionary;
|
|
|
682
671
|
* @example
|
|
683
672
|
* ```typescript
|
|
684
673
|
* import { ptKeywords } from '@lokascript/i18n/parser/pt';
|
|
685
|
-
* import { Parser } from '@hyperfixi/core';
|
|
686
674
|
*
|
|
687
|
-
*
|
|
688
|
-
*
|
|
675
|
+
* ptKeywords.resolve('alternar'); // 'toggle'
|
|
676
|
+
* ptKeywords.toLocale('on'); // 'em'
|
|
689
677
|
* ```
|
|
690
678
|
*/
|
|
691
679
|
declare const ptKeywords: KeywordProvider;
|
|
@@ -753,9 +741,6 @@ declare const tlKeywords: KeywordProvider;
|
|
|
753
741
|
* // Get keyword provider for parsing
|
|
754
742
|
* const provider = LocaleManager.get(); // Returns esKeywords
|
|
755
743
|
* const frProvider = LocaleManager.get('fr'); // Returns frKeywords
|
|
756
|
-
*
|
|
757
|
-
* // Use with parser
|
|
758
|
-
* const parser = new Parser({ keywords: LocaleManager.get() });
|
|
759
744
|
* ```
|
|
760
745
|
*/
|
|
761
746
|
declare class LocaleManager {
|
|
@@ -842,10 +827,9 @@ declare class LocaleManager {
|
|
|
842
827
|
* @example
|
|
843
828
|
* ```typescript
|
|
844
829
|
* import { detectBrowserLocale } from '@lokascript/i18n/parser';
|
|
845
|
-
* import { Parser } from '@hyperfixi/core';
|
|
846
830
|
*
|
|
847
|
-
* //
|
|
848
|
-
*
|
|
831
|
+
* // The provider for the browser's language (navigator.languages), or English
|
|
832
|
+
* detectBrowserLocale().locale; // e.g. 'es'
|
|
849
833
|
* ```
|
|
850
834
|
*/
|
|
851
835
|
declare function detectBrowserLocale(): KeywordProvider;
|