From d1b387be3fa977a97256dfbbf799e0eed6ee9136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?FRA=C3=8FSSE=20Charles?= Date: Wed, 15 Jan 2020 18:41:48 +0100 Subject: [PATCH] Adding french language --- languages_substitution.go | 7 ++++++- slug.go | 2 ++ slug_test.go | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/languages_substitution.go b/languages_substitution.go index 931a369..b1c8efe 100644 --- a/languages_substitution.go +++ b/languages_substitution.go @@ -10,7 +10,7 @@ func init() { // TODO: Find better way so all langs are merged automatically and better // tested. for _, sub := range []*map[rune]string{ - &deSub, &enSub, &esSub, &fiSub, &grSub, &kkSub, &nlSub, &plSub, &svSub, &trSub, + &deSub, &enSub, &esSub, &fiSub, &frSub, &grSub, &kkSub, &nlSub, &plSub, &svSub, &trSub, } { for key, value := range defaultSub { (*sub)[key] = value @@ -54,6 +54,11 @@ var fiSub = map[rune]string{ '@': "at", } +var frSub = map[rune]string{ + '&': "et", + '@': "arobase", +} + var grSub = map[rune]string{ '&': "kai", 'η': "i", diff --git a/slug.go b/slug.go index 272cc3f..c49166b 100644 --- a/slug.go +++ b/slug.go @@ -65,6 +65,8 @@ func MakeLang(s string, lang string) (slug string) { slug = SubstituteRune(slug, esSub) case "fi", "fin": slug = SubstituteRune(slug, fiSub) + case "fr", "fra": + slug = SubstituteRune(slug, frSub) case "gr", "el", "ell": slug = SubstituteRune(slug, grSub) case "kz", "kk", "kaz": diff --git a/slug_test.go b/slug_test.go index e43eeed..9c2b9f5 100644 --- a/slug_test.go +++ b/slug_test.go @@ -87,6 +87,8 @@ func TestSlugMakeLang(t *testing.T) { {"en", "This & that", "this-and-that", true}, {"es", "This & that", "this-y-that", true}, {"fi", "This & that", "this-ja-that", true}, + {"fr", "This & that", "this-et-that", true}, + {"fr", "This @ that", "this-arobase-that", true}, {"gr", "This & that", "this-kai-that", true}, {"ell", "This & that", "this-kai-that", true}, {"Ell", "This & that", "this-kai-that", true}, @@ -138,6 +140,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"}, "fr", "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"