Add support for default i18n for items

This commit is contained in:
2024-04-13 16:22:15 +02:00
parent ffab35d8fb
commit 2b28ab568a
2 changed files with 6 additions and 3 deletions

View File

@@ -9,8 +9,11 @@
(str "### " (get i18n category))) (str "### " (get i18n category)))
(defn produce-item [item nights i18n] (defn produce-item [item nights i18n]
(let [qnt (int (Math/ceil ((:quantity item) nights)))] (let [quantity (if (= (type (:quantity item)) java.lang.Long) (:quantity item) ((:quantity item) nights))
(str "- [ ] " (get i18n (:key item)) (if (> qnt 1) (str " x" qnt) "")))) quantity-long (long (Math/ceil quantity))
quantity-string (if (> quantity-long 1) (str " x" quantity-long) "")
name (or (get i18n (:key item)) (:name item))]
(str "- [ ] " name quantity-string)))
(defn produce-items [items nights i18n] (defn produce-items [items nights i18n]
(->> items (->> items

View File

@@ -1,5 +1,5 @@
(ns packer.model (:gen-class)) (ns packer.model (:gen-class))
(defrecord Item [key quantity]) (defrecord Item [key name quantity])
(defrecord Template [store i18n profile]) (defrecord Template [store i18n profile])