-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmethods.go
49 lines (40 loc) · 1.29 KB
/
methods.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
package t13n
import (
"runtime"
"github.com/goloop/t13n/lang"
)
// String returns string value by rune from the main lib, it's doesn't
// take into account regional linguistic features of transliteration.
func String(c rune) string {
if id := int(c); id < len(lib) {
return lib[id]
}
return ""
}
// Make transliterates a unicode string to an ASCII string, it's doesn't
// take into account regional linguistic features of transliteration.
func Make(t string) string {
return Render(lang.None, t, nil)
}
// Trans transliterates a Unicode string into an ASCII string
// with taking into account regional linguistic features of
// the transliteration depending from the language.
func Trans(l, t string) string {
return Render(l, t, nil)
}
// Render transliterates a Unicode string into an ASCII string
// with taking into account regional linguistic features of
// the transliteration depending from the language.
//
// The third parameter can specify the function of
// custom transliteration rules or nil.
func Render(l, t string, ctr lang.TransRules) (result string) {
return renderString(l, t, ctr, parallelTasks)
}
// Together sets the number of parallel transliteration tasks.
func Together(pt int) int {
if pt > 0 && pt < runtime.NumCPU()*3 {
parallelTasks = pt
}
return parallelTasks
}