File tree Expand file tree Collapse file tree 6 files changed +129
-71
lines changed Expand file tree Collapse file tree 6 files changed +129
-71
lines changed Original file line number Diff line number Diff line change @@ -321,7 +321,7 @@ export function createTokenizer(
321
321
return fn ( )
322
322
} else {
323
323
// other characters
324
- return isIdentifierStart ( ch )
324
+ return isTextStart ( scnr , false )
325
325
}
326
326
}
327
327
@@ -680,7 +680,7 @@ export function createTokenizer(
680
680
}
681
681
682
682
function readLinkedRefer ( scnr : Scanner ) : string {
683
- const fn = ( detect = false , buf : string ) : string => {
683
+ const fn = ( buf : string ) : string => {
684
684
const ch = scnr . currentChar ( )
685
685
if (
686
686
ch === TokenChars . BraceLeft ||
@@ -697,15 +697,15 @@ export function createTokenizer(
697
697
} else if ( ch === NEW_LINE || ch === DOT ) {
698
698
buf += ch
699
699
scnr . next ( )
700
- return fn ( detect , buf )
700
+ return fn ( buf )
701
701
} else {
702
702
buf += ch
703
703
scnr . next ( )
704
- return fn ( true , buf )
704
+ return fn ( buf )
705
705
}
706
706
}
707
707
708
- return fn ( false , '' )
708
+ return fn ( '' )
709
709
}
710
710
711
711
function readPlural ( scnr : Scanner ) : string {
Original file line number Diff line number Diff line change @@ -525,28 +525,6 @@ exports[`parse > linked key paren error with modifier: "@.lower:(foo)" 1`] = `
525
525
}
526
526
` ;
527
527
528
- exports [` parse > linked key paren error with modifier: "@.lower:(foo)" errors 1` ] = `
529
- [
530
- {
531
- " code" : 13 ,
532
- " domain" : " parser" ,
533
- " location" : {
534
- " end" : {
535
- " column" : 14 ,
536
- " line" : 1 ,
537
- " offset" : 13 ,
538
- },
539
- " start" : {
540
- " column" : 8 ,
541
- " line" : 1 ,
542
- " offset" : 7 ,
543
- },
544
- },
545
- " message" : " Unexpected empty linked key" ,
546
- } ,
547
- ]
548
- ` ;
549
-
550
528
exports [` parse > linked key paren error: "@:(foo)" 1` ] = `
551
529
{
552
530
" body" : {
@@ -640,28 +618,6 @@ exports[`parse > linked key paren error: "@:(foo)" 1`] = `
640
618
}
641
619
` ;
642
620
643
- exports [` parse > linked key paren error: "@:(foo)" errors 1` ] = `
644
- [
645
- {
646
- " code" : 13 ,
647
- " domain" : " parser" ,
648
- " location" : {
649
- " end" : {
650
- " column" : 8 ,
651
- " line" : 1 ,
652
- " offset" : 7 ,
653
- },
654
- " start" : {
655
- " column" : 2 ,
656
- " line" : 1 ,
657
- " offset" : 1 ,
658
- },
659
- },
660
- " message" : " Unexpected empty linked key" ,
661
- } ,
662
- ]
663
- ` ;
664
-
665
621
exports [` parse > linked key with named and modifier: "hi @._upper:{ _name } !" 1` ] = `
666
622
{
667
623
" body" : {
@@ -2024,16 +1980,6 @@ exports[`parser options > location disable > linked key paren error with modifie
2024
1980
}
2025
1981
` ;
2026
1982
2027
- exports [` parser options > location disable > linked key paren error with modifier: "@.lower:(foo)" errors 1` ] = `
2028
- [
2029
- {
2030
- " code" : 13 ,
2031
- " domain" : " parser" ,
2032
- " message" : " Unexpected empty linked key" ,
2033
- } ,
2034
- ]
2035
- ` ;
2036
-
2037
1983
exports [` parser options > location disable > linked key paren error: "@:(foo)" 1` ] = `
2038
1984
{
2039
1985
" body" : {
@@ -2056,16 +2002,6 @@ exports[`parser options > location disable > linked key paren error: "@:(foo)" 1
2056
2002
}
2057
2003
` ;
2058
2004
2059
- exports [` parser options > location disable > linked key paren error: "@:(foo)" errors 1` ] = `
2060
- [
2061
- {
2062
- " code" : 13 ,
2063
- " domain" : " parser" ,
2064
- " message" : " Unexpected empty linked key" ,
2065
- } ,
2066
- ]
2067
- ` ;
2068
-
2069
2005
exports [` parser options > location disable > linked key with named and modifier: "hi @._upper:{ _name } !" 1` ] = `
2070
2006
{
2071
2007
" body" : {
Original file line number Diff line number Diff line change @@ -4370,6 +4370,90 @@ exports[`token analysis > "hi @:name !" tokens 1`] = `
4370
4370
]
4371
4371
` ;
4372
4372
4373
+ exports[` token analysis > " hi @:名前" tokens 1 ` ] = `
4374
+ [
4375
+ {
4376
+ " loc" : {
4377
+ " end" : {
4378
+ " column" : 4 ,
4379
+ " line" : 1 ,
4380
+ " offset" : 3 ,
4381
+ },
4382
+ " start" : {
4383
+ " column" : 1 ,
4384
+ " line" : 1 ,
4385
+ " offset" : 0 ,
4386
+ },
4387
+ },
4388
+ " type" : 0 ,
4389
+ " value" : " hi " ,
4390
+ },
4391
+ {
4392
+ " loc" : {
4393
+ " end" : {
4394
+ " column" : 5 ,
4395
+ " line" : 1 ,
4396
+ " offset" : 4 ,
4397
+ },
4398
+ " start" : {
4399
+ " column" : 4 ,
4400
+ " line" : 1 ,
4401
+ " offset" : 3 ,
4402
+ },
4403
+ },
4404
+ " type" : 8 ,
4405
+ " value" : " @" ,
4406
+ },
4407
+ {
4408
+ " loc" : {
4409
+ " end" : {
4410
+ " column" : 6 ,
4411
+ " line" : 1 ,
4412
+ " offset" : 5 ,
4413
+ },
4414
+ " start" : {
4415
+ " column" : 5 ,
4416
+ " line" : 1 ,
4417
+ " offset" : 4 ,
4418
+ },
4419
+ },
4420
+ " type" : 10 ,
4421
+ " value" : " :" ,
4422
+ },
4423
+ {
4424
+ " loc" : {
4425
+ " end" : {
4426
+ " column" : 8 ,
4427
+ " line" : 1 ,
4428
+ " offset" : 7 ,
4429
+ },
4430
+ " start" : {
4431
+ " column" : 6 ,
4432
+ " line" : 1 ,
4433
+ " offset" : 5 ,
4434
+ },
4435
+ },
4436
+ " type" : 11 ,
4437
+ " value" : " 名前" ,
4438
+ },
4439
+ {
4440
+ " loc" : {
4441
+ " end" : {
4442
+ " column" : 8 ,
4443
+ " line" : 1 ,
4444
+ " offset" : 7 ,
4445
+ },
4446
+ " start" : {
4447
+ " column" : 8 ,
4448
+ " line" : 1 ,
4449
+ " offset" : 7 ,
4450
+ },
4451
+ },
4452
+ " type" : 14 ,
4453
+ },
4454
+ ]
4455
+ ` ;
4456
+
4373
4457
exports[` token analysis > " hi @\\ n. upper\\ n: {'name'}\\ n !" errors 1 ` ] = `
4374
4458
[
4375
4459
{
@@ -10520,6 +10604,30 @@ exports[`tokenize options: location disable > "hi @:name !" tokens 1`] = `
10520
10604
]
10521
10605
` ;
10522
10606
10607
+ exports[` tokenize options : location disable > " hi @:名前" tokens 1 ` ] = `
10608
+ [
10609
+ {
10610
+ " type" : 0 ,
10611
+ " value" : " hi " ,
10612
+ },
10613
+ {
10614
+ " type" : 8 ,
10615
+ " value" : " @" ,
10616
+ },
10617
+ {
10618
+ " type" : 10 ,
10619
+ " value" : " :" ,
10620
+ },
10621
+ {
10622
+ " type" : 11 ,
10623
+ " value" : " 名前" ,
10624
+ },
10625
+ {
10626
+ " type" : 14 ,
10627
+ },
10628
+ ]
10629
+ ` ;
10630
+
10523
10631
exports[` tokenize options : location disable > " hi @\\ n. upper\\ n: {'name'}\\ n !" errors 1 ` ] = `
10524
10632
[
10525
10633
{
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ const CASES = [
80
80
`hi @.upper\n{name} !` ,
81
81
`hi @.upper {name} !` ,
82
82
`hi @:\nname !` ,
83
+ `hi @:名前` ,
83
84
`hi @: {'name'} !` ,
84
85
`hi @\n. upper\n: {'name'}\n !` ,
85
86
` | | |` ,
Original file line number Diff line number Diff line change @@ -1437,3 +1437,16 @@ test('#1796', async () => {
1437
1437
} )
1438
1438
) . toEqual ( 'My message with hello world.' )
1439
1439
} )
1440
+
1441
+ test ( '#1809' , async ( ) => {
1442
+ const i18n = createI18n ( {
1443
+ locale : 'en' ,
1444
+ messages : {
1445
+ en : {
1446
+ hi : 'hi @:名前' ,
1447
+ 名前 : 'kazupon'
1448
+ }
1449
+ }
1450
+ } )
1451
+ expect ( i18n . global . t ( 'hi' ) ) . toEqual ( 'hi kazupon' )
1452
+ } )
Original file line number Diff line number Diff line change 1
1
(*
2
- * Inltify message syntax v0.3
2
+ * Inltify message syntax v0.4.0
3
3
* (vue-i18n compatible)
4
4
*)
5
5
@@ -18,7 +18,7 @@ Named ::= Modulo? "{" Space? (NamedIdentifier) Space? "}";
18
18
List ::= " {" Space ? (NumberLiteral ) Space ? " }" ;
19
19
Linked ::= " @" (LinkedModifier )? LinkedDelimiter LinkedRefer ;
20
20
LinkedRefer ::= LinkedKey | Placeholder ;
21
- LinkedKey ::= Identifier ;
21
+ LinkedKey ::= Text ;
22
22
LinkedModifier ::= LinkedDot Identifier ;
23
23
LinkedDelimiter ::= " :" ;
24
24
LinkedDot ::= " ." ;
You can’t perform that action at this time.
0 commit comments