Skip to content

Commit

Permalink
Add support for Finnish substitutions (gosimple#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
henkka authored and matrixik committed Sep 14, 2018
1 parent 91d42f4 commit 5a8a61f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions languages_substitution.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ var defaultSub = map[rune]string{
'―': "-", // horizontal bar
}

var fiSub = map[rune]string{
'&': "ja",
'@': "at",
}

var nlSub = map[rune]string{
'&': "en",
'@': "at",
Expand Down
2 changes: 2 additions & 0 deletions slug.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ func MakeLang(s string, lang string) (slug string) {
slug = SubstituteRune(slug, grSub)
case "nl":
slug = SubstituteRune(slug, nlSub)
case "fi":
slug = SubstituteRune(slug, fiSub)
default: // fallback to "en" if lang not found
slug = SubstituteRune(slug, enSub)
}
Expand Down
1 change: 1 addition & 0 deletions slug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func TestSlugMakeLang(t *testing.T) {
{"es", "This & that", "this-y-that"},
{"gr", "This & that", "this-kai-that"},
{"nl", "This & that", "this-en-that"},
{"fi", "This & that", "this-ja-that"},
{"test", "This & that", "this-and-that"}, // unknown lang, fallback to "en"
}

Expand Down

0 comments on commit 5a8a61f

Please sign in to comment.