Skip to content

Commit

Permalink
Merge pull request #62 from ED-iitu/kazakh-locale
Browse files Browse the repository at this point in the history
kazakh locale added
  • Loading branch information
goodsign authored Jun 20, 2023
2 parents fbd4764 + 70071cd commit fc34b97
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
```

Expand Down
13 changes: 13 additions & 0 deletions default_formats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -525,4 +537,5 @@ var TimeFormatsByLocale = map[Locale]string{
LocaleUkUA: DefaultFormatUkUATime,
LocaleLtLT: DefaultFormatLtLTTime,
LocaleUzUZ: DefaultFormatUzUZTime,
LocaleKkKZ: DefaultFormatKkKZTime,
}
85 changes: 85 additions & 0 deletions format_kk_kz.go
Original file line number Diff line number Diff line change
@@ -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": "жел",
}
2 changes: 2 additions & 0 deletions locale.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -93,5 +94,6 @@ func ListLocales() []Locale {
LocaleLtLT,
LocaleThTH,
LocaleUzUZ,
LocaleKkKZ,
}
}
10 changes: 10 additions & 0 deletions monday.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions monday_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit fc34b97

Please sign in to comment.