react-translate-component
Advanced tools
Comparing version 0.11.1 to 0.12.0
13
index.js
@@ -38,3 +38,4 @@ 'use strict'; | ||
attributes: PropTypes.object | ||
attributes: PropTypes.object, | ||
with: PropTypes.object | ||
}, | ||
@@ -78,4 +79,10 @@ | ||
var interpolate = textContent || this.props.unsafe === true; | ||
var props = extend({ locale: this.state.locale }, this.props, { interpolate: interpolate }); | ||
var props = extend( | ||
{ locale: this.state.locale }, | ||
this.props, // DEPRECATED | ||
this.props.with, | ||
{ interpolate: interpolate } | ||
); | ||
if (props.attributes) { | ||
@@ -99,2 +106,3 @@ for (var attribute in props.attributes) { | ||
delete props.interpolate; | ||
delete props.with; | ||
@@ -109,2 +117,3 @@ return React.createElement(Interpolate, props, translation); | ||
delete props.component; | ||
delete props.with; | ||
@@ -111,0 +120,0 @@ return React.createElement(component, props); |
{ | ||
"name": "react-translate-component", | ||
"version": "0.11.1", | ||
"version": "0.12.0", | ||
"description": "A component for React that utilizes the counterpart module to translate/localize its content", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -127,3 +127,3 @@ # React Translate Component | ||
Now add the new Greeter component to the body element, provide a `name` prop holding your first name and a `component` prop which is set to "h1": | ||
Now add the new Greeter component to the body element, provide a `with` prop holding the interpolations (your first name in this case) and a `component` prop which is set to "h1": | ||
@@ -133,7 +133,7 @@ ```jsx | ||
<LocaleSwitcher /> | ||
<Greeter name="Martin" component="h1" /> | ||
<Greeter with={{ name: "Martin" }} component="h1" /> | ||
</body> | ||
``` | ||
The value of the `name` prop will be interpolated into the translation result. The `component` prop tells Translate which HTML tag to render as container element (a `<span>` by default). | ||
The value of the `name` key will be interpolated into the translation result. The `component` prop tells Translate which HTML tag to render as container element (a `<span>` by default). | ||
@@ -156,3 +156,3 @@ All that's left to do is to add the actual translations. You do so by calling the `registerTranslations` function of Counterpart. Add this to `client.js`: | ||
In the translations above we defined placeholders (in sprintf's named arguments syntax) which will be interpolated with the value of the `name` prop we gave to the Greeter component. | ||
In the translations above we defined placeholders (in sprintf's named arguments syntax) which will be interpolated with the value of the `name` key we gave to the Greeter component via the `with` prop. | ||
@@ -159,0 +159,0 @@ That's it for the application logic. To eventually see this working in a browser, we need to create the server-side code that will be executed by Node.js. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14558
99