Simplify fn translations in light of #10868

- Reverted overly complex fn translations from #10810
- Updated guidelines so it's clear that fn translations need to remain
simple. They shouldn't be so complex that they fail for edge cases
- Updated catch so we are aware when translations fail
This commit is contained in:
Gabriel Horner
2024-01-18 10:18:23 -05:00
committed by Tienson Qin
parent c4341c1884
commit 283d084de2
4 changed files with 16 additions and 19 deletions

View File

@@ -4,7 +4,8 @@
throughout the application."
(:require [frontend.dicts :as dicts]
[tongue.core :as tongue]
[frontend.state :as state]))
[frontend.state :as state]
[lambdaisland.glogi :as log]))
(def dicts (merge dicts/dicts {:tongue/fallback :en}))
@@ -17,8 +18,13 @@
(try
(apply translate preferred-language args)
(catch :default e
(js/console.error "Translating dict" e)
(apply translate :en args)))))
(log/error :failed-translation {:arguments args
:lang preferred-language})
(apply translate :en args)
(state/pub-event! [:capture-error {:error e
:payload {:type :failed-translation
:arguments args
:lang preferred-language}}])))))
(defn- fetch-local-language []
(.. js/window -navigator -language))