Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/goodsign/monday
Browse files Browse the repository at this point in the history
  • Loading branch information
thebaer committed Sep 21, 2023
2 parents 44f10ff + 534cfb3 commit c82bce1
Show file tree
Hide file tree
Showing 12 changed files with 361 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ const (
LocaleCsCZ = "cs_CZ" // Czech (Czech Republic)
LocaleSlSI = "sl_SI" // Slovenian (Slovenia)
LocaleLtLT = "lt_LT" // Lithuanian (Lithuania)
LocaleEtEE = "et_EE" // Estonian (Estonia)
LocaleHrHR = "hr_HR" // Croatian (Croatia)
LocaleLvLV = "lv_LV" // Latvian (Latvia)
LocaleSkSK = "sk_SK" // Slovak (Slovakia)
LocaleThTH = "th_TH" // Thai (Thailand)
LocaleUzUZ = "uz_UZ" // Uzbek (Uzbekistan)
LocaleKkKZ = "kk_KZ" // Kazakh (Kazakhstan)
Expand Down
4 changes: 4 additions & 0 deletions automation.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ func (ld *LocaleDetector) detectLocale(value string) Locale {
for _, v := range wordsRx.FindAllStringSubmatchIndex(value, -1) {
word := strings.ToLower(value[v[0]:v[1]])

if len(word) <= 1 {
continue
}

if localesSet, ok := ld.localeMap[word]; ok {
localesSet.Each(func(loc Locale) bool {
if _, ok := localesMap[loc]; !ok {
Expand Down
48 changes: 48 additions & 0 deletions default_formats.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,34 @@ const (
DefaultFormatLtLTDateTime = "2006-01-02, 15:04"
DefaultFormatLtLTTime = "15:04"

DefaultFormatEtEEFull = "Monday, 2. January 2006" // Estonian (Estonia)
DefaultFormatEtEELong = "2. January 2006"
DefaultFormatEtEEMedium = "2. Jan 2006"
DefaultFormatEtEEShort = "2.1.2006"
DefaultFormatEtEEDateTime = "2.1.2006 15:04"
DefaultFormatEtEETime = "2.1.2006 15:04"

DefaultFormatHrHRFull = "Monday, 2. January 2006." // Croatian (Croatia)
DefaultFormatHrHRLong = "2. January 2006."
DefaultFormatHrHRMedium = "2. Jan 2006."
DefaultFormatHrHRShort = "2.1.2006."
DefaultFormatHrHRDateTime = "2.1.2006. 15:04"
DefaultFormatHrHRTime = "15:04"

DefaultFormatLvLVFull = "Monday, 2006. gada 2. January" // Latvian (Latvia)
DefaultFormatLvLVLong = "2006. gada 2. January"
DefaultFormatLvLVMedium = "2006. g. 2. Jan."
DefaultFormatLvLVShort = "2.1.2006."
DefaultFormatLvLVDateTime = "2.1.2006. 15:04"
DefaultFormatLvLVTime = "15:04"

DefaultFormatSkSKFull = "Monday, 2. January 2006" // Slovak (Slovakia)
DefaultFormatSkSKLong = "2. January 2006"
DefaultFormatSkSKMedium = "2. 1. 2006"
DefaultFormatSkSKShort = "2. 1. 2006"
DefaultFormatSkSKDateTime = "2. 1. 2006, 15:04"
DefaultFormatSkSKTime = "15:04"

DefaultFormatThTHFull = "Monday ที่ 2 January 2006" // Thai (Thailand)
DefaultFormatThTHLong = "วันที่ 2 January 2006"
DefaultFormatThTHLongNoYr = "วันที่ 2 January"
Expand Down Expand Up @@ -357,6 +385,10 @@ var FullFormatsByLocale = map[Locale]string{
LocaleCsCZ: DefaultFormatCsCZFull,
LocaleUkUA: DefaultFormatUkUAFull,
LocaleLtLT: DefaultFormatLtLTFull,
LocaleEtEE: DefaultFormatEtEEFull,
LocaleHrHR: DefaultFormatHrHRFull,
LocaleLvLV: DefaultFormatLvLVFull,
LocaleSkSK: DefaultFormatSkSKFull,
LocaleThTH: DefaultFormatThTHFull,
LocaleUzUZ: DefaultFormatUzUZFull,
LocaleKkKZ: DefaultFormatKkKZFull,
Expand Down Expand Up @@ -401,6 +433,10 @@ var LongFormatsByLocale = map[Locale]string{
LocaleCsCZ: DefaultFormatCsCZLong,
LocaleUkUA: DefaultFormatUkUALong,
LocaleLtLT: DefaultFormatLtLTLong,
LocaleEtEE: DefaultFormatEtEELong,
LocaleHrHR: DefaultFormatHrHRLong,
LocaleLvLV: DefaultFormatLvLVLong,
LocaleSkSK: DefaultFormatSkSKLong,
LocaleThTH: DefaultFormatThTHLong,
LocaleUzUZ: DefaultFormatUzUZLong,
LocaleKkKZ: DefaultFormatKkKZLong,
Expand Down Expand Up @@ -489,6 +525,10 @@ var MediumFormatsByLocale = map[Locale]string{
LocaleCsCZ: DefaultFormatCsCZMedium,
LocaleUkUA: DefaultFormatUkUAMedium,
LocaleLtLT: DefaultFormatLtLTMedium,
LocaleEtEE: DefaultFormatEtEEMedium,
LocaleHrHR: DefaultFormatHrHRMedium,
LocaleLvLV: DefaultFormatLvLVMedium,
LocaleSkSK: DefaultFormatSkSKMedium,
LocaleThTH: DefaultFormatThTHMedium,
LocaleUzUZ: DefaultFormatUzUZMedium,
LocaleKkKZ: DefaultFormatKkKZMedium,
Expand Down Expand Up @@ -533,6 +573,10 @@ var ShortFormatsByLocale = map[Locale]string{
LocaleCsCZ: DefaultFormatCsCZShort,
LocaleUkUA: DefaultFormatUkUAShort,
LocaleLtLT: DefaultFormatLtLTShort,
LocaleEtEE: DefaultFormatEtEEShort,
LocaleHrHR: DefaultFormatHrHRShort,
LocaleLvLV: DefaultFormatLvLVShort,
LocaleSkSK: DefaultFormatSkSKShort,
LocaleUzUZ: DefaultFormatUzUZShort,
LocaleKkKZ: DefaultFormatKkKZShort,
}
Expand Down Expand Up @@ -576,6 +620,10 @@ var DateTimeFormatsByLocale = map[Locale]string{
LocaleCsCZ: DefaultFormatCsCZDateTime,
LocaleUkUA: DefaultFormatUkUADateTime,
LocaleLtLT: DefaultFormatLtLTDateTime,
LocaleEtEE: DefaultFormatEtEEDateTime,
LocaleHrHR: DefaultFormatHrHRDateTime,
LocaleLvLV: DefaultFormatLvLVDateTime,
LocaleSkSK: DefaultFormatSkSKDateTime,
LocaleUzUZ: DefaultFormatUzUZDateTime,
LocaleKkKZ: DefaultFormatKkKZDateTime,
}
Expand Down
2 changes: 1 addition & 1 deletion format_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func createCommonParseFunc(locale Locale) internalParseFunc {
}
}

func createCommonParsetFuncWithGenitive(locale Locale) internalParseFunc {
func createCommonParseFuncWithGenitive(locale Locale) internalParseFunc {
return func(layout, value string) (res string) {
return commonGenitiveFormatFunc(value, layout,
knownDaysShortReverse[locale], knownDaysLongReverse[locale],
Expand Down
55 changes: 55 additions & 0 deletions format_et_ee.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package monday

// ============================================================
// Format rules for "et_EE" locale: Estonian (Estonia)
// ============================================================

var longDayNamesEtEE = map[string]string{
"Sunday": "pühapäev",
"Monday": "esmaspäev",
"Tuesday": "teisipäev",
"Wednesday": "kolmapäev",
"Thursday": "neljapäev",
"Friday": "reede",
"Saturday": "laupäev",
}

var shortDayNamesEtEE = map[string]string{
"Sun": "P",
"Mon": "E",
"Tue": "T",
"Wed": "K",
"Thu": "N",
"Fri": "R",
"Sat": "L",
}

var longMonthNamesEtEE = map[string]string{
"January": "jaanuar",
"February": "veebruar",
"March": "märts",
"April": "aprill",
"May": "mai",
"June": "juuni",
"July": "juuli",
"August": "august",
"September": "september",
"October": "oktoober",
"November": "november",
"December": "detsember",
}

var shortMonthNamesEtEE = map[string]string{
"Jan": "jaan",
"Feb": "veebr",
"Mar": "märts",
"Apr": "apr",
"May": "mai",
"Jun": "juuni",
"Jul": "juuli",
"Aug": "aug",
"Sep": "sept",
"Oct": "okt",
"Nov": "nov",
"Dec": "dets",
}
55 changes: 55 additions & 0 deletions format_hr_hr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package monday

// ============================================================
// Format rules for "hr_HR" locale: Croatian (Croatia)
// ============================================================

var longDayNamesHrHR = map[string]string{
"Sunday": "nedjelja",
"Monday": "ponedjeljak",
"Tuesday": "utorak",
"Wednesday": "srijeda",
"Thursday": "četvrtak",
"Friday": "petak",
"Saturday": "subota",
}

var shortDayNamesHrHR = map[string]string{
"Sun": "ned",
"Mon": "pon",
"Tue": "uto",
"Wed": "sri",
"Thu": "čet",
"Fri": "pet",
"Sat": "sub",
}

var longMonthNamesHrHR = map[string]string{
"January": "siječanj",
"February": "veljača",
"March": "ožujak",
"April": "travanj",
"May": "svibanj",
"June": "lipanj",
"July": "srpanj",
"August": "kolovoz",
"September": "rujan",
"October": "listopad",
"November": "studeni",
"December": "prosinac",
}

var shortMonthNamesHrHR = map[string]string{
"Jan": "sij",
"Feb": "velj",
"Mar": "ožu",
"Apr": "tra",
"May": "svi",
"Jun": "lip",
"Jul": "srp",
"Aug": "kol",
"Sep": "ruj",
"Oct": "lis",
"Nov": "stu",
"Dec": "pro",
}
2 changes: 1 addition & 1 deletion format_id_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var shortMonthNamesIdID = map[string]string{
"May": "Mei",
"Jun": "Jun",
"Jul": "Jul",
"Aug": "Ags",
"Aug": "Agu",
"Sep": "Sep",
"Oct": "Okt",
"Nov": "Nov",
Expand Down
55 changes: 55 additions & 0 deletions format_lv_lv.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package monday

// ============================================================
// Format rules for "lv_LV" locale: Latvian (Latvia)
// ============================================================

var longDayNamesLvLV = map[string]string{
"Sunday": "Svētdiena",
"Monday": "Pirmdiena",
"Tuesday": "Otrdiena",
"Wednesday": "Trešdiena",
"Thursday": "Ceturtdiena",
"Friday": "Piektdiena",
"Saturday": "Sestdiena",
}

var shortDayNamesLvLV = map[string]string{
"Sun": "Svētd",
"Mon": "Pirmd",
"Tue": "Otrd",
"Wed": "Trešd",
"Thu": "Ceturtd",
"Fri": "Piektd",
"Sat": "Sestd",
}

var longMonthNamesLvLV = map[string]string{
"January": "janvāris",
"February": "februāris",
"March": "marts",
"April": "aprīlis",
"May": "maijs",
"June": "jūnijs",
"July": "jūlijs",
"August": "augusts",
"September": "septembris",
"October": "oktobris",
"November": "novembris",
"December": "decembris",
}

var shortMonthNamesLvLV = map[string]string{
"Jan": "janv",
"Feb": "febr",
"Mar": "marts",
"Apr": "apr",
"May": "maijs",
"Jun": "jūn",
"Jul": "jūl",
"Aug": "aug",
"Sep": "sept",
"Oct": "okt",
"Nov": "nov",
"Dec": "dec",
}
55 changes: 55 additions & 0 deletions format_sk_sk.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package monday

// ============================================================
// Format rules for "sk_SK" locale: Slovak (Slovakia)
// ============================================================

var longDayNamesSkSK = map[string]string{
"Sunday": "nedeľa",
"Monday": "pondelok",
"Tuesday": "utorok",
"Wednesday": "streda",
"Thursday": "štvrtok",
"Friday": "piatok",
"Saturday": "sobota",
}

var shortDayNamesSkSK = map[string]string{
"Sun": "ne",
"Mon": "po",
"Tue": "ut",
"Wed": "st",
"Thu": "št",
"Fri": "pi",
"Sat": "so",
}

var longMonthNamesSkSK = map[string]string{
"January": "január",
"February": "február",
"March": "marec",
"April": "apríl",
"May": "máj",
"June": "jún",
"July": "júl",
"August": "august",
"September": "september",
"October": "október",
"November": "november",
"December": "december",
}

var shortMonthNamesSkSK = map[string]string{
"Jan": "jan",
"Feb": "feb",
"Mar": "mar",
"Apr": "apr",
"May": "máj",
"Jun": "jún",
"Jul": "júl",
"Aug": "aug",
"Sep": "sep",
"Oct": "okt",
"Nov": "nov",
"Dec": "dec",
}
8 changes: 8 additions & 0 deletions locale.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ const (
LocaleCsCZ = "cs_CZ" // Czech (Czech Republic)
LocaleSlSI = "sl_SI" // Slovenian (Slovenia)
LocaleLtLT = "lt_LT" // Lithuanian (Lithuania)
LocaleEtEE = "et_EE" // Estonian (Estonia)
LocaleHrHR = "hr_HR" // Croatian (Croatia)
LocaleLvLV = "lv_LV" // Latvian (Latvia)
LocaleSkSK = "sk_SK" // Slovak (Slovakia)
LocaleThTH = "th_TH" // Thai (Thailand)
LocaleUzUZ = "uz_UZ" // Uzbek (Uzbekistan)
LocaleKkKZ = "kk_KZ" // Kazakh (Kazakhstan)
Expand Down Expand Up @@ -92,6 +96,10 @@ func ListLocales() []Locale {
LocaleCsCZ,
LocaleSlSI,
LocaleLtLT,
LocaleEtEE,
LocaleHrHR,
LocaleLvLV,
LocaleSkSK,
LocaleThTH,
LocaleUzUZ,
LocaleKkKZ,
Expand Down
Loading

0 comments on commit c82bce1

Please sign in to comment.