Browse files

Document use of translations with React

  • Loading branch information...
1 parent 1c18e01 commit 315282da9c94390df8275338cbcd4bc3410927d8 @ptaoussanis committed Apr 10, 2014
Showing with 11 additions and 2 deletions.
  1. +11 −2
@@ -51,7 +51,7 @@ The `make-t` fn handles translations. You give it a config map which includes yo
:with-exclaim! "<tag>**strong**</tag>"
:greeting-alias :example/greeting
- :missing "<Missing translation: [%1$s %2$s %3$s]>"}
+ :missing "|Missing translation: [%1$s %2$s %3$s]|"}
:en-US {:example {:foo ":en-US :example/foo text"}}
:de {:example {:foo ":de :example/foo text"}}
:ja "test_ja.clj" ; Import locale's map from external resource
@@ -107,7 +107,7 @@ You can also specify fallback keys that'll be tried before other locales. `(t :e
In all cases, translation requests are logged upon fallback to fallback locale or :missing key.
-**ClojureScript translation support**: This is still **experimental**!
+#### ClojureScript translation support (still experimental!)
(ns my-clojurescript-ns
@@ -131,6 +131,15 @@ There's two notable differences from the JVM translator:
The API is otherwise exactly the same, including support for all decorators.
+##### Use with React (Reagent/Om/etc.)
+React presents a bit of a challenge to translations since it **automatically escapes all text content** as a security measure.
+This has two important implications for use with Tower's translations:
+ 1. Content intended to allow _translator-controlled inline styles_ needs to provided to React with the `dangerouslySetInnerHTML` property.
+ 2. All other content should get a `:<key>!`-style translation to prevent double escaping (Tower already escapes translations not marked with an exlamation point).
### Localization
Check out `fmt`, `parse`, `lsort`, `fmt-str`, `fmt-msg`:

0 comments on commit 315282d

Please sign in to comment.