0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 23:18:48 -05:00

Remove line numbers from locales.json

This will help to avoid unnecesary conflicts.
This commit is contained in:
Andrey Antukh 2021-02-16 20:04:32 +01:00 committed by Andrés Moya
parent dc69d0c7f4
commit abb8d8502b
4 changed files with 602 additions and 801 deletions

View file

@ -14,7 +14,7 @@
[app.main :as main]
[app.util.time :as dt]
[app.util.transit :as t]
[clojure.data.json :as json]
[app.util.json :as json]
[clojure.java.io :as io]
[clojure.pprint :refer [pprint]]
[clojure.repl :refer :all]

View file

@ -12,7 +12,9 @@
'java.nio.file.Path
'java.nio.file.Files
'java.nio.file.SimpleFileVisitor
'java.nio.file.FileVisitResult)
'java.nio.file.FileVisitResult
'com.fasterxml.jackson.databind.ObjectMapper
'com.fasterxml.jackson.databind.SerializationFeature)
(defmulti task first)
@ -62,7 +64,7 @@
(defn- read-json-file
[path]
(when (fs/regular-file? path)
(let [content (json/read-value (slurp (io/as-file path)))]
(let [content (json/read-value (io/as-file path))]
(into (sorted-map) content))))
(defn- read-edn-file
@ -74,7 +76,7 @@
(defn- add-translation
[data {:keys [code file line] :as translation}]
(let [rpath (str file ":" line)]
(let [rpath (str file)]
(if (contains? data code)
(update data code (fn [state]
(if (get state "permanent")
@ -121,29 +123,20 @@
(first r)
(rest r)))))
(defn- synchronize-legacy-translations
[data legacy-data lang]
(reduce-kv (fn [data k v]
(if (contains? data k)
(update-in data [k "translations"] assoc lang v)
data))
data
legacy-data))
(defn- write-result!
[data output-path]
(binding [*out* (io/writer (fs/path output-path))]
(let [mapper (json/object-mapper {:pretty true})]
(let [mapper (doto (ObjectMapper.)
(.enable SerializationFeature/ORDER_MAP_ENTRIES_BY_KEYS))
mapper (json/object-mapper {:pretty true :mapper mapper})]
(println (json/write-value-as-string data mapper))
(flush))))
(defn- update-translations
[{:keys [find-directory output-path] :as props}]
(let [
data (read-json-file output-path)
(let [data (read-json-file output-path)
translations (collect-translations find-directory)
data (synchronize-translations data translations)
]
data (synchronize-translations data translations)]
(write-result! data output-path)))
(defmethod task "collect"
@ -151,12 +144,4 @@
(update-translations {:find-directory in-path
:output-path out-path}))
(defmethod task "merge-with-legacy"
[[_ path lang legacy-path]]
(let [ldata (read-edn-file legacy-path)
data (read-json-file path)
data (synchronize-legacy-translations data ldata lang)]
(write-result! data path)))
(task *command-line-args*)

View file

@ -12,7 +12,7 @@
"defaults"
],
"scripts": {
"collect-locales": "clojure -Adev locales.clj collect src/app/main/ resources/locales.json"
"collect-locales": "clojure -M:dev locales.clj collect src/app/main/ resources/locales.json"
},
"devDependencies": {
"autoprefixer": "^10.1.0",

File diff suppressed because it is too large Load diff