Skip to content

Commit

Permalink
in the spec, require all translation keys to be namespaced
Browse files Browse the repository at this point in the history
  • Loading branch information
akatov committed Nov 4, 2023
1 parent 609eb04 commit 96404bd
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/status_im2/setup/i18n_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,27 @@
[status-im2.setup.i18n-resources :as i18n-resources]
[utils.i18n :as i18n]))

(defn- js-translations->namespaced-keys
[js-translations]
(->> js-translations
js->clj
keys
(map (partial keyword "t"))
set))

;; english as source of truth
(def labels
(set (keys (js->clj (:en i18n-resources/translations-by-locale)
:keywordize-keys
true))))
(-> i18n-resources/translations-by-locale
:en
js-translations->namespaced-keys))

(spec/def ::label labels)
(spec/def ::labels (spec/coll-of ::label :kind set? :into #{}))

(defn labels-for-all-locales
[]
(->> i18n-resources/translations-by-locale
(mapcat #(-> % val (js->clj :keywordize-keys true) keys))
(mapcat (comp js-translations->namespaced-keys val))
set))

;; checkpoints
Expand Down Expand Up @@ -1035,7 +1043,9 @@

(defn locale->labels
[locale]
(-> i18n-resources/translations-by-locale (get locale) (js->clj :keywordize-keys true) keys set))
(-> i18n-resources/translations-by-locale
(get locale)
js-translations->namespaced-keys))

(defn locale->checkpoint
[locale]
Expand Down

0 comments on commit 96404bd

Please sign in to comment.