Skip to content

Commit

Permalink
Added Slovenian substitutions and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanb authored and matrixik committed Jul 26, 2021
1 parent 4626f56 commit 9a63f1f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion languages_substitution.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func init() {
// TODO: Find better way so all langs are merged automatically and better
// tested.
for _, sub := range []*map[rune]string{
&deSub, &enSub, &esSub, &fiSub, &grSub, &kkSub, &nlSub, &plSub, &svSub, &trSub,
&deSub, &enSub, &esSub, &fiSub, &grSub, &kkSub, &nlSub, &plSub, &svSub, &slSub, &trSub,
} {
for key, value := range defaultSub {
(*sub)[key] = value
Expand Down Expand Up @@ -102,6 +102,12 @@ var svSub = map[rune]string{
'@': "snabel a",
}

var slSub = map[rune]string{
'&': "in",
'Đ': "DZ",
'đ': "dz",
}

var trSub = map[rune]string{
'&': "ve",
'@': "et",
Expand Down
2 changes: 2 additions & 0 deletions slug.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ func MakeLang(s string, lang string) (slug string) {
slug = SubstituteRune(slug, plSub)
case "sv", "swe":
slug = SubstituteRune(slug, svSub)
case "sl", "slv":
slug = SubstituteRune(slug, slSub)
case "tr", "tur":
slug = SubstituteRune(slug, trSub)
default: // fallback to "en" if lang not found
Expand Down
4 changes: 4 additions & 0 deletions slug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func TestSlugMake(t *testing.T) {
{"\"C'est déjà l’été.\"", "cest-deja-lete"},
{"jaja---lol-méméméoo--a", "jaja-lol-mememeoo-a"},
{"影師", "ying-shi"},
{"Đanković & Kožušček", "dankovic-and-kozuscek"},
}

for index, st := range testCases {
Expand Down Expand Up @@ -100,6 +101,8 @@ func TestSlugMakeLang(t *testing.T) {
{"swe", "This & that", "this-och-that", true},
{"swe", "This @ that", "this-snabel-a-that", true},
{"tr", "This & that", "this-ve-that", true},
{"sl", "đanković & Kožušček", "dzankovic-in-kozuscek", true},
{"sl", "ĐankoVIĆ & KOŽUŠČEK", "DZankoVIC-in-KOZUSCEK", false},
{"test", "This & that", "this-and-that", true}, // unknown lang, fallback to "en"
// Test defaultSub, when adding new lang copy/paste this line,
// it contain special characters.
Expand All @@ -112,6 +115,7 @@ func TestSlugMakeLang(t *testing.T) {
{"nl", "1\"2'3’4‒5–6—7―8", "1234-5-6-7-8", true},
{"pl", "1\"2'3’4‒5–6—7―8", "1234-5-6-7-8", true},
{"sv", "1\"2'3’4‒5–6—7―8", "1234-5-6-7-8", true},
{"sl", "1\"2'3’4-5–6—7―8", "1234-5-6-7-8", true},
{"tr", "1\"2'3’4‒5–6—7―8", "1234-5-6-7-8", true},
}

Expand Down

0 comments on commit 9a63f1f

Please sign in to comment.