mirror of
https://github.com/Luzifer/go-holidays.git
synced 2024-12-26 13:51:18 +00:00
Allow to query localized name
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
3307a07901
commit
c361e5ea47
1 changed files with 7 additions and 1 deletions
|
@ -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")),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue