diff --git a/src/metabase/analytics/snowplow.clj b/src/metabase/analytics/snowplow.clj index 06ac051dfc5cfa10d5b2f0e2b045a80e71391060..0dd066997cbaeffae33a334d216a3a2b29e337de 100644 --- a/src/metabase/analytics/snowplow.clj +++ b/src/metabase/analytics/snowplow.clj @@ -20,25 +20,25 @@ org.apache.http.impl.conn.PoolingHttpClientConnectionManager)) (defsetting analytics-uuid - (str (deferred-tru "Unique identifier to be used in Snowplow analytics, to identify this instance of Metabase.") - " " - (deferred-tru "This is a public setting since some analytics events are sent prior to initial setup.")) + (deferred-tru + (str "Unique identifier to be used in Snowplow analytics, to identify this instance of Metabase. " + "This is a public setting since some analytics events are sent prior to initial setup.")) :visibility :public :setter :none :type ::public-settings/uuid-nonce) (defsetting snowplow-available - (str (deferred-tru "Boolean indicating whether a Snowplow collector is available to receive analytics events.") - " " - (deferred-tru "Should be set via environment variable in Cypress tests or during local development.")) + (deferred-tru + (str "Boolean indicating whether a Snowplow collector is available to receive analytics events. " + "Should be set via environment variable in Cypress tests or during local development.")) :type :boolean :visibility :public :default config/is-prod?) (defsetting snowplow-enabled - (str (deferred-tru "Boolean indicating whether analytics events are being sent to Snowplow.") - " " - (deferred-tru "True if anonymous tracking is enabled for this instance, and a Snowplow collector is available.")) + (deferred-tru + (str "Boolean indicating whether analytics events are being sent to Snowplow. " + "True if anonymous tracking is enabled for this instance, and a Snowplow collector is available.")) :type :boolean :setter :none :getter (fn [] (and (snowplow-available) diff --git a/src/metabase/driver/common.clj b/src/metabase/driver/common.clj index bd70a52c702a694136629e39f020ca018b4d735f..e415760063dba8ea4fcd57d6fcb0683321d2af8a 100644 --- a/src/metabase/driver/common.clj +++ b/src/metabase/driver/common.clj @@ -132,9 +132,9 @@ :type :boolean :default true :display-name (deferred-tru "Rerun queries for simple explorations") - :description (str (deferred-tru "We execute the underlying query when you explore data using Summarize or Filter.") - " " - (deferred-tru "This is on by default but you can turn it off if performance is slow.")) + :description (deferred-tru + (str "We execute the underlying query when you explore data using Summarize or Filter. " + "This is on by default but you can turn it off if performance is slow.")) :visible-if {"advanced-options" true}}) (def let-user-control-scheduling @@ -150,9 +150,9 @@ `let-user-control-scheduling` is enabled." {:name "schedules.metadata_sync" :display-name (deferred-tru "Database syncing") - :description (str (deferred-tru "This is a lightweight process that checks for updates to this database’s schema.") - " " - (deferred-tru "In most cases, you should be fine leaving this set to sync hourly.")) + :description (deferred-tru + (str "This is a lightweight process that checks for updates to this database’s schema. " + "In most cases, you should be fine leaving this set to sync hourly.")) :visible-if {"let-user-control-scheduling" true}}) (def cache-field-values-schedule @@ -160,9 +160,11 @@ `let-user-control-scheduling` is enabled." {:name "schedules.cache_field_values" :display-name (deferred-tru "Scanning for Filter Values") - :description (str (deferred-tru "Metabase can scan the values present in each field in this database to enable checkbox filters in dashboards and questions. This can be a somewhat resource-intensive process, particularly if you have a very large database.") - " " - (deferred-tru "When should Metabase automatically scan and cache field values?")) + :description (deferred-tru + (str "Metabase can scan the values present in each field in this database to enable checkbox " + "filters in dashboards and questions. This can be a somewhat resource-intensive process, " + "particularly if you have a very large database. When should Metabase automatically scan " + "and cache field values?")) :visible-if {"let-user-control-scheduling" true}}) (def refingerprint @@ -170,7 +172,9 @@ {:name "refingerprint" :type :boolean :display-name (deferred-tru "Periodically refingerprint tables") - :description (deferred-tru "This enables Metabase to scan for additional field values during syncs allowing smarter behavior, like improved auto-binning on your bar charts.") + :description (deferred-tru + (str "This enables Metabase to scan for additional field values during syncs allowing smarter " + "behavior, like improved auto-binning on your bar charts.")) :visible-if {"advanced-options" true}}) (def default-advanced-options @@ -205,7 +209,9 @@ :type :info :getter (fn [] (when-let [ips (public-settings/cloud-gateway-ips)] - (str (deferred-tru "If your database is behind a firewall, you may need to allow connections from our Metabase Cloud IP addresses:") + (str (deferred-tru + (str "If your database is behind a firewall, you may need to allow connections from our Metabase " + "Cloud IP addresses:")) "\n" (str/join " - " ips))))}) diff --git a/src/metabase/driver/common/parameters/values.clj b/src/metabase/driver/common/parameters/values.clj index 633a18480325bcafbb87f5a5f98961a8b6658eb9..fc5d696c65e66b54914ba8da947bb12e05bfc0dc 100644 --- a/src/metabase/driver/common/parameters/values.clj +++ b/src/metabase/driver/common/parameters/values.clj @@ -18,7 +18,7 @@ [metabase.query-processor.error-type :as qp.error-type] [metabase.query-processor.store :as qp.store] [metabase.util :as u] - [metabase.util.i18n :refer [deferred-tru tru]] + [metabase.util.i18n :refer [tru]] [metabase.util.schema :as su] [schema.core :as s] [toucan.db :as db]) @@ -130,7 +130,7 @@ {:field (let [field-id (field-filter->field-id field-filter)] (qp.store/fetch-and-store-fields! #{field-id}) (or (qp.store/field field-id) - (throw (ex-info (str (deferred-tru "Can''t find field with ID: {0}" field-id)) + (throw (ex-info (tru "Can''t find field with ID: {0}" field-id) {:field-id field-id, :type qp.error-type/invalid-parameter})))) :value (field-filter-value tag params)})) diff --git a/src/metabase/integrations/google.clj b/src/metabase/integrations/google.clj index 148418592daf2c7d949587aee5f9117daa4d65a6..13d7a246ec87935f28f5c86800c5ec3b317687c8 100644 --- a/src/metabase/integrations/google.clj +++ b/src/metabase/integrations/google.clj @@ -53,8 +53,9 @@ (let [audience (:aud <>) audience (if (string? audience) [audience] audience)] (when-not (contains? (set audience) client-id) - (throw (ex-info (str (deferred-tru "Google Sign-In token appears to be incorrect. ") - (deferred-tru "Double check that it matches in Google and Metabase.")) + (throw (ex-info (tru + (str "Google Sign-In token appears to be incorrect. " + "Double check that it matches in Google and Metabase.")) {:status-code 400})))) (when-not (= (:email_verified <>) "true") (throw (ex-info (tru "Email is not verified.") {:status-code 400}))))))) diff --git a/src/metabase/integrations/slack.clj b/src/metabase/integrations/slack.clj index 610a43af97829e884e138fd4a7980f61378d24a5..57da89b21bc424f75cf267ff90409f00805d1d3f 100644 --- a/src/metabase/integrations/slack.clj +++ b/src/metabase/integrations/slack.clj @@ -15,20 +15,20 @@ [schema.core :as s])) (defsetting slack-token - (str (deferred-tru "Deprecated Slack API token for connecting the Metabase Slack bot.") - " " - (deferred-tru "Please use a new Slack app integration instead.")) + (deferred-tru + (str "Deprecated Slack API token for connecting the Metabase Slack bot. " + "Please use a new Slack app integration instead.")) :deprecated "0.42.0") (defsetting slack-app-token - (str (deferred-tru "Bot user OAuth token for connecting the Metabase Slack app.") - " " - (deferred-tru "This should be used for all new Slack integrations starting in Metabase v0.42.0."))) + (deferred-tru + (str "Bot user OAuth token for connecting the Metabase Slack app. " + "This should be used for all new Slack integrations starting in Metabase v0.42.0."))) (defsetting slack-token-valid? - (str (deferred-tru "Whether the current Slack app token, if set, is valid.") - " " - (deferred-tru "Set to 'false' if a Slack API request returns an auth error.")) + (deferred-tru + (str "Whether the current Slack app token, if set, is valid. " + "Set to 'false' if a Slack API request returns an auth error.")) :type :boolean) (defn process-files-channel-name diff --git a/src/metabase/models/humanization.clj b/src/metabase/models/humanization.clj index 7f62b0cbba173a2d925fe12e6b0389bd49e30f42..443ede00c27fa8642f74d80cf18ca6f956dd6aff 100644 --- a/src/metabase/models/humanization.clj +++ b/src/metabase/models/humanization.clj @@ -104,9 +104,9 @@ (re-humanize-table-and-field-names! old-strategy)))) (defsetting ^{:added "0.28.0"} humanization-strategy - (str (deferred-tru "To make table and field names more human-friendly, Metabase will replace dashes and underscores in them with spaces.") - " " - (deferred-tru "We’ll capitalize each word while at it, so ‘last_visited_at’ will become ‘Last Visited At’.")) + (deferred-tru + (str "To make table and field names more human-friendly, Metabase will replace dashes and underscores in them " + "with spaces. We’ll capitalize each word while at it, so ‘last_visited_at’ will become ‘Last Visited At’.")) :type :keyword :default :simple :setter set-humanization-strategy!) diff --git a/src/metabase/models/permissions.clj b/src/metabase/models/permissions.clj index 99ff798f9f5f7c4f34d5559a95914c2465a668e5..8ef51eed639e140081597af59a295239399ec42c 100644 --- a/src/metabase/models/permissions.clj +++ b/src/metabase/models/permissions.clj @@ -185,7 +185,7 @@ [metabase.public-settings.premium-features :as premium-features :refer [defenterprise]] [metabase.util :as u] [metabase.util.honeysql-extensions :as hx] - [metabase.util.i18n :refer [deferred-tru trs tru]] + [metabase.util.i18n :refer [trs tru]] [metabase.util.regex :as u.regex] [metabase.util.schema :as su] [schema.core :as s] @@ -614,8 +614,7 @@ (:object permissions)))))) (defn- pre-update [_] - (throw (Exception. (str (deferred-tru "You cannot update a permissions entry!") - (deferred-tru "Delete it and create a new one."))))) + (throw (Exception. (tru "You cannot update a permissions entry! Delete it and create a new one.")))) (defn- pre-delete [permissions] (log/debug (u/colorize 'red (trs "Revoking permissions for group {0}: {1}" @@ -1164,10 +1163,10 @@ made in the interim. Return a 409 (Conflict) if the numbers don't match up." [old-graph new-graph] (when (not= (:revision old-graph) (:revision new-graph)) - (throw (ex-info (str (deferred-tru "Looks like someone else edited the permissions and your data is out of date.") - " " - (deferred-tru "Please fetch new data and try again.")) - {:status-code 409})))) + (throw (ex-info (tru + (str "Looks like someone else edited the permissions and your data is out of date. " + "Please fetch new data and try again.")) + {:status-code 409})))) (defn save-perms-revision! "Save changes made to permission graph for logging/auditing purposes. diff --git a/src/metabase/models/setting.clj b/src/metabase/models/setting.clj index b0d19c53736c231f2006351321872c3016a69ed6..6f7b0fdcbe9e2120196be6f2d5e1a89184a7ac06 100644 --- a/src/metabase/models/setting.clj +++ b/src/metabase/models/setting.clj @@ -839,21 +839,11 @@ (defn- valid-trs-or-tru? [desc] (is-form? allowed-deferred-i18n-forms desc)) -(defn- valid-str-of-trs-or-tru? [maybe-str-expr] - (when (is-form? #{`str} maybe-str-expr) - ;; When there are several i18n'd sentences, there will probably be a surrounding `str` invocation and a space in - ;; between the sentences, remove those to validate the i18n clauses - (let [exprs-without-strs (remove (every-pred string? str/blank?) (rest maybe-str-expr))] - ;; We should have at lease 1 i18n clause, so ensure `exprs-without-strs` is not empty - (and (seq exprs-without-strs) - (every? valid-trs-or-tru? exprs-without-strs))))) - (defn- validate-description-form - "Check that `description-form` is a i18n form (e.g. [[metabase.util.i18n/deferred-tru]]), or a [[str]] form consisting - of one or more deferred i18n forms. Returns `description-form` as-is." + "Check that `description-form` is a i18n form (e.g. [[metabase.util.i18n/deferred-tru]]). Returns `description-form` + as-is." [description-form] - (when-not (or (valid-trs-or-tru? description-form) - (valid-str-of-trs-or-tru? description-form)) + (when-not (valid-trs-or-tru? description-form) ;; this doesn't need to be i18n'ed because it's a compile-time error. (throw (ex-info (str "defsetting docstrings must be an *deferred* i18n form unless the Setting has" " `:visibilty` `:internal` or `:setter` `:none`." diff --git a/src/metabase/public_settings.clj b/src/metabase/public_settings.clj index d68817b9f3c47f7ce396b4ce6d98ac20593fe785..834d1e5aa2a0185dd4bfc6a64fcde004a2e40c46 100644 --- a/src/metabase/public_settings.clj +++ b/src/metabase/public_settings.clj @@ -485,12 +485,10 @@ (setting/set-value-of-type! :boolean :redirect-all-requests-to-https new-value))) (defsetting start-of-week - (str - (deferred-tru "This will affect things like grouping by week or filtering in GUI queries.") - " " - (deferred-tru "It won''t affect most SQL queries,") - " " - (deferred-tru " although it is used to set the WEEK_START session variable in Snowflake.")) + (deferred-tru + (str "This will affect things like grouping by week or filtering in GUI queries. " + "It won''t affect most SQL queries, " + "although it is used to set the WEEK_START session variable in Snowflake.")) :visibility :public :type :keyword :default :sunday) diff --git a/src/metabase/server/middleware/security.clj b/src/metabase/server/middleware/security.clj index 5336c9d5022ca9e543d35ed4f4e8a8ad9742bc91..188b796344e9abd6c5253f76d85640053d8c9ed7 100644 --- a/src/metabase/server/middleware/security.clj +++ b/src/metabase/server/middleware/security.clj @@ -103,9 +103,11 @@ #(format "%s frame-ancestors %s;" % (if allow-iframes? "*" (or (embedding-app-origin) "'none'"))))) (defsetting ssl-certificate-public-key - (str (deferred-tru "Base-64 encoded public key for this site's SSL certificate.") - (deferred-tru "Specify this to enable HTTP Public Key Pinning.") - (deferred-tru "See {0} for more information." "http://mzl.la/1EnfqBf"))) + (deferred-tru + (str "Base-64 encoded public key for this site''s SSL certificate. " + "Specify this to enable HTTP Public Key Pinning. " + "See {0} for more information.") + "http://mzl.la/1EnfqBf")) ;; TODO - it would be nice if we could make this a proper link in the UI; consider enabling markdown parsing (defn- first-embedding-app-origin diff --git a/src/metabase/util/schema.clj b/src/metabase/util/schema.clj index 6ad80d196abbd1f89f3ef9baabff279cf0fd66ee..1a3dee65ac93ee903c4c99b45090729763e5fca5 100644 --- a/src/metabase/util/schema.clj +++ b/src/metabase/util/schema.clj @@ -115,9 +115,10 @@ ;; do the same for sequences of a schema (when (vector? schema) - (str (deferred-tru "value must be an array.") (when (= (count schema) 1) - (when-let [message (api-error-message (first schema))] - (str " " (deferred-tru "Each {0}" message)))))))) + (str (deferred-tru "value must be an array.") + (when (= (count schema) 1) + (when-let [message (api-error-message (first schema))] + (str " " (deferred-tru "Each {0}" message)))))))) (defn non-empty