Skip to content

Commit

Permalink
Add portuguese language (#78)
Browse files Browse the repository at this point in the history
Co-authored-by: Guilherme Santos <[email protected]>
Co-authored-by: Dobrosław Żybort <[email protected]>
  • Loading branch information
3 people authored Feb 24, 2024
1 parent a9e699c commit 412e31a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions languages_substitution.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func init() {
&nlSub,
&nnSub,
&plSub,
&ptSub,
&roSub,
&slSub,
&svSub,
Expand Down Expand Up @@ -190,6 +191,20 @@ var plSub = map[rune]string{
var ptSub = map[rune]string{
'&': "e",
'@': "em",
'á': "a",
'Á': "A",
'é': "e",
'É': "E",
'í': "i",
'Í': "I",
'ó': "o",
'Ó': "O",
'ö': "o",
'Ö': "O",
'ú': "u",
'Ú': "U",
'ü': "u",
'Ü': "U",
}

var roSub = map[rune]string{
Expand Down
2 changes: 1 addition & 1 deletion slug.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func MakeLang(s string, lang string) (slug string) {
slug = SubstituteRune(slug, nnSub)
case "pl", "pol":
slug = SubstituteRune(slug, plSub)
case "pt", "prt", "pt-br", "bra", "por":
case "pt", "prt", "pt-br", "br", "bra", "por":
slug = SubstituteRune(slug, ptSub)
case "ro", "rou":
slug = SubstituteRune(slug, roSub)
Expand Down
1 change: 1 addition & 0 deletions slug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func TestSlugMakeLang(t *testing.T) {
{"hu", "SzÉlÜtÖtt ŰrÚjsÁgírÓnŐ", "SzElUtOtt-UrUjsAgirOnO", false},
{"kk", "әғһіңөқұүӘҒҺІҢӨҚҰҮ", "aghinoquuaghinoquu", true},
{"kk", "әғһіңөқұүӘҒҺІҢӨҚҰҮ", "aghinoquuAGHINOQUU", false},
{"pt", "áÁéÉíÍóÓöÖúÚüÜ", "aAeEiIoOoOuUuU", false},
{"ro", "ĂăÂăÎîȘșȚț", "aaaaiisstt", true},
{"ro", "ĂăÂăÎîȘșȚț", "AaAaIiSsTt", false},
{"tr", "şüöğıçŞÜÖİĞÇ", "suogicsuoigc", true},
Expand Down

0 comments on commit 412e31a

Please sign in to comment.