Skip to content

Commit

Permalink
Add Norwegian language subs (#50)
Browse files Browse the repository at this point in the history
Co-authored-by: Dobrosław Żybort <[email protected]>
  • Loading branch information
marcusirgens and matrixik authored Jul 26, 2021
1 parent 9a63f1f commit abe4c67
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
16 changes: 15 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, &slSub, &trSub,
&deSub, &enSub, &esSub, &fiSub, &grSub, &kkSub, &nlSub, &plSub, &svSub, &slSub, &trSub, &nbSub, &nnSub,
} {
for key, value := range defaultSub {
(*sub)[key] = value
Expand Down Expand Up @@ -87,6 +87,20 @@ var kkSub = map[rune]string{
'Ұ': "U",
}

var nbSub = map[rune]string{
'&': "og",
'@': "at",
'æ': "ae",
'ø': "oe",
'å': "aa",
'Æ': "Ae",
'Ø': "Oe",
'Å': "Aa",
}

// Norwegian Nynorsk has the same rules
var nnSub = nbSub

var nlSub = map[rune]string{
'&': "en",
'@': "at",
Expand Down
4 changes: 4 additions & 0 deletions slug.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func MakeLang(s string, lang string) (slug string) {
slug = SubstituteRune(slug, plSub)
case "sv", "swe":
slug = SubstituteRune(slug, svSub)
case "nn", "nno":
slug = SubstituteRune(slug, nnSub)
case "nb", "nob":
slug = SubstituteRune(slug, nbSub)
case "sl", "slv":
slug = SubstituteRune(slug, slSub)
case "tr", "tur":
Expand Down
8 changes: 8 additions & 0 deletions slug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ func TestSlugMakeLang(t *testing.T) {
{"sv", "This @ that", "this-snabel-a-that", true},
{"swe", "This & that", "this-och-that", true},
{"swe", "This @ that", "this-snabel-a-that", true},
{"nb", "Ærlig, Østen, Åse", "aerlig-oesten-aase", true},
{"nb", "This & that", "this-og-that", true},
{"nb", "This @ that", "this-at-that", true},
{"nn", "Ærlig, Østen, Åse", "aerlig-oesten-aase", true},
{"nn", "This & that", "this-og-that", true},
{"nn", "This @ that", "this-at-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},
Expand All @@ -115,6 +121,8 @@ 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},
{"nb", "1\"2'3’4‒5–6—7―8", "1234-5-6-7-8", true},
{"nn", "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 abe4c67

Please sign in to comment.