Skip to content
Snippets Groups Projects
Unverified Commit 593d28f1 authored by Cam Saul's avatar Cam Saul
Browse files

Add i18n to api/email 'autocorrected' messages

parent 261c3b00
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
(:require [clojure
[data :as data]
[set :as set]
[string :as string]]
[string :as str]]
[clojure.tools.logging :as log]
[compojure.core :refer [DELETE POST PUT]]
[metabase
......@@ -11,9 +11,11 @@
[email :as email]]
[metabase.api.common :as api]
[metabase.models.setting :as setting]
[metabase.util.schema :as su]))
[metabase.util
[i18n :refer [tru]]
[schema :as su]]))
(def ^:private ^:const mb-to-smtp-settings
(def ^:private mb-to-smtp-settings
{:email-smtp-host :host
:email-smtp-username :user
:email-smtp-password :pass
......@@ -55,18 +57,18 @@
#".*"
{:message "Sorry, something went wrong. Please try again."}))))
(defn humanize-email-corrections
"formats warnings when security settings are autocorrected"
(defn- humanize-email-corrections
"Formats warnings when security settings are autocorrected."
[corrections]
(into {}
(mapv (fn [[k v]]
[k (format "%s was autocorrected to %s"
(name (mb-to-smtp-settings k))
(string/upper-case v))])
corrections)))
(into
{}
(for [[k v] corrections]
[k (tru "{0} was autocorrected to {1}"
(name (mb-to-smtp-settings k))
(str/upper-case v))])))
(api/defendpoint PUT "/"
"Update multiple `Settings` values. You must be a superuser to do this."
"Update multiple email Settings. You must be a superuser to do this."
[:as {settings :body}]
{settings su/Map}
(api/check-superuser)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment