From a17f6e3fc5726b3996e989effe6fa065ed608c2c Mon Sep 17 00:00:00 2001 From: Kristof Daja Date: Sun, 12 Dec 2021 22:50:34 +0100 Subject: [PATCH] New supported language: hu/hun/hungarian --- languages_substitution.go | 22 ++++++++++++++++++++++ slug.go | 2 ++ slug_test.go | 3 +++ 3 files changed, 27 insertions(+) diff --git a/languages_substitution.go b/languages_substitution.go index f7ab294..508e1e6 100644 --- a/languages_substitution.go +++ b/languages_substitution.go @@ -17,6 +17,7 @@ func init() { &fiSub, &frSub, &grSub, + &huSub, &kkSub, &nbSub, &nlSub, @@ -95,6 +96,27 @@ var grSub = map[rune]string{ 'ϋ': "u", } +var huSub = map[rune]string{ + 'á': "a", + 'Á': "A", + 'é': "e", + 'É': "E", + 'í': "i", + 'Í': "I", + 'ó': "o", + 'Ó': "O", + 'ö': "o", + 'Ö': "O", + 'ő': "o", + 'Ő': "O", + 'ú': "u", + 'Ú': "U", + 'ü': "u", + 'Ü': "U", + 'ű': "u", + 'Ű': "U", +} + var kkSub = map[rune]string{ '&': "jane", 'ә': "a", diff --git a/slug.go b/slug.go index 2917bbf..891c546 100644 --- a/slug.go +++ b/slug.go @@ -71,6 +71,8 @@ func MakeLang(s string, lang string) (slug string) { slug = SubstituteRune(slug, frSub) case "gr", "el", "ell": slug = SubstituteRune(slug, grSub) + case "hu", "hun": + slug = SubstituteRune(slug, huSub) case "kz", "kk", "kaz": slug = SubstituteRune(slug, kkSub) case "nb", "nob": diff --git a/slug_test.go b/slug_test.go index 9376c7c..7c3203b 100644 --- a/slug_test.go +++ b/slug_test.go @@ -85,6 +85,9 @@ func TestSlugMakeLang(t *testing.T) { {"en", "äÄäöÖöüÜü", "aAaoOouUu", false}, {"gr", "ϊχώΩϋ", "ixwwu", true}, {"gr", "ϊχώΩϋ", "ixwwu", false}, + {"hu", "Árvíztűrő tükörfúrógép", "arvizturo-tukorfurogep", true}, + {"hu", "Árvíztűrő tükörfúrógép", "Arvizturo-tukorfurogep", false}, + {"hu", "SzÉlÜtÖtt ŰrÚjsÁgírÓnŐ", "SzElUtOtt-UrUjsAgirOnO", false}, {"Ell", "ϊχώΩϋ", "ixwwu", true}, {"Ell", "ϊχώΩϋ", "ixwwu", false}, {"tr", "şüöğıçŞÜÖİĞÇ", "suogicsuoigc", true},