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 Vietnamese substitution #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
87 changes: 87 additions & 0 deletions languages_substitution.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func init() {
&slSub,
&svSub,
&trSub,
&viSub,
} {
for key, value := range defaultSub {
(*sub)[key] = value
Expand Down Expand Up @@ -311,3 +312,89 @@ var bgSub = map[rune]string{
'ю': "yu",
'я': "ya",
}

var viSub = map[rune]string{
'&': "va",
'@': "a cong",
'$': "do la",
'%': " phan tram",
'*': "sao",
'+': "cong",
'=': "bang",
'<': "nho hon",
'>': "lon hon",
'đ': "d",
'Đ': "D",
'ă': "a",
'Ă': "A",
'â': "a",
'Â': "A",
'ê': "e",
'Ê': "E",
'ô': "o",
'Ô': "O",
'ơ': "o",
'Ơ': "O",
'ư': "u",
'Ư': "U",
'à': "a",
'À': "A",
'á': "a",
'Á': "A",
'ạ': "a",
'Ạ': "A",
'ả': "a",
'Ả': "A",
'ã': "a",
'Ã': "A",
'è': "e",
'È': "E",
'é': "e",
'É': "E",
'ẹ': "e",
'Ẹ': "E",
'ẻ': "e",
'Ẻ': "E",
'ẽ': "e",
'Ẽ': "E",
'ì': "i",
'Ì': "I",
'í': "i",
'Í': "I",
'ị': "i",
'Ị': "I",
'ỉ': "i",
'Ỉ': "I",
'ĩ': "i",
'Ĩ': "I",
'ò': "o",
'Ò': "O",
'ó': "o",
'Ó': "O",
'ọ': "o",
'Ọ': "O",
'ỏ': "o",
'Ỏ': "O",
'õ': "o",
'Õ': "O",
'ù': "u",
'Ù': "U",
'ú': "u",
'Ú': "U",
'ụ': "u",
'Ụ': "U",
'ủ': "u",
'Ủ': "U",
'ũ': "u",
'Ũ': "U",
'ỳ': "y",
'Ỳ': "Y",
'ý': "y",
'Ý': "Y",
'ỵ': "y",
'Ỵ': "Y",
'ỷ': "y",
'Ỷ': "Y",
'ỹ': "y",
'Ỹ': "Y",
}
2 changes: 2 additions & 0 deletions slug.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ func MakeLang(s string, lang string) (slug string) {
slug = SubstituteRune(slug, svSub)
case "tr", "tur":
slug = SubstituteRune(slug, trSub)
case "vi":
slug = SubstituteRune(slug, viSub)
default: // fallback to "en" if lang not found
slug = SubstituteRune(slug, enSub)
}
Expand Down
5 changes: 5 additions & 0 deletions slug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ func TestSlugMakeLang(t *testing.T) {
{"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},
{"vi", "10 Bí Quyết Để Thành Công Trong Công Việc", "10-bi-quyet-de-thanh-cong-trong-cong-viec", true},
{"vi", "Cách Sử Dụng @ trong Email Hiệu Quả", "cach-su-dung-a-cong-trong-email-hieu-qua", true},
{"vi", "Học Lập Trình: #1 Hành Trình Đầy Thử Thách!", "hoc-lap-trinh-1-hanh-trinh-day-thu-thach", true},
{"vi", "Câu Chuyện Thành Công & Những Bài Học", "cau-chuyen-thanh-cong-va-nhung-bai-hoc", true},
{"vi", "Tăng Thu Nhập 100% Nhờ Kinh Doanh Online!", "tang-thu-nhap-100-phan-tram-nho-kinh-doanh-online", true},
}

for index, smlt := range testCases {
Expand Down
Loading