1
0
Fork 0
mirror of https://github.com/Luzifer/go-holidays.git synced 2024-12-26 05:41:18 +00:00

Allow to query localized name

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-12-27 05:04:34 +01:00
parent 3307a07901
commit c361e5ea47
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -65,6 +65,7 @@ func handleHolidays(res http.ResponseWriter, r *http.Request) {
var ( var (
countryCode = vars["country-code"] countryCode = vars["country-code"]
format = vars["format"] format = vars["format"]
locale = r.FormValue("locale")
year = time.Now().Year() year = time.Now().Year()
) )
@ -99,8 +100,13 @@ func handleHolidays(res http.ResponseWriter, r *http.Request) {
case "ics": case "ics":
cal := iCalendar{} cal := iCalendar{}
for _, h := range outputSet { for _, h := range outputSet {
name := h.Name
if h.LocalizedName != nil && h.LocalizedName[locale] != "" {
name = h.LocalizedName[locale]
}
cal.Events = append(cal.Events, iCalendarEvent{ cal.Events = append(cal.Events, iCalendarEvent{
Summary: h.Name, Summary: name,
Date: h.ParsedDate, Date: h.ParsedDate,
UID: fmt.Sprintf("%s_%s@hoiday-api.fyi", countryCode, h.ParsedDate.Format("20060102")), UID: fmt.Sprintf("%s_%s@hoiday-api.fyi", countryCode, h.ParsedDate.Format("20060102")),
}) })