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

react-localize

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-localize - npm Package Compare versions

Comparing version 1.0.0-rc1 to 1.0.0-rc2

24

build/Text.js

@@ -24,5 +24,6 @@ 'use strict';

var message = props.message;
var children = props.children;
var values = props.values;
var rest = _objectWithoutProperties(props, ['message', 'values']);
var rest = _objectWithoutProperties(props, ['message', 'children', 'values']);

@@ -32,7 +33,17 @@ var localize = context.localize;

return _react2.default.createElement(
'span',
rest,
localize.apply(undefined, [message].concat(_toConsumableArray(values)))
);
var localized = message;
if (typeof localize === 'function') {
localized = localize.apply(undefined, [message].concat(_toConsumableArray(values)));
}
if (typeof children === 'function') {
return children.apply(undefined, [localized, message].concat(_toConsumableArray(values)));
} else {
return _react2.default.createElement(
'span',
rest,
localized
);
}
};

@@ -43,2 +54,3 @@

Text.propTypes = {
children: func,
message: string.isRequired,

@@ -45,0 +57,0 @@ values: array

{
"name": "react-localize",
"version": "1.0.0-rc1",
"version": "1.0.0-rc2",
"description": "A simple context wrapper and text localization component for localizing strings",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -31,2 +31,15 @@ # react-localize

## Also you can defer rendering for custom output:
```
<Text message='some.key'>
{(localized, message, ...values) => {
// message & ...values are optional, and are really just whatever you sent in on props
return <input type="text" placholder={localized} />
}}
</Text>
```
(that's so you can use something other than span, or put localized text in attributes, mostly)
## More Stuff

@@ -33,0 +46,0 @@ I think you might need to browserify `build/index.js` because of `util` dependency. I have the `dist/` folder but I'm not sure how I feel about all that or what it should do yet.

@@ -19,6 +19,17 @@ /*

const Text = (props, context) => {
const { message, values, ...rest } = props;
const { message, children, values, ...rest } = props;
const { localize } = context;
return (<span {...rest}>{localize(message, ...values)}</span>);
let localized = message;
if (typeof localize === 'function') {
localized = localize(message, ...values);
}
// allow for optional alternative API using render-prop pattern
if (typeof children === 'function') {
return children(localized, message, ...values);
} else {
return (<span {...rest}>{localized}</span>);
}
};

@@ -29,2 +40,3 @@

Text.propTypes = {
children: func,
message: string.isRequired,

@@ -31,0 +43,0 @@ values: array

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