Change: make substitute function public
This commit is contained in:
parent
f8ad7d8035
commit
4d153f396b
14
slug.go
14
slug.go
@ -32,17 +32,17 @@ func MakeLang(s string, lang string) (slug string) {
|
|||||||
// Select substitution language
|
// Select substitution language
|
||||||
switch lang {
|
switch lang {
|
||||||
case "de":
|
case "de":
|
||||||
slug = substitute(slug, deSub)
|
slug = Substitute(slug, deSub)
|
||||||
case "en":
|
case "en":
|
||||||
slug = substitute(slug, enSub)
|
slug = Substitute(slug, enSub)
|
||||||
case "pl":
|
case "pl":
|
||||||
slug = substitute(slug, plSub)
|
slug = Substitute(slug, plSub)
|
||||||
default: // fallback to "en" if lang not found
|
default: // fallback to "en" if lang not found
|
||||||
slug = substitute(slug, enSub)
|
slug = Substitute(slug, enSub)
|
||||||
}
|
}
|
||||||
|
|
||||||
slug = substitute(slug, defaultSub)
|
slug = Substitute(slug, defaultSub)
|
||||||
slug = substitute(slug, CustomSub)
|
slug = Substitute(slug, CustomSub)
|
||||||
|
|
||||||
slug = unidecode.Unidecode(slug)
|
slug = unidecode.Unidecode(slug)
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ func MakeLang(s string, lang string) (slug string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Substitute string chars with provided substitution map.
|
// Substitute string chars with provided substitution map.
|
||||||
func substitute(s string, sub map[rune]string) (buf string) {
|
func Substitute(s string, sub map[rune]string) (buf string) {
|
||||||
for _, c := range s {
|
for _, c := range s {
|
||||||
if d, ok := sub[c]; ok {
|
if d, ok := sub[c]; ok {
|
||||||
buf += d
|
buf += d
|
||||||
|
Loading…
Reference in New Issue
Block a user