1
- import { getLocale } from '@/locale'
1
+ import { createL10n } from '@/locale'
2
2
import { FieldPattern , TextPosition } from '@/types'
3
3
import { describe , expect , it } from 'vitest'
4
4
5
5
describe ( 'locale' , ( ) => {
6
- it ( 'getLocale ' , ( ) => {
6
+ it ( 'createL10n ' , ( ) => {
7
7
const testCases = [
8
8
{ locale : 'en' , expected : 'Hour' } ,
9
9
{ locale : 'foo-bar' , expected : 'Hour' } ,
@@ -13,43 +13,43 @@ describe('locale', () => {
13
13
]
14
14
15
15
for ( const test of testCases ) {
16
- const l = getLocale ( test . locale )
17
- expect ( l . getLocaleStr ( 'hour' , 'text' ) ) . toBe ( test . expected )
16
+ const l = createL10n ( test . locale )
17
+ expect ( l . getTemplate ( 'hour' , 'text' ) ) . toBe ( test . expected )
18
18
}
19
19
} )
20
20
21
- it ( 'getLocaleStr ' , ( ) => {
22
- const l = getLocale ( 'en' , {
21
+ it ( 'getTemplate ' , ( ) => {
22
+ const l = createL10n ( 'en' , {
23
23
custom : {
24
24
'*' : 'bar' ,
25
25
message : 'baz' ,
26
26
} ,
27
27
} )
28
28
29
- expect ( l . getLocaleStr ( 'year' , 'minute' , 'empty ' , 'text' ) ) . toBe ( 'every {{field.id}}' )
30
- expect ( l . getLocaleStr ( 'year' , 'dayOfWeek' , 'value' , 'prefix' ) ) . toBe ( 'and' )
31
- expect ( l . getLocaleStr ( 'year' , 'minute' , 'range' , 'prefix' ) ) . toBe ( ':' )
32
- expect ( l . getLocaleStr ( 'custom' , 'foo' ) ) . toBe ( 'bar' )
33
- expect ( l . getLocaleStr ( 'custom' , 'message' ) ) . toBe ( 'baz' )
29
+ expect ( l . getTemplate ( 'year' , 'minute' , 'any ' , 'text' ) ) . toBe ( 'every {{field.id}}' )
30
+ expect ( l . getTemplate ( 'year' , 'dayOfWeek' , 'value' , 'prefix' ) ) . toBe ( 'and' )
31
+ expect ( l . getTemplate ( 'year' , 'minute' , 'range' , 'prefix' ) ) . toBe ( ':' )
32
+ expect ( l . getTemplate ( 'custom' , 'foo' ) ) . toBe ( 'bar' )
33
+ expect ( l . getTemplate ( 'custom' , 'message' ) ) . toBe ( 'baz' )
34
34
} )
35
35
36
- it ( 'getLocaleStr pt' , ( ) => {
37
- const l = getLocale ( 'pt' , {
36
+ it ( 'getTemplate pt' , ( ) => {
37
+ const l = createL10n ( 'pt' , {
38
38
custom : {
39
39
'*' : 'bar' ,
40
40
message : 'baz' ,
41
41
} ,
42
42
} )
43
43
44
- expect ( l . getLocaleStr ( 'year' , 'minute' , 'empty ' , 'text' ) ) . toBe ( 'cada minuto' )
45
- expect ( l . getLocaleStr ( 'year' , 'dayOfWeek' , 'value' , 'prefix' ) ) . toBe ( 'e de' )
46
- expect ( l . getLocaleStr ( 'year' , 'minute' , 'range' , 'prefix' ) ) . toBe ( ':' )
47
- expect ( l . getLocaleStr ( 'custom' , 'foo' ) ) . toBe ( 'bar' )
48
- expect ( l . getLocaleStr ( 'custom' , 'message' ) ) . toBe ( 'baz' )
44
+ expect ( l . getTemplate ( 'year' , 'minute' , 'any ' , 'text' ) ) . toBe ( 'cada minuto' )
45
+ expect ( l . getTemplate ( 'year' , 'dayOfWeek' , 'value' , 'prefix' ) ) . toBe ( 'e de' )
46
+ expect ( l . getTemplate ( 'year' , 'minute' , 'range' , 'prefix' ) ) . toBe ( ':' )
47
+ expect ( l . getTemplate ( 'custom' , 'foo' ) ) . toBe ( 'bar' )
48
+ expect ( l . getTemplate ( 'custom' , 'message' ) ) . toBe ( 'baz' )
49
49
} )
50
50
51
51
it ( 'render' , ( ) => {
52
- const l = getLocale ( 'en' , {
52
+ const l = createL10n ( 'en' , {
53
53
'*' : {
54
54
'*' : {
55
55
value : {
0 commit comments