Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-translate-component

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-translate-component - npm Package Compare versions

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);

2

package.json
{
"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.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc