mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
✨ Remove line numbers from locales.json
This will help to avoid unnecesary conflicts.
This commit is contained in:
committed by
Andrés Moya
parent
dc69d0c7f4
commit
abb8d8502b
@@ -14,7 +14,7 @@
|
|||||||
[app.main :as main]
|
[app.main :as main]
|
||||||
[app.util.time :as dt]
|
[app.util.time :as dt]
|
||||||
[app.util.transit :as t]
|
[app.util.transit :as t]
|
||||||
[clojure.data.json :as json]
|
[app.util.json :as json]
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[clojure.pprint :refer [pprint]]
|
[clojure.pprint :refer [pprint]]
|
||||||
[clojure.repl :refer :all]
|
[clojure.repl :refer :all]
|
||||||
|
|||||||
@@ -12,7 +12,9 @@
|
|||||||
'java.nio.file.Path
|
'java.nio.file.Path
|
||||||
'java.nio.file.Files
|
'java.nio.file.Files
|
||||||
'java.nio.file.SimpleFileVisitor
|
'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)
|
(defmulti task first)
|
||||||
|
|
||||||
@@ -62,7 +64,7 @@
|
|||||||
(defn- read-json-file
|
(defn- read-json-file
|
||||||
[path]
|
[path]
|
||||||
(when (fs/regular-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))))
|
(into (sorted-map) content))))
|
||||||
|
|
||||||
(defn- read-edn-file
|
(defn- read-edn-file
|
||||||
@@ -74,7 +76,7 @@
|
|||||||
|
|
||||||
(defn- add-translation
|
(defn- add-translation
|
||||||
[data {:keys [code file line] :as translation}]
|
[data {:keys [code file line] :as translation}]
|
||||||
(let [rpath (str file ":" line)]
|
(let [rpath (str file)]
|
||||||
(if (contains? data code)
|
(if (contains? data code)
|
||||||
(update data code (fn [state]
|
(update data code (fn [state]
|
||||||
(if (get state "permanent")
|
(if (get state "permanent")
|
||||||
@@ -121,29 +123,20 @@
|
|||||||
(first r)
|
(first r)
|
||||||
(rest 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!
|
(defn- write-result!
|
||||||
[data output-path]
|
[data output-path]
|
||||||
(binding [*out* (io/writer (fs/path 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))
|
(println (json/write-value-as-string data mapper))
|
||||||
(flush))))
|
(flush))))
|
||||||
|
|
||||||
(defn- update-translations
|
(defn- update-translations
|
||||||
[{:keys [find-directory output-path] :as props}]
|
[{:keys [find-directory output-path] :as props}]
|
||||||
(let [
|
(let [data (read-json-file output-path)
|
||||||
data (read-json-file output-path)
|
|
||||||
translations (collect-translations find-directory)
|
translations (collect-translations find-directory)
|
||||||
data (synchronize-translations data translations)
|
data (synchronize-translations data translations)]
|
||||||
]
|
|
||||||
(write-result! data output-path)))
|
(write-result! data output-path)))
|
||||||
|
|
||||||
(defmethod task "collect"
|
(defmethod task "collect"
|
||||||
@@ -151,12 +144,4 @@
|
|||||||
(update-translations {:find-directory in-path
|
(update-translations {:find-directory in-path
|
||||||
:output-path out-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*)
|
(task *command-line-args*)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"defaults"
|
"defaults"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"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": {
|
"devDependencies": {
|
||||||
"autoprefixer": "^10.1.0",
|
"autoprefixer": "^10.1.0",
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user