Skip to content

Commit

Permalink
Merge pull request goodsign#46 from fbecart/master
Browse files Browse the repository at this point in the history
Add support for lt_LT: Lithuanian (Lithuania)
  • Loading branch information
goodsign authored Jan 11, 2021
2 parents 2489c8c + 31a90cd commit c2a8f41
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const (
LocaleFrGF = "fr_RE" // French (Reunion)
LocaleCsCZ = "cs_CZ" // Czech (Czech Republic)
LocaleSlSI = "sl_SI" // Slovenian (Slovenia)
LocaleLtLT = "lt_LT" // Lithuanian (Lithuania)
)
```

Expand Down
11 changes: 11 additions & 0 deletions default_formats.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ const (
DefaultFormatCsCZMedium = "02 Jan 2006"
DefaultFormatCsCZShort = "02/01/2006"
DefaultFormatCsCZDateTime = "02/01/2006 15:04"

DefaultFormatLtLTFull = "2006 m. January 2 d., Monday" // Lithuanian (Lithuania)
DefaultFormatLtLTLong = "2006 January 2 d."
DefaultFormatLtLTMedium = "2006 Jan 2"
DefaultFormatLtLTShort = "2006-01-02"
DefaultFormatLtLTDateTime = "2006-01-02, 15:04"
)

// FullFormatsByLocale maps locales to the'full' date formats for all
Expand Down Expand Up @@ -254,6 +260,7 @@ var FullFormatsByLocale = map[Locale]string{
LocaleElGR: DefaultFormatElGRFull,
LocaleCsCZ: DefaultFormatCsCZFull,
LocaleUkUA: DefaultFormatUkUAFull,
LocaleLtLT: DefaultFormatLtLTFull,
}

// LongFormatsByLocale maps locales to the 'long' date formats for all
Expand Down Expand Up @@ -294,6 +301,7 @@ var LongFormatsByLocale = map[Locale]string{
LocaleElGR: DefaultFormatElGRLong,
LocaleCsCZ: DefaultFormatCsCZLong,
LocaleUkUA: DefaultFormatUkUALong,
LocaleLtLT: DefaultFormatLtLTLong,
}

// MediumFormatsByLocale maps locales to the 'medium' date formats for all
Expand Down Expand Up @@ -334,6 +342,7 @@ var MediumFormatsByLocale = map[Locale]string{
LocaleElGR: DefaultFormatElGRMedium,
LocaleCsCZ: DefaultFormatCsCZMedium,
LocaleUkUA: DefaultFormatUkUAMedium,
LocaleLtLT: DefaultFormatLtLTMedium,
}

// ShortFormatsByLocale maps locales to the 'short' date formats for all
Expand Down Expand Up @@ -374,6 +383,7 @@ var ShortFormatsByLocale = map[Locale]string{
LocaleElGR: DefaultFormatElGRShort,
LocaleCsCZ: DefaultFormatCsCZShort,
LocaleUkUA: DefaultFormatUkUAShort,
LocaleLtLT: DefaultFormatLtLTShort,
}

// DateTimeFormatsByLocale maps locales to the 'DateTime' date formats for
Expand Down Expand Up @@ -414,4 +424,5 @@ var DateTimeFormatsByLocale = map[Locale]string{
LocaleElGR: DefaultFormatElGRDateTime,
LocaleCsCZ: DefaultFormatCsCZDateTime,
LocaleUkUA: DefaultFormatUkUADateTime,
LocaleLtLT: DefaultFormatLtLTDateTime,
}
85 changes: 85 additions & 0 deletions format_lt_lt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package monday

// ============================================================
// Format rules for "lt_LT" locale: Lithuanian (Lithuania)
// ============================================================

var longDayNamesLtLT = map[string]string{
"Sunday": "sekmadienis",
"Monday": "pirmadienis",
"Tuesday": "antradienis",
"Wednesday": "trečiadienis",
"Thursday": "ketvirtadienis",
"Friday": "penktadienis",
"Saturday": "šeštadienis",
}

var shortDayNamesLtLT = map[string]string{
"Sun": "VII",
"Mon": "I",
"Tue": "II",
"Wed": "III",
"Thu": "IV",
"Fri": "V",
"Sat": "VI",
}

var longMonthNamesLtLT = map[string]string{
"January": "sausis",
"February": "vasaris",
"March": "kovas",
"April": "balandis",
"May": "gegužė",
"June": "birželis",
"July": "liepa",
"August": "rugpjūtis",
"September": "rugsėjis",
"October": "spalis",
"November": "lapkritis",
"December": "gruodis",
}

var longMonthNamesGenitiveLtLT = map[string]string{
"January": "sausio",
"February": "vasario",
"March": "kovo",
"April": "balandžio",
"May": "gegužės",
"June": "birželio",
"July": "liepos",
"August": "rugpjūčio",
"September": "rugsėjio",
"October": "spalio",
"November": "lapkričio",
"December": "gruodžio",
}

var shortMonthNamesLtLT = map[string]string{
"Jan": "sausis",
"Feb": "vas",
"Mar": "kovas",
"Apr": "bal",
"May": "geg",
"Jun": "birž",
"Jul": "liepa",
"Aug": "rugpj",
"Sep": "rugs",
"Oct": "spalis",
"Nov": "lapkr",
"Dec": "gruodis",
}

var shortMonthNamesGenitiveLtLT = map[string]string{
"Jan": "sausio",
"Feb": "vas",
"Mar": "kovo",
"Apr": "bal",
"May": "geg",
"Jun": "birž",
"Jul": "liepos",
"Aug": "rugpj",
"Sep": "rugs",
"Oct": "spalio",
"Nov": "lapkr",
"Dec": "gruodžio",
}
2 changes: 2 additions & 0 deletions locale.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
LocaleFrGF = "fr_GF" // French (French Guiana)
LocaleCsCZ = "cs_CZ" // Czech (Czech Republic)
LocaleSlSI = "sl_SI" // Slovenian (Slovenia)
LocaleLtLT = "lt_LT" // Lithuanian (Lithuania)
)

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

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

var knownDaysShort = map[Locale]map[string]string{} // Mapping for 'Format', days of week, short form
Expand Down Expand Up @@ -355,6 +357,14 @@ func fillKnownWords() {
fillKnownDaysShort(shortDayNamesSlSI, LocaleSlSI)
fillKnownMonthsLong(longMonthNamesSlSI, LocaleSlSI)
fillKnownMonthsShort(shortMonthNamesSlSI, LocaleSlSI)

// Lt_LT: Lithuanian (Lithuania)
fillKnownDaysLong(longDayNamesLtLT, LocaleLtLT)
fillKnownDaysShort(shortDayNamesLtLT, LocaleLtLT)
fillKnownMonthsLong(longMonthNamesLtLT, LocaleLtLT)
fillKnownMonthsShort(shortMonthNamesLtLT, LocaleLtLT)
fillKnownMonthsGenitiveLong(longMonthNamesGenitiveLtLT, LocaleLtLT)
fillKnownMonthsGenitiveShort(shortMonthNamesGenitiveLtLT, LocaleLtLT)
}

func fill(src map[string]string, dest map[Locale]map[string]string, locale Locale) {
Expand Down

0 comments on commit c2a8f41

Please sign in to comment.