@@ -10,7 +10,7 @@ import (
10
10
"github.com/stretchr/testify/assert"
11
11
)
12
12
13
- func Test_Tr (t * testing.T ) {
13
+ func TestLocaleStore (t * testing.T ) {
14
14
testData1 := []byte (`
15
15
.dot.name = Dot Name
16
16
fmt = %[1]s %[2]s
@@ -28,8 +28,8 @@ sub = Changed Sub String
28
28
` )
29
29
30
30
ls := NewLocaleStore ()
31
- assert .NoError (t , ls .AddLocaleByIni ("lang1" , "Lang1" , testData1 ))
32
- assert .NoError (t , ls .AddLocaleByIni ("lang2" , "Lang2" , testData2 ))
31
+ assert .NoError (t , ls .AddLocaleByIni ("lang1" , "Lang1" , testData1 , nil ))
32
+ assert .NoError (t , ls .AddLocaleByIni ("lang2" , "Lang2" , testData2 , nil ))
33
33
ls .SetDefaultLang ("lang1" )
34
34
35
35
result := ls .Tr ("lang1" , "fmt" , "a" , "b" )
@@ -58,3 +58,21 @@ sub = Changed Sub String
58
58
assert .False (t , found )
59
59
assert .NoError (t , ls .Close ())
60
60
}
61
+
62
+ func TestLocaleStoreMoreSource (t * testing.T ) {
63
+ testData1 := []byte (`
64
+ a=11
65
+ b=12
66
+ ` )
67
+
68
+ testData2 := []byte (`
69
+ b=21
70
+ c=22
71
+ ` )
72
+
73
+ ls := NewLocaleStore ()
74
+ assert .NoError (t , ls .AddLocaleByIni ("lang1" , "Lang1" , testData1 , testData2 ))
75
+ assert .Equal (t , "11" , ls .Tr ("lang1" , "a" ))
76
+ assert .Equal (t , "21" , ls .Tr ("lang1" , "b" ))
77
+ assert .Equal (t , "22" , ls .Tr ("lang1" , "c" ))
78
+ }
0 commit comments