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.12.2 to 0.13.0

72

index.js

@@ -17,2 +17,7 @@ 'use strict';

var keyType = PropTypes.oneOfType([
PropTypes.string,
PropTypes.arrayOf(PropTypes.string)
]);
var Translate = React.createClass({

@@ -22,3 +27,4 @@ displayName: 'Translate',

contextTypes: {
translator: translatorType
translator: translatorType,
scope: keyType
},

@@ -29,13 +35,4 @@

count: PropTypes.number,
content: PropTypes.oneOfType([
PropTypes.string,
PropTypes.arrayOf(PropTypes.string)
]),
scope: PropTypes.oneOfType([
PropTypes.string,
PropTypes.arrayOf(PropTypes.string)
]),
content: keyType,
scope: keyType,
attributes: PropTypes.object,

@@ -87,3 +84,3 @@ with: PropTypes.object

var attributeTranslationOptions = extend(
{ locale: this.state.locale },
{ locale: this.state.locale, scope: this.context.scope },
props,

@@ -102,5 +99,2 @@ interpolations,

delete props.scope;
delete props.separator;
delete props.fallbackLocale;
delete props.fallback;
delete props.count;

@@ -147,1 +141,47 @@ delete props.with;

module.exports.translatorType = translatorType;
module.exports.getLocale = translator.getLocale.bind(translator);
module.exports.setLocale = translator.setLocale.bind(translator);
module.exports.registerTranslations = translator.registerTranslations.bind(translator);
function withTranslations(DecoratedComponent, translations) {
if (!translations) {
return function(decoratedComponent) {
return withTranslations(decoratedComponent, DecoratedComponent);
};
}
var displayName =
DecoratedComponent.displayName ||
DecoratedComponent.name ||
'Component';
for (var locale in translations) {
var localeTranslations = translations[locale];
var scopedTranslations = {};
scopedTranslations[displayName] = localeTranslations;
translator.registerTranslations(locale, scopedTranslations);
}
return React.createClass({
displayName: displayName + 'WithTranslations',
childContextTypes: {
scope: keyType
},
getChildContext: function() {
return {
scope: displayName
};
},
render: function() {
return React.createElement(DecoratedComponent, this.props);
}
});
}
module.exports.withTranslations = withTranslations;
{
"name": "react-translate-component",
"version": "0.12.2",
"version": "0.13.0",
"description": "A component for React that utilizes the counterpart module to translate/localize its content",

@@ -5,0 +5,0 @@ "main": "index.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