From 435637e1a4e01c6950bf185e4c01503430462143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Tue, 10 Mar 2026 16:59:31 +0800 Subject: [PATCH] Added schedules empty message for kmb --- datasources/kmb/QueryResult.go | 10 +++++++++- i18n/messages.go | 1 + resources/langpacks/zh-Hant/messages.json | 3 ++- resources/po/zh-Hant/messages.po | 10 ++++++++-- resources/pot/messages.pot | 8 +++++++- resources/src/messages.json | 1 + 6 files changed, 28 insertions(+), 5 deletions(-) diff --git a/datasources/kmb/QueryResult.go b/datasources/kmb/QueryResult.go index 95190f3..486dd2e 100644 --- a/datasources/kmb/QueryResult.go +++ b/datasources/kmb/QueryResult.go @@ -174,6 +174,8 @@ func (this *QueryResult) Message() (string, error) { sb.WriteString("\n") writeShortRoute(&this.Lang, &sb, r) + noSchedules := true + for _, schedule := range *(*this.Schedules)[r] { if !schedule.ETA.IsZero() { @@ -189,6 +191,8 @@ func (this *QueryResult) Message() (string, error) { } else { utils.WriteMDv2Text(&sb, eta) } + + noSchedules = false } if schedule.Remarks_en != "" { @@ -204,6 +208,10 @@ func (this *QueryResult) Message() (string, error) { sb.WriteString("\n") } + if noSchedules { + utils.WriteMDv2Text(&sb, i18n.DS_KMB_NO_SCHEDULES.Text(langPack)) + } + sb.WriteString("\n") } @@ -241,7 +249,7 @@ func (this *QueryResult) Message() (string, error) { } } } else { - return "", fmt.Errorf("No Results") + return "", fmt.Errorf(i18n.NO_RESULTS.Text(langPack)) } return sb.String(), nil diff --git a/i18n/messages.go b/i18n/messages.go index 326422c..3f42809 100644 --- a/i18n/messages.go +++ b/i18n/messages.go @@ -4,6 +4,7 @@ const ( DS_KMB_ETA_DEPARTED Key = "DS.KMB.ETA.DEPARTED" DS_KMB_NEAREST_STOPS Key = "DS.KMB.NEAREST_STOPS" DS_KMB_NO_NEAREST_STOPS Key = "DS.KMB.NO_NEAREST_STOPS" + DS_KMB_NO_SCHEDULES Key = "DS.KMB.NO_SCHEDULES" DS_MTR_NEAREST_STOPS Key = "DS.MTR.NEAREST_STOPS" DS_MTR_NO_NEAREST_STOPS Key = "DS.MTR.NO_NEAREST_STOPS" DS_MTR_NO_SCHEDULES Key = "DS.MTR.NO_SCHEDULES" diff --git a/resources/langpacks/zh-Hant/messages.json b/resources/langpacks/zh-Hant/messages.json index a8ec95a..aacfa2a 100644 --- a/resources/langpacks/zh-Hant/messages.json +++ b/resources/langpacks/zh-Hant/messages.json @@ -2,9 +2,10 @@ "DS.KMB.ETA.DEPARTED": "%s (走左了?)", "DS.KMB.NEAREST_STOPS": "%s 範圍內九巴站", "DS.KMB.NO_NEAREST_STOPS": "%s 範圍內找不到九巴站,最近 %d 個站為:", + "DS.KMB.NO_SCHEDULES": "沒有行程(收左工了?全日得一班?)", "DS.MTR.NEAREST_STOPS": "%s 範圍內港鐵巴士車站", "DS.MTR.NO_NEAREST_STOPS": "%s 範圍內找不到港鐵巴士站,最近 %d 個站為:", - "DS.MTR.NO_SCHEDULES": "沒有行程(收左工了?)", + "DS.MTR.NO_SCHEDULES": "沒有行程(收左工了?全日得一班?)", "NO_RESULTS": "找不到結果", "UNITS.KM": "%.1f 公里", "UNITS.METER": "%.0f 米", diff --git a/resources/po/zh-Hant/messages.po b/resources/po/zh-Hant/messages.po index a70e79d..743b3a8 100644 --- a/resources/po/zh-Hant/messages.po +++ b/resources/po/zh-Hant/messages.po @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-10 15:23+0800\n" +"POT-Creation-Date: 2026-03-10 16:50+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -25,6 +25,11 @@ msgid "" "KMB: Unable to find stations under %s. Listing nearest %d stations instead:" msgstr "%s 範圍內找不到九巴站,最近 %d 個站為:" +#: .DS.KMB.NO_SCHEDULES +msgctxt ".DS.KMB.NO_SCHEDULES" +msgid "Schedules are empty...perhaps Out of Service Time?" +msgstr "沒有行程(收左工了?全日得一班?)" + #: .DS.MTR.NEAREST_STOPS msgid "MTR: Showing nearest bus stops under %s" msgstr "%s 範圍內港鐵巴士車站" @@ -36,8 +41,9 @@ msgid "" msgstr "%s 範圍內找不到港鐵巴士站,最近 %d 個站為:" #: .DS.MTR.NO_SCHEDULES +msgctxt ".DS.MTR.NO_SCHEDULES" msgid "Schedules are empty...perhaps Out of Service Time?" -msgstr "沒有行程(收左工了?)" +msgstr "沒有行程(收左工了?全日得一班?)" #: .NO_RESULTS msgid "No Results" diff --git a/resources/pot/messages.pot b/resources/pot/messages.pot index 64f12c8..8acf082 100644 --- a/resources/pot/messages.pot +++ b/resources/pot/messages.pot @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-10 15:23+0800\n" +"POT-Creation-Date: 2026-03-10 16:50+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -26,6 +26,11 @@ msgid "" "KMB: Unable to find stations under %s. Listing nearest %d stations instead:" msgstr "" +#: .DS.KMB.NO_SCHEDULES +msgctxt ".DS.KMB.NO_SCHEDULES" +msgid "Schedules are empty...perhaps Out of Service Time?" +msgstr "" + #: .DS.MTR.NEAREST_STOPS msgid "MTR: Showing nearest bus stops under %s" msgstr "" @@ -37,6 +42,7 @@ msgid "" msgstr "" #: .DS.MTR.NO_SCHEDULES +msgctxt ".DS.MTR.NO_SCHEDULES" msgid "Schedules are empty...perhaps Out of Service Time?" msgstr "" diff --git a/resources/src/messages.json b/resources/src/messages.json index cd9cd94..2b80ed1 100644 --- a/resources/src/messages.json +++ b/resources/src/messages.json @@ -2,6 +2,7 @@ "DS.KMB.ETA.DEPARTED": "%s (Leaved?)", "DS.KMB.NEAREST_STOPS": "KMB: Showing nearest bus stops under %s", "DS.KMB.NO_NEAREST_STOPS": "KMB: Unable to find stations under %s. Listing nearest %d stations instead:", + "DS.KMB.NO_SCHEDULES": "Schedules are empty...perhaps Out of Service Time?", "DS.MTR.NEAREST_STOPS": "MTR: Showing nearest bus stops under %s", "DS.MTR.NO_NEAREST_STOPS": "MTR Bus: Unable to find stations under %s. Listing nearest %d stations instead:", "DS.MTR.NO_SCHEDULES": "Schedules are empty...perhaps Out of Service Time?",