Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Norwegian language subs #50

Merged
merged 2 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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