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 kazakh language #40

Merged
merged 2 commits into from
Oct 22, 2019
Merged
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
18 changes: 17 additions & 1 deletion languages_substitution.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package slug
func init() {
// Merge language subs with the default one
for _, sub := range []*map[rune]string{
&deSub, &enSub, &esSub, &fiSub, &grSub, &nlSub, &plSub, &svSub,
&deSub, &enSub, &esSub, &fiSub, &grSub, &kkSub, &nlSub, &plSub, &svSub,
} {
for key, value := range defaultSub {
(*sub)[key] = value
Expand Down Expand Up @@ -100,3 +100,19 @@ var trSub = map[rune]string{
'ç': "c",
'Ç': "C",
}

var kkSub = map[rune]string{
'&': "jane",
'ә': "a",
Comment on lines +105 to +106
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed mapping @ symbol.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People don't use @ at Kazakh, that's why I used default @=>`` ( empty )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange for me. What about writing email address in text (like [email protected])?

Personally I would prefer handling @ but will merge it as is for now, and fix if someone complain.

'ғ': "g",
'қ': "q",
'ң': "n",
'ө': "o",
'ұ': "u",
'Ә': "A",
'Ғ': "G",
'Қ': "Q",
'Ң': "N",
'Ө': "O",
'Ұ': "U",
}
2 changes: 2 additions & 0 deletions slug.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func MakeLang(s string, lang string) (slug string) {
slug = SubstituteRune(slug, fiSub)
case "gr", "el", "ell":
slug = SubstituteRune(slug, grSub)
case "kz", "kk", "kaz":
slug = SubstituteRune(slug, kkSub)
case "nl", "nld":
slug = SubstituteRune(slug, nlSub)
case "pl", "pol":
Expand Down
6 changes: 6 additions & 0 deletions slug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ func TestSlugMakeLang(t *testing.T) {
{"Ell", "ϊχώΩϋ", "ixwwu", false},
{"tr", "şüöğıçŞÜÖİĞÇ", "suogicsuoigc", true},
{"tr", "şüöğıçŞÜÖİĞÇ", "suogicSUOIGC", false},
{"kk", "әғһіңөқұүӘҒҺІҢӨҚҰҮ", "aghinoquuaghinoquu", true},
{"kk", "әғһіңөқұүӘҒҺІҢӨҚҰҮ", "aghinoquuAGHINOQUU", false},
// & fun.
{"de", "This & that", "this-und-that", true},
{"en", "This & that", "this-and-that", true},
Expand All @@ -88,6 +90,8 @@ func TestSlugMakeLang(t *testing.T) {
{"gr", "This & that", "this-kai-that", true},
{"ell", "This & that", "this-kai-that", true},
{"Ell", "This & that", "this-kai-that", true},
{"kk", "This & that", "this-jane-that", true},
{"kk", "This @ that", "this-that", true},
{"nl", "This & that", "this-en-that", true},
{"pl", "This & that", "this-i-that", true},
{"pol", "This & that", "this-i-that", true},
Expand All @@ -104,6 +108,7 @@ func TestSlugMakeLang(t *testing.T) {
{"es", "1\"2'3’4‒5–6—7―8", "1234-5-6-7-8", true},
{"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},
}
Expand Down Expand Up @@ -131,6 +136,7 @@ func TestSlugMakeUserSubstituteLang(t *testing.T) {
{map[string]string{"&": "or"}, "de", "This & that", "this-or-that"}, // by default "&" => "und"
{map[string]string{"&": "or"}, "DEU", "This & that", "this-or-that"}, // by default "&" => "und"
{map[string]string{"&": "or"}, "Fin", "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"
}
Expand Down