Permalink
Browse files

Fix bug preventing default-locale translation fallback

  • Loading branch information...
1 parent 5fb0c05 commit 5e8fe2babea84804f1da92477e72f878a09fb002 @ptaoussanis committed Oct 26, 2012
Showing with 15 additions and 12 deletions.
  1. +13 −11 src/taoensso/tower.clj
  2. +2 −1 test/test_tower/main.clj
View
@@ -442,17 +442,19 @@
(if-not (keyword? last-kchoice*)
last-kchoice* ; Return provided explicit fallback value
- (do (log-missing-translation!-fn
- {:dev-mode? dev-mode? :locale *Locale* :k-or-ks k-or-ks})
-
- ;; Try fall back to named keys in (different) default locale
- (when-not (= @lchoices* lchoices)
- (some get-in-dict (for [k kchoices] [default-locale (sk k)])))
-
- ;; Try fall back to :missing key in named or default locale
- (when-let [pattern (some get-in-dict (for [l @lchoices*]
- [l :missing]))]
- (format-msg pattern k-or-ks))))))))))
+ (do
+ (log-missing-translation!-fn
+ {:dev-mode? dev-mode? :locale *Locale* :k-or-ks k-or-ks})
+
+ (or
+ ;; Try fall back to named keys in (different) default locale
+ (when-not (= @lchoices* lchoices)
+ (some get-in-dict (for [k kchoices] [default-locale (sk k)])))
+
+ ;; Try fall back to :missing key in named or default locale
+ (when-let [pattern (some get-in-dict (for [l @lchoices*]
+ [l :missing]))]
+ (format-msg pattern k-or-ks)))))))))))
(comment (with-locale :en-ZA (t :example/foo))
(with-locale :en-ZA (with-scope :example (t :foo)))
View
@@ -128,7 +128,8 @@
:en ":en :example/foo text"
:en-US ":en-US :example/foo text"
:en-GB ":en :example/foo text"
- :default ":en :example/foo text")
+ :default ":en :example/foo text"
+ :zh-CN ":en :example/foo text")
;; Scoping
(with-locale :en

0 comments on commit 5e8fe2b

Please sign in to comment.