Skip to content

Commit

Permalink
Document use of translations with React
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaoussanis committed Apr 10, 2014
1 parent 1c18e01 commit 315282d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions README.md
Expand Up @@ -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
:baz-alias :example.bar/baz}
: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
Expand Down Expand Up @@ -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!)

```clojure
(ns my-clojurescript-ns
Expand All @@ -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`:
Expand Down

0 comments on commit 315282d

Please sign in to comment.