diff --git a/languages_substitution.go b/languages_substitution.go index 46213f4..823ddd5 100644 --- a/languages_substitution.go +++ b/languages_substitution.go @@ -10,7 +10,20 @@ 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, &frSub, &grSub, &kkSub, &nlSub, &plSub, &svSub, &slSub, &trSub, &nbSub, &nnSub, + &deSub, + &enSub, + &esSub, + &fiSub, + &frSub, + &grSub, + &kkSub, + &nbSub, + &nlSub, + &nnSub, + &plSub, + &slSub, + &svSub, + &trSub, } { for key, value := range defaultSub { (*sub)[key] = value @@ -116,17 +129,17 @@ var plSub = map[rune]string{ '@': "na", } -var svSub = map[rune]string{ - '&': "och", - '@': "snabel a", -} - var slSub = map[rune]string{ '&': "in", 'Đ': "DZ", 'Δ‘': "dz", } +var svSub = map[rune]string{ + '&': "och", + '@': "snabel a", +} + var trSub = map[rune]string{ '&': "ve", '@': "et", diff --git a/slug.go b/slug.go index 4372ecd..fe92c9b 100644 --- a/slug.go +++ b/slug.go @@ -71,18 +71,18 @@ func MakeLang(s string, lang string) (slug string) { slug = SubstituteRune(slug, grSub) case "kz", "kk", "kaz": slug = SubstituteRune(slug, kkSub) + case "nb", "nob": + slug = SubstituteRune(slug, nbSub) case "nl", "nld": slug = SubstituteRune(slug, nlSub) - case "pl", "pol": - 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 "pl", "pol": + slug = SubstituteRune(slug, plSub) case "sl", "slv": slug = SubstituteRune(slug, slSub) + case "sv", "swe": + slug = SubstituteRune(slug, svSub) case "tr", "tur": slug = SubstituteRune(slug, trSub) default: // fallback to "en" if lang not found diff --git a/slug_test.go b/slug_test.go index d3144a3..6184f0e 100644 --- a/slug_test.go +++ b/slug_test.go @@ -42,6 +42,7 @@ func TestSlugMake(t *testing.T) { {"Γ†", "ae"}, {"Ich heiße", "ich-heisse"}, {"𐀀", ""}, // Bug #53 + {"% 5 @ 4 $ 3 / 2 & 1 & 2 # 3 @ 4 _ 5", "5-at-4-3-2-and-1-and-2-3-at-4-_-5"}, {"This & that", "this-and-that"}, {"fΓ‘cil €", "facil-eu"}, @@ -121,12 +122,12 @@ func TestSlugMakeLang(t *testing.T) { {"fi", "1\"2'3’4β€’5–6β€”7―8", "1234-5-6-7-8", true}, {"gr", "1\"2'3’4β€’5–6β€”7―8", "1234-5-6-7-8", true}, {"kk", "1\"2'3’4β€’5–6β€”7―8", "1234-5-6-7-8", true}, - {"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}, + {"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}, {"sl", "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}, {"tr", "1\"2'3’4β€’5–6β€”7―8", "1234-5-6-7-8", true}, } @@ -155,8 +156,8 @@ func TestSlugMakeUserSubstituteLang(t *testing.T) { {map[string]string{"&": "or"}, "Fin", "This & that", "this-or-that"}, // by default "&" => "ja" {map[string]string{"&": "or"}, "fr", "This & that", "this-or-that"}, // by default "&" => "ja" {map[string]string{"&": "or"}, "kk", "This & that", "this-or-that"}, // by default "&" => "jane" - {map[string]string{"&": "or", "@": "the"}, "sv", "@ This & that", "the-this-or-that"}, // by default "&" => "och", "@" => "snabel a" {map[string]string{"&": "or", "@": "the"}, "de", "@ This & that", "the-this-or-that"}, // by default "&" => "und", "@" => "an" + {map[string]string{"&": "or", "@": "the"}, "sv", "@ This & that", "the-this-or-that"}, // by default "&" => "och", "@" => "snabel a" } for index, smust := range testCases {