0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 07:50:43 -05:00

Fix ordering on locales.json file.

This commit is contained in:
Andrey Antukh 2021-02-22 14:45:00 +01:00
parent 60232baffb
commit 5e2bb3f546
2 changed files with 3049 additions and 3070 deletions

View file

@ -65,14 +65,12 @@
[path] [path]
(when (fs/regular-file? path) (when (fs/regular-file? path)
(let [content (json/read-value (io/as-file path))] (let [content (json/read-value (io/as-file path))]
(into (sorted-map) content)))) (reduce-kv (fn [res k v]
(let [v (into (sorted-map) v)
(defn- read-edn-file v (update v "translations" #(into (sorted-map) %))]
[path] (assoc res k v)))
(when (fs/regular-file? path) (sorted-map)
(let [content (edn/read-string (slurp (io/as-file path)))] content))))
(into (sorted-map) content))))
(defn- add-translation (defn- add-translation
[data {:keys [code file line] :as translation}] [data {:keys [code file line] :as translation}]
@ -84,7 +82,7 @@
(-> state (-> state
(dissoc "unused") (dissoc "unused")
(update "used-in" conj rpath))))) (update "used-in" conj rpath)))))
(assoc data code {"translations" {"en" nil "fr" nil "es" nil "ru" nil} (assoc data code {"translations" (sorted-map "en" nil "es" nil)
"used-in" [rpath]})))) "used-in" [rpath]}))))
(defn- clean-removed-translations (defn- clean-removed-translations
@ -112,10 +110,10 @@
(defn- synchronize-translations (defn- synchronize-translations
[data translations] [data translations]
(loop [data (initial-cleanup data) (loop [data (initial-cleanup data)
imported #{} imported #{}
c (first translations) c (first translations)
r (rest translations)] r (rest translations)]
(if (nil? c) (if (nil? c)
(clean-removed-translations data imported) (clean-removed-translations data imported)
(recur (add-translation data c) (recur (add-translation data c)

File diff suppressed because it is too large Load diff