From d8d5bc0573f8607861968e38eb4b177fc97a5c85 Mon Sep 17 00:00:00 2001 From: Azareal Date: Thu, 27 Sep 2018 20:53:40 +1000 Subject: [PATCH] Localised the not found error. --- common/errors.go | 2 +- common/phrases.go | 6 +++--- langs/english.json | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/errors.go b/common/errors.go index 4475860a..568383ca 100644 --- a/common/errors.go +++ b/common/errors.go @@ -281,7 +281,7 @@ func SecurityError(w http.ResponseWriter, r *http.Request, user User) RouteError // ? - Add a JSQ and JS version of this? // ? - Add a user parameter? func NotFound(w http.ResponseWriter, r *http.Request, header *Header) RouteError { - return CustomError("The requested page doesn't exist.", 404, "Not Found", w, r, header, GuestUser) + return CustomError(GetErrorPhrase("not_found"), 404, "Not Found", w, r, header, GuestUser) } // CustomError lets us make custom error types which aren't covered by the generic functions above diff --git a/common/phrases.go b/common/phrases.go index 1bba07a3..09a1dbe8 100644 --- a/common/phrases.go +++ b/common/phrases.go @@ -205,12 +205,12 @@ func GetHumanLangPhrase(name string) (string, bool) { } // TODO: Does comma ok work with multi-dimensional maps? -func GetErrorPhrase(name string) (string, bool) { +func GetErrorPhrase(name string) string { res, ok := currentLangPack.Load().(*LanguagePack).Errors[name] if !ok { - return getPhrasePlaceholder("error", name), false + return getPhrasePlaceholder("error", name) } - return res, true + return res } func GetNoticePhrase(name string) string { diff --git a/langs/english.json b/langs/english.json index 7452a9c1..85629b1e 100644 --- a/langs/english.json +++ b/langs/english.json @@ -70,6 +70,7 @@ }, "Errors": { + "not_found":"The requested page doesn't exist." }, "PageTitles": {