diff --git a/CHANGES.md b/CHANGES.md index 2ac85e15f..f8a5710cc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/frontend/src/app/util/i18n.cljs b/frontend/src/app/util/i18n.cljs index e308d7e1f..5241b6c28 100644 --- a/frontend/src/app/util/i18n.cljs +++ b/frontend/src/app/util/i18n.cljs @@ -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