aboutsummaryrefslogtreecommitdiffstats
path: root/internal/web/handlers_pages.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web/handlers_pages.go')
-rw-r--r--internal/web/handlers_pages.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/internal/web/handlers_pages.go b/internal/web/handlers_pages.go
index 09257a3..fdd1bc8 100644
--- a/internal/web/handlers_pages.go
+++ b/internal/web/handlers_pages.go
@@ -69,11 +69,11 @@ func (s *Server) handlePageSave(w http.ResponseWriter, r *http.Request) {
var msg string
switch {
case err != nil:
- msg = "Image not added: " + err.Error()
+ msg = s.tr(r, "Image not added:") + " " + err.Error()
case p.Title == "" || len(p.Title) > 120:
- msg = "Title is required (max 120 characters)."
+ msg = s.tr(r, "Title is required (max 120 characters).")
case !slug.Valid(p.Slug) || reservedPageSlugs[p.Slug]:
- msg = "Slug may only contain lowercase letters, digits and dashes (and not be a reserved word)."
+ msg = s.tr(r, "Slug may only contain lowercase letters, digits and dashes (and not be a reserved word).")
}
if msg != "" {
s.renderStatus(w, r, http.StatusBadRequest, "dashboard/page_form.html", map[string]any{"page": p, "error": msg})
@@ -98,13 +98,13 @@ func (s *Server) handlePageSave(w http.ResponseWriter, r *http.Request) {
}
if err != nil {
if errors.Is(err, store.ErrConflict) {
- s.renderStatus(w, r, http.StatusConflict, "dashboard/page_form.html", map[string]any{"page": p, "error": "A page with that slug already exists."})
+ s.renderStatus(w, r, http.StatusConflict, "dashboard/page_form.html", map[string]any{"page": p, "error": s.tr(r, "A page with that slug already exists.")})
return
}
s.serverError(w, err)
return
}
- redirectOK(w, r, "/b/"+blog.Subdomain+"/pages/"+strconv.FormatInt(p.ID, 10)+"/edit", "Saved. Refresh your blog to see it.")
+ redirectOK(w, r, "/b/"+blog.Subdomain+"/pages/"+strconv.FormatInt(p.ID, 10)+"/edit", s.tr(r, "Saved. Refresh your blog to see it."))
}
func (s *Server) handlePageDeleteConfirm(w http.ResponseWriter, r *http.Request) {
@@ -113,7 +113,7 @@ func (s *Server) handlePageDeleteConfirm(w http.ResponseWriter, r *http.Request)
return
}
s.render(w, r, "dashboard/confirm.html", map[string]any{
- "what": "the page \"" + p.Title + "\" and all " + strconv.Itoa(p.PostCount) + " of its posts",
+ "what": s.trf(r, "the page ā€œ%sā€ and all %d of its posts", p.Title, p.PostCount),
"action": r.URL.Path,
"back": "/b/" + currentBlog(r).Subdomain + "/pages",
"isHome": p.IsHome,
@@ -126,14 +126,14 @@ func (s *Server) handlePageDelete(w http.ResponseWriter, r *http.Request) {
return
}
if p.IsHome {
- s.plainError(w, http.StatusBadRequest, "The home page cannot be deleted. Make another page the home page first.")
+ s.plainError(w, http.StatusBadRequest, s.tr(r, "The home page cannot be deleted. Make another page the home page first."))
return
}
if err := blogStore(r).DeletePage(r.Context(), p.ID); err != nil {
s.serverError(w, err)
return
}
- redirectOK(w, r, "/b/"+currentBlog(r).Subdomain+"/pages", "Page deleted.")
+ redirectOK(w, r, "/b/"+currentBlog(r).Subdomain+"/pages", s.tr(r, "Page deleted."))
}
func (s *Server) handlePageMove(w http.ResponseWriter, r *http.Request) {
@@ -161,5 +161,5 @@ func (s *Server) handlePageHome(w http.ResponseWriter, r *http.Request) {
s.serverError(w, err)
return
}
- redirectOK(w, r, "/b/"+currentBlog(r).Subdomain+"/pages", "\""+p.Title+"\" is now the home page.")
+ redirectOK(w, r, "/b/"+currentBlog(r).Subdomain+"/pages", s.trf(r, "ā€œ%sā€ is now the home page.", p.Title))
}