Skip to content

Commit

Permalink
Merge pull request #57 from azziko/uz_UZ
Browse files Browse the repository at this point in the history
Add uzbek uz_UZ
  • Loading branch information
goodsign authored Jul 11, 2022
2 parents 04a3233 + 79b4751 commit fbd4764
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 3 deletions.
16 changes: 13 additions & 3 deletions default_formats.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@ const (
DefaultFormatThTHShort = "02/01/2006"
DefaultFormatThTHDateTime = "02/01/2006 15:04"
DefaultFormatThTHTime = "15:04"

DefaultFormatUzUZFull = "Monday, 02 January 2006" // Uzbek (Uzbekistan)
DefaultFormatUzUZLong = "2 January 2006"
DefaultFormatUzUZMedium = "2 Jan 2006"
DefaultFormatUzUZShort = "02.01.2006"
DefaultFormatUzUZDateTime = "02.01.2006 15:04"
DefaultFormatUzUZTime = "15:04"
)

// FullFormatsByLocale maps locales to the'full' date formats for all
Expand Down Expand Up @@ -305,6 +312,7 @@ var FullFormatsByLocale = map[Locale]string{
LocaleUkUA: DefaultFormatUkUAFull,
LocaleLtLT: DefaultFormatLtLTFull,
LocaleThTH: DefaultFormatThTHFull,
LocaleUzUZ: DefaultFormatUzUZFull,
}

// LongFormatsByLocale maps locales to the 'long' date formats for all
Expand Down Expand Up @@ -347,6 +355,7 @@ var LongFormatsByLocale = map[Locale]string{
LocaleUkUA: DefaultFormatUkUALong,
LocaleLtLT: DefaultFormatLtLTLong,
LocaleThTH: DefaultFormatThTHLong,
LocaleUzUZ: DefaultFormatUzUZLong,
}

// MediumFormatsByLocale maps locales to the 'medium' date formats for all
Expand Down Expand Up @@ -389,6 +398,7 @@ var MediumFormatsByLocale = map[Locale]string{
LocaleUkUA: DefaultFormatUkUAMedium,
LocaleLtLT: DefaultFormatLtLTMedium,
LocaleThTH: DefaultFormatThTHMedium,
LocaleUzUZ: DefaultFormatUzUZMedium,
}

// ShortFormatsByLocale maps locales to the 'short' date formats for all
Expand Down Expand Up @@ -430,7 +440,7 @@ var ShortFormatsByLocale = map[Locale]string{
LocaleCsCZ: DefaultFormatCsCZShort,
LocaleUkUA: DefaultFormatUkUAShort,
LocaleLtLT: DefaultFormatLtLTShort,
LocaleThTH: DefaultFormatThTHShort,
LocaleUzUZ: DefaultFormatUzUZShort,
}

// DateTimeFormatsByLocale maps locales to the 'DateTime' date formats for
Expand Down Expand Up @@ -472,7 +482,7 @@ var DateTimeFormatsByLocale = map[Locale]string{
LocaleCsCZ: DefaultFormatCsCZDateTime,
LocaleUkUA: DefaultFormatUkUADateTime,
LocaleLtLT: DefaultFormatLtLTDateTime,
LocaleThTH: DefaultFormatThTHDateTime,
LocaleUzUZ: DefaultFormatUzUZDateTime,
}

// TimeFormatsByLocale maps locales to the 'Time' date formats for
Expand Down Expand Up @@ -514,5 +524,5 @@ var TimeFormatsByLocale = map[Locale]string{
LocaleCsCZ: DefaultFormatCsCZTime,
LocaleUkUA: DefaultFormatUkUATime,
LocaleLtLT: DefaultFormatLtLTTime,
LocaleThTH: DefaultFormatThTHTime,
LocaleUzUZ: DefaultFormatUzUZTime,
}
85 changes: 85 additions & 0 deletions format_uz_uz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package monday

// ============================================================
// Format rules for "uz_UZ" locale: Uzbek (Uzbeksitan)
// ============================================================

var longDayNamesUzUZ = map[string]string{
"Sunday": "Yakshanba",
"Monday": "Dushanba",
"Tuesday": "Seshanba",
"Wednesday": "Chorshanba",
"Thursday": "Payshanba",
"Friday": "Juma",
"Saturday": "Shanba",
}

var shortDayNamesUzUZ = map[string]string{
"Sun": "Ya",
"Mon": "Du",
"Tue": "Se",
"Wed": "Ch",
"Thu": "Pa",
"Fri": "Ju",
"Sat": "Sh",
}

var longMonthNamesUzUZ = map[string]string{
"January": "Yanvar",
"February": "Fevral",
"March": "Mart",
"April": "Aprel",
"May": "May",
"June": "Iyun",
"July": "Iyul",
"August": "Avgust",
"September": "Sentyabr",
"October": "Oktyabr",
"November": "Noyabr",
"December": "Dekabr",
}

var longMonthNamesGenitiveUzUZ = map[string]string{
"January": "yanvar",
"February": "fevral",
"March": "mart",
"April": "aprel",
"May": "may",
"June": "iyun",
"July": "iyul",
"August": "avgust",
"September": "sentyabr",
"October": "oktyabr",
"November": "noyabr",
"December": "dekabr",
}

var shortMonthNamesUzUZ = map[string]string{
"Jan": "Yan",
"Feb": "Fev",
"Mar": "Mar",
"Apr": "Apr",
"May": "May",
"Jun": "Iyun",
"Jul": "Iyul",
"Aug": "Avg",
"Sep": "Sen",
"Oct": "Okt",
"Nov": "Noy",
"Dec": "Dek",
}

var shortMonthNamesGenitiveUzUZ = map[string]string{
"Jan": "yan",
"Feb": "fev",
"Mar": "mar",
"Apr": "apr",
"May": "may",
"Jun": "iyun",
"Jul": "iyul",
"Aug": "avg",
"Sep": "sen",
"Oct": "okt",
"Nov": "noy",
"Dec": "dek",
}
2 changes: 2 additions & 0 deletions locale.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const (
LocaleSlSI = "sl_SI" // Slovenian (Slovenia)
LocaleLtLT = "lt_LT" // Lithuanian (Lithuania)
LocaleThTH = "th_TH" // Thai (Thailand)
LocaleUzUZ = "uz_UZ" // Uzbek (Uzbekistan)
)

// ListLocales returns all locales supported by the package.
Expand Down Expand Up @@ -91,5 +92,6 @@ func ListLocales() []Locale {
LocaleSlSI,
LocaleLtLT,
LocaleThTH,
LocaleUzUZ,
}
}
10 changes: 10 additions & 0 deletions monday.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var internalFormatFuncs = map[Locale]internalFormatFunc{
LocaleSlSI: createCommonFormatFunc(LocaleSlSI),
LocaleLtLT: createCommonFormatFuncWithGenitive(LocaleLtLT),
LocaleThTH: createCommonFormatFunc(LocaleThTH),
LocaleUzUZ: createCommonFormatFuncWithGenitive(LocaleUzUZ),
}

// internalParseFunc is a preprocessor for default time.ParseInLocation func
Expand Down Expand Up @@ -95,6 +96,7 @@ var internalParseFuncs = map[Locale]internalParseFunc{
LocaleSlSI: createCommonParseFunc(LocaleSlSI),
LocaleLtLT: createCommonParsetFuncWithGenitive(LocaleLtLT),
LocaleThTH: parseFuncThCommon(LocaleThTH),
LocaleUzUZ: createCommonParsetFuncWithGenitive(LocaleUzUZ),
}

var knownDaysShort = map[Locale]map[string]string{} // Mapping for 'Format', days of week, short form
Expand Down Expand Up @@ -373,6 +375,14 @@ func fillKnownWords() {
fillKnownDaysShort(shortDayNamesThTH, LocaleThTH)
fillKnownMonthsLong(longMonthNamesThTH, LocaleThTH)
fillKnownMonthsShort(shortMonthNamesThTH, LocaleThTH)

// Uz_UZ: Uzbek (Uzbekistan)
fillKnownDaysLong(longDayNamesUzUZ, LocaleUzUZ)
fillKnownDaysShort(shortDayNamesUzUZ, LocaleUzUZ)
fillKnownMonthsLong(longMonthNamesUzUZ, LocaleUzUZ)
fillKnownMonthsShort(shortMonthNamesUzUZ, LocaleUzUZ)
fillKnownMonthsGenitiveLong(longMonthNamesGenitiveUzUZ, LocaleUzUZ)
fillKnownMonthsGenitiveShort(shortMonthNamesGenitiveUzUZ, LocaleUzUZ)
}

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 @@ -360,6 +360,15 @@ var formatTests = []FormatTest{
{LocaleThTH, time.Date(2022, 5, 13, 0, 0, 0, 0, time.UTC), "2 Jan 2006", "13 พ.ค. 2022"},
{LocaleThTH, time.Date(0, 5, 1, 0, 0, 0, 0, time.UTC), "January", "พฤษภาคม"},
{LocaleThTH, time.Date(0, 5, 13, 0, 0, 0, 0, time.UTC), "2 January", "13 พฤษภาคม"},

{LocaleUzUZ, time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC), "Mon Jan 2 2006", "Se Sen 3 2013"},
{LocaleUzUZ, time.Date(2013, 9, 4, 0, 0, 0, 0, time.UTC), "Monday Jan 2 2006", "Chorshanba Sen 4 2013"},
{LocaleUzUZ, time.Date(2013, 10, 3, 0, 0, 0, 0, time.UTC), "Monday January 02 2006", "Payshanba Oktyabr 03 2013"},
{LocaleUzUZ, time.Date(2013, 11, 3, 0, 0, 0, 0, time.UTC), "Monday. 2 January 2006", "Yakshanba. 3 noyabr 2013"},
{LocaleUzUZ, time.Date(2013, 5, 13, 0, 0, 0, 0, time.UTC), "2006. 2 January. Monday", "2013. 13 may. Dushanba"},
{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"},
}

func TestFormat(t *testing.T) {
Expand Down

0 comments on commit fbd4764

Please sign in to comment.