File size: 1,155 Bytes
530729e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package language

import (
	"fmt"
	"html/template"
	"testing"

	"github.com/GoAdminGroup/go-admin/modules/config"
	"github.com/stretchr/testify/assert"
)

func TestKK(t *testing.T) {
	for key := range cn {
		if _, ok := ptbr[key]; !ok {
			fmt.Println(key, "===", cn[key])
		}
	}
}

func TestAdd(t *testing.T) {
	Add("cn", map[string]string{})
}

func TestGetWithScope(t *testing.T) {
	config.Initialize(&config.Config{
		Language: CN,
	})
	cn["foo"] = "bar"
	assert.Equal(t, GetWithScope("foo"), "bar")
	cn["user.table.foo2"] = "bar"
	assert.Equal(t, GetWithScope("foo2"), "foo2")
	assert.Equal(t, GetWithScope("foo2", "user"), "foo2")
	assert.Equal(t, GetWithScope("foo2", "user", "table"), "bar")
}

func TestGet(t *testing.T) {
	config.Initialize(&config.Config{
		Language: CN,
	})
	cn["foo"] = "bar"
	assert.Equal(t, Get("foo"), "bar")
}

func TestWithScopes(t *testing.T) {
	assert.Equal(t, WithScopes("foo", "user", "table"), "user.table.foo")
}

func TestGetFromHtml(t *testing.T) {
	config.Initialize(&config.Config{
		Language: CN,
	})
	cn["user.table.foo"] = "bar"
	assert.Equal(t, GetFromHtml("foo", "user", "table"), template.HTML("bar"))
}