I18n.locale = { 'Hello, World!': 'Hola, Mundo!', 'This text is {0}!': 'Este texto está en {0}!', 'bold': 'negrita', 'Write some text here': 'Escribí un texto acá', 'Hover over me': 'Mové el mouse sobre mi', 'Great!': 'Genial!', 'I\'m a button input': 'Soy un input botón', 'I\'m a submit input': 'Soy un input submit', '{0}/{1}/{2}': '{1}/{0}/{2}' }; // ========================================================================== // // Note that the default behavior is implicit translations (i.e. without // an explicit wrapper). To opt-out of this implicit behavior just // call: I18n.optOut(); var Test = React.createClass({ render: function() { return
{this.props.title}
{this.props.children}
} }); var NotTranslated1 = React.createClass({ noI18n: true, render: function() { return This is not translated } }); var DontTranslate = { I18n: false }; var NotTranslated2 = React.createClass({ mixins: [DontTranslate], render: function() { return This is not translated } }); var Func = ({children}) => {children}; var WrappedFunc = I18n.wrap(({children}) => {children}); // ========================================================================== // // To opt back in the implicit (default) behavior just call: I18n.optIn(); // Components defined from now on will have implicit translations by default: var ImplicitTest = React.createClass({ render: function() { return ; } }); // Note that you can still opt-out of translations on a per-component basis // using the noI18n flag in React.createClass({ noI18n: true, ... }) a mixin // like DontTranslate above. // ========================================================================== // setTimeout(function() { var content =
{/* see below for the implicit alternative */} Hello, World! This text is bold! Hover over me Custom It's always "a"
Hello, World!
This is not translated
Translation for this text will be missing (check browser console). 09/12/1900 {/* note the missing wrapper! */} Hello, World! Hello, World! Hello, World! Hello, World!
; ReactDOM.render(content, document.getElementById('container')); }, 1);