Skip to content

Commit

Permalink
New language: hu/hun/hungarian (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
theriverman authored Dec 13, 2021
1 parent f347b0c commit e104167
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions languages_substitution.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func init() {
&fiSub,
&frSub,
&grSub,
&huSub,
&idSub,
&kkSub,
&nbSub,
Expand Down Expand Up @@ -96,6 +97,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 idSub = map[rune]string{
'&': "dan",
}
Expand Down
2 changes: 2 additions & 0 deletions slug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 "id", "idn", "ind":
slug = SubstituteRune(slug, idSub)
case "kz", "kk", "kaz":
Expand Down
3 changes: 3 additions & 0 deletions slug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit e104167

Please sign in to comment.