-
Notifications
You must be signed in to change notification settings - Fork 1
/
convert.go
91 lines (86 loc) · 1.94 KB
/
convert.go
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// this file is generated by convert_test.go
package opencc
import (
"github.com/caiguanhao/opencc/configs"
"github.com/caiguanhao/opencc/configs/hk2s"
"github.com/caiguanhao/opencc/configs/hk2t"
"github.com/caiguanhao/opencc/configs/jp2t"
"github.com/caiguanhao/opencc/configs/s2hk"
"github.com/caiguanhao/opencc/configs/s2t"
"github.com/caiguanhao/opencc/configs/s2tw"
"github.com/caiguanhao/opencc/configs/s2twp"
"github.com/caiguanhao/opencc/configs/t2hk"
"github.com/caiguanhao/opencc/configs/t2jp"
"github.com/caiguanhao/opencc/configs/t2s"
"github.com/caiguanhao/opencc/configs/t2tw"
"github.com/caiguanhao/opencc/configs/tw2s"
"github.com/caiguanhao/opencc/configs/tw2sp"
"github.com/caiguanhao/opencc/configs/tw2t"
)
var (
Dictionaries = map[string]string{
"hk2s": hk2s.Description,
"hk2t": hk2t.Description,
"jp2t": jp2t.Description,
"s2hk": s2hk.Description,
"s2t": s2t.Description,
"s2tw": s2tw.Description,
"s2twp": s2twp.Description,
"t2hk": t2hk.Description,
"t2jp": t2jp.Description,
"t2s": t2s.Description,
"t2tw": t2tw.Description,
"tw2s": tw2s.Description,
"tw2sp": tw2sp.Description,
"tw2t": tw2t.Description,
}
)
func Convert(dictionary, in string) string {
dicts := dictsForName(dictionary)
return dicts.Convert(in)
}
func dictsForName(name string) configs.Dicts {
if name == "hk2s" {
return hk2s.Dicts
}
if name == "hk2t" {
return hk2t.Dicts
}
if name == "jp2t" {
return jp2t.Dicts
}
if name == "s2hk" {
return s2hk.Dicts
}
if name == "s2t" {
return s2t.Dicts
}
if name == "s2tw" {
return s2tw.Dicts
}
if name == "s2twp" {
return s2twp.Dicts
}
if name == "t2hk" {
return t2hk.Dicts
}
if name == "t2jp" {
return t2jp.Dicts
}
if name == "t2s" {
return t2s.Dicts
}
if name == "t2tw" {
return t2tw.Dicts
}
if name == "tw2s" {
return tw2s.Dicts
}
if name == "tw2sp" {
return tw2sp.Dicts
}
if name == "tw2t" {
return tw2t.Dicts
}
return nil
}