0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-11 07:11:32 -05:00

🐛 Fix autodetect language issues

This commit is contained in:
Andrey Antukh 2022-10-20 00:06:50 +02:00
parent 59e6ef5609
commit 6323c3ac92
2 changed files with 11 additions and 11 deletions

View file

@ -11,6 +11,7 @@
- Fix shortcut texts alignment [Taiga #4275](https://tree.taiga.io/project/penpot/issue/4275)
- Fix some texts and a typo [Taiga #4215](https://tree.taiga.io/project/penpot/issue/4215)
- Fix twitter support account link [Taiga #4279](https://tree.taiga.io/project/penpot/issue/4279)
- Fix lang autodetect issue [Taiga #4277](https://tree.taiga.io/project/penpot/issue/4277)
### :arrow_up: Deps updates

View file

@ -72,19 +72,22 @@
(defonce locale (l/atom (or (get @storage ::locale)
(autodetect))))
;; The translations `data` is a javascript object and should be treated
;; with `goog.object` namespace functions instead of a standard
;; clojure functions. This is for performance reasons because this
;; code is executed in the critical part (application bootstrap) and
;; used in many parts of the application.
(defn init!
"Initialize the i18n module with translations.
The `data` is a javascript object for performance reasons. This code
is executed in the critical part (application bootstrap) and used in
many parts of the application."
[data]
(set! translations data))
(defn set-locale!
[lname]
(if lname
(if (or (nil? lname)
(str/empty? lname))
(let [lname (autodetect)]
(swap! storage dissoc ::locale)
(reset! locale lname))
(let [supported (into #{} (map :value supported-locales))
lname (loop [locales (seq (parse-locale lname))]
(if-let [locale (first locales)]
@ -92,11 +95,7 @@
locale
(recur (rest locales)))
cfg/default-language))]
(swap! storage assoc ::locale lname)
(reset! locale lname))
(let [lname (autodetect)]
(swap! storage dissoc ::locale)
(reset! locale lname))))
(defn reset-locale