From 5f3c437e9bbef39f35ff7681d1baaa31f09cc946 Mon Sep 17 00:00:00 2001 From: pelivan Date: Mon, 19 Jun 2023 10:21:31 +0500 Subject: [PATCH 1/2] kazakh locale added --- default_formats.go | 13 +++++++ format_kk_kz.go | 85 ++++++++++++++++++++++++++++++++++++++++++++++ locale.go | 2 ++ monday.go | 10 ++++++ monday_test.go | 9 +++++ 5 files changed, 119 insertions(+) create mode 100644 format_kk_kz.go diff --git a/default_formats.go b/default_formats.go index be7929f..9d92e78 100644 --- a/default_formats.go +++ b/default_formats.go @@ -270,6 +270,13 @@ const ( DefaultFormatUzUZShort = "02.01.2006" DefaultFormatUzUZDateTime = "02.01.2006 15:04" DefaultFormatUzUZTime = "15:04" + + DefaultFormatKkKZFull = "Monday, 2 January 2006 ж." // Kazakh (Kazakhstan) + DefaultFormatKkKZLong = "2 January 2006 ж." + DefaultFormatKkKZMedium = "02 Jan 2006 ж." + DefaultFormatKkKZShort = "02.01.06" + DefaultFormatKkKZDateTime = "02.01.06, 15:04" + DefaultFormatKkKZTime = "15:04" ) // FullFormatsByLocale maps locales to the'full' date formats for all @@ -313,6 +320,7 @@ var FullFormatsByLocale = map[Locale]string{ LocaleLtLT: DefaultFormatLtLTFull, LocaleThTH: DefaultFormatThTHFull, LocaleUzUZ: DefaultFormatUzUZFull, + LocaleKkKZ: DefaultFormatKkKZFull, } // LongFormatsByLocale maps locales to the 'long' date formats for all @@ -356,6 +364,7 @@ var LongFormatsByLocale = map[Locale]string{ LocaleLtLT: DefaultFormatLtLTLong, LocaleThTH: DefaultFormatThTHLong, LocaleUzUZ: DefaultFormatUzUZLong, + LocaleKkKZ: DefaultFormatKkKZLong, } // MediumFormatsByLocale maps locales to the 'medium' date formats for all @@ -399,6 +408,7 @@ var MediumFormatsByLocale = map[Locale]string{ LocaleLtLT: DefaultFormatLtLTMedium, LocaleThTH: DefaultFormatThTHMedium, LocaleUzUZ: DefaultFormatUzUZMedium, + LocaleKkKZ: DefaultFormatKkKZMedium, } // ShortFormatsByLocale maps locales to the 'short' date formats for all @@ -441,6 +451,7 @@ var ShortFormatsByLocale = map[Locale]string{ LocaleUkUA: DefaultFormatUkUAShort, LocaleLtLT: DefaultFormatLtLTShort, LocaleUzUZ: DefaultFormatUzUZShort, + LocaleKkKZ: DefaultFormatKkKZShort, } // DateTimeFormatsByLocale maps locales to the 'DateTime' date formats for @@ -483,6 +494,7 @@ var DateTimeFormatsByLocale = map[Locale]string{ LocaleUkUA: DefaultFormatUkUADateTime, LocaleLtLT: DefaultFormatLtLTDateTime, LocaleUzUZ: DefaultFormatUzUZDateTime, + LocaleKkKZ: DefaultFormatKkKZDateTime, } // TimeFormatsByLocale maps locales to the 'Time' date formats for @@ -525,4 +537,5 @@ var TimeFormatsByLocale = map[Locale]string{ LocaleUkUA: DefaultFormatUkUATime, LocaleLtLT: DefaultFormatLtLTTime, LocaleUzUZ: DefaultFormatUzUZTime, + LocaleKkKZ: DefaultFormatKkKZTime, } diff --git a/format_kk_kz.go b/format_kk_kz.go new file mode 100644 index 0000000..e07dd51 --- /dev/null +++ b/format_kk_kz.go @@ -0,0 +1,85 @@ +package monday + +// ============================================================ +// Format rules for "kk_KZ" locale: Kazakh (Kazakhstan) +// ============================================================ + +var longDayNamesKkKZ = map[string]string{ + "Sunday": "Жексенбі", + "Monday": "Дүйсенбі", + "Tuesday": "Сейсенбі", + "Wednesday": "Сәрсенбі", + "Thursday": "Бейсенбі", + "Friday": "Жұма", + "Saturday": "Сенбі", +} + +var shortDayNamesKkKZ = map[string]string{ + "Sun": "Жс", + "Mon": "Дс", + "Tue": "Сс", + "Wed": "Ср", + "Thu": "Бс", + "Fri": "Жм", + "Sat": "Сб", +} + +var longMonthNamesKkKZ = map[string]string{ + "January": "Қаңтар", + "February": "Ақпан", + "March": "Наурыз", + "April": "Сәуір", + "May": "Мамыр", + "June": "Маусым", + "July": "Шілде", + "August": "Тамыз", + "September": "Қыркүйек", + "October": "Қазан", + "November": "Қараша", + "December": "Желтоқсан", +} + +var longMonthNamesGenitiveKkKZ = map[string]string{ + "January": "қаңтар", + "February": "ақпан", + "March": "наурыз", + "April": "сәуір", + "May": "мамыр", + "June": "маусым", + "July": "шілде", + "August": "тамыз", + "September": "қыркүйек", + "October": "қазан", + "November": "қараша", + "December": "желтоқсан", +} + +var shortMonthNamesKkKZ = map[string]string{ + "Jan": "Қаң", + "Feb": "Ақп", + "Mar": "Нау", + "Apr": "Сәу", + "May": "Мам", + "Jun": "Мау", + "Jul": "Шіл", + "Aug": "Там", + "Sep": "Қыр", + "Oct": "Қаз", + "Nov": "Қар", + "Dec": "Жел", +} + +var shortMonthNamesGenitiveKkKZ = map[string]string{ + "Jan": "қаң", + "Feb": "ақп", + "Mar": "нау", + "Apr": "сәу", + "May": "мам", + "Jun": "мау", + "Jul": "шіл", + "Aug": "там", + "Sep": "қыр", + "Oct": "қаз", + "Nov": "қар", + "Dec": "жел", +} diff --git a/locale.go b/locale.go index 44ec74c..f9990fd 100644 --- a/locale.go +++ b/locale.go @@ -48,6 +48,7 @@ const ( LocaleLtLT = "lt_LT" // Lithuanian (Lithuania) LocaleThTH = "th_TH" // Thai (Thailand) LocaleUzUZ = "uz_UZ" // Uzbek (Uzbekistan) + LocaleKkKZ = "kk_KZ" // Kazakh (Kazakhstan) ) // ListLocales returns all locales supported by the package. @@ -93,5 +94,6 @@ func ListLocales() []Locale { LocaleLtLT, LocaleThTH, LocaleUzUZ, + LocaleKkKZ, } } diff --git a/monday.go b/monday.go index 8c03061..e24ae7a 100644 --- a/monday.go +++ b/monday.go @@ -50,6 +50,7 @@ var internalFormatFuncs = map[Locale]internalFormatFunc{ LocaleLtLT: createCommonFormatFuncWithGenitive(LocaleLtLT), LocaleThTH: createCommonFormatFunc(LocaleThTH), LocaleUzUZ: createCommonFormatFuncWithGenitive(LocaleUzUZ), + LocaleKkKZ: createCommonFormatFuncWithGenitive(LocaleKkKZ), } // internalParseFunc is a preprocessor for default time.ParseInLocation func @@ -97,6 +98,7 @@ var internalParseFuncs = map[Locale]internalParseFunc{ LocaleLtLT: createCommonParsetFuncWithGenitive(LocaleLtLT), LocaleThTH: parseFuncThCommon(LocaleThTH), LocaleUzUZ: createCommonParsetFuncWithGenitive(LocaleUzUZ), + LocaleKkKZ: createCommonParsetFuncWithGenitive(LocaleKkKZ), } var knownDaysShort = map[Locale]map[string]string{} // Mapping for 'Format', days of week, short form @@ -383,6 +385,14 @@ func fillKnownWords() { fillKnownMonthsShort(shortMonthNamesUzUZ, LocaleUzUZ) fillKnownMonthsGenitiveLong(longMonthNamesGenitiveUzUZ, LocaleUzUZ) fillKnownMonthsGenitiveShort(shortMonthNamesGenitiveUzUZ, LocaleUzUZ) + + // Kk_KZ: Kazakh (Kazakhstan) + fillKnownDaysLong(longDayNamesKkKZ, LocaleKkKZ) + fillKnownDaysShort(shortDayNamesKkKZ, LocaleKkKZ) + fillKnownMonthsLong(longMonthNamesKkKZ, LocaleKkKZ) + fillKnownMonthsShort(shortMonthNamesKkKZ, LocaleKkKZ) + fillKnownMonthsGenitiveLong(longMonthNamesGenitiveKkKZ, LocaleKkKZ) + fillKnownMonthsGenitiveShort(shortMonthNamesGenitiveKkKZ, LocaleKkKZ) } func fill(src map[string]string, dest map[Locale]map[string]string, locale Locale) { diff --git a/monday_test.go b/monday_test.go index 09c296d..f5bf547 100644 --- a/monday_test.go +++ b/monday_test.go @@ -369,6 +369,15 @@ var formatTests = []FormatTest{ {LocaleUzUZ, time.Date(2013, 5, 13, 0, 0, 0, 0, time.UTC), "2 Jan 2006", "13 may 2013"}, {LocaleUzUZ, time.Date(0, 5, 1, 0, 0, 0, 0, time.UTC), "January", "May"}, {LocaleUzUZ, time.Date(0, 5, 13, 0, 0, 0, 0, time.UTC), "2 January", "13 may"}, + + {LocaleKkKZ, time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC), "Mon Jan 2 2006", "Сс Қыр 3 2013"}, + {LocaleKkKZ, time.Date(2013, 9, 4, 0, 0, 0, 0, time.UTC), "Monday Jan 2 2006", "Сәрсенбі Қыр 4 2013"}, + {LocaleKkKZ, time.Date(2013, 10, 3, 0, 0, 0, 0, time.UTC), "Monday January 02 2006", "Бейсенбі Қазан 03 2013"}, + {LocaleKkKZ, time.Date(2013, 11, 3, 0, 0, 0, 0, time.UTC), "Monday. 2 January 2006", "Жексенбі. 3 қараша 2013"}, + {LocaleKkKZ, time.Date(2013, 5, 13, 0, 0, 0, 0, time.UTC), "2006. 2 January. Monday", "2013. 13 мамыр. Дүйсенбі"}, + {LocaleKkKZ, time.Date(2013, 5, 13, 0, 0, 0, 0, time.UTC), "2 Jan 2006", "13 мам 2013"}, + {LocaleKkKZ, time.Date(0, 5, 1, 0, 0, 0, 0, time.UTC), "January", "Мамыр"}, + {LocaleKkKZ, time.Date(0, 5, 13, 0, 0, 0, 0, time.UTC), "2 January", "13 мамыр"}, } func TestFormat(t *testing.T) { From 70071cda531dc99b548d1f96fae71a16308a45a6 Mon Sep 17 00:00:00 2001 From: pelivan Date: Mon, 19 Jun 2023 10:34:55 +0500 Subject: [PATCH 2/2] kazakh locale added. readme update --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4d76275..6d67214 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,8 @@ const ( LocaleSlSI = "sl_SI" // Slovenian (Slovenia) LocaleLtLT = "lt_LT" // Lithuanian (Lithuania) LocaleThTH = "th_TH" // Thai (Thailand) + LocaleUzUZ = "uz_UZ" // Uzbek (Uzbekistan) + LocaleKkKZ = "kk_KZ" // Kazakh (Kazakhstan) ) ```