Socket
Socket
Sign inDemoInstall

react-localization

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-localization - npm Package Compare versions

Comparing version 0.0.18 to 0.1.0

2

lib/LocalizedStrings.js

@@ -218,3 +218,3 @@ 'use strict';

return isReactComponent(valueForPlaceholder) ? _react2.default.Children.toArray(valueForPlaceholder).map(function (component) {
return _extends({}, component, { key: index });
return _extends({}, component, { key: index.toString() });
}) : valueForPlaceholder;

@@ -221,0 +221,0 @@ }

{
"name": "react-localization",
"version": "0.0.18",
"version": "0.1.0",
"description": "Simple module to localize the React interface using the same syntax used in the ReactNativeLocalization module, use 'npm run build' before publishing",

@@ -31,5 +31,5 @@ "scripts": {

"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.22.0",
"jasmine": "^2.6.0",
"jasmine-core": "^2.6.2"
"jasmine": "^2.6.0"
},

@@ -36,0 +36,0 @@ "dependencies": {

@@ -0,1 +1,3 @@

import React from 'react';
import LocalizedStrings from '../src/LocalizedStrings';

@@ -135,2 +137,32 @@

});
describe('formatString with React components', () => {
const reactStrings = new LocalizedStrings({
en: {
onlyForMembers: "Only who have {0} can enter",
onlyForMembersStrong: "Only who have {0} can {1}",
helloThere: "Hello {0}! Are you sure {0} is your name?",
},
fi: {
onlyForMembers: "Vain {0} voivat tulla",
onlyForMembersStrong: "Vain {0} voivat {1}",
helloThere: "Moi {0}! Onko {0} varmasti nimesi?",
}
});
it('one React component', () => {
expect(reactStrings.formatString(reactStrings.onlyForMembers, <a href="#">logged in</a>))
.toEqual(["Only who have ", [<a href="#" key="1">logged in</a>], " can enter"]);
});
it('two React component', () => {
expect(reactStrings.formatString(reactStrings.onlyForMembersStrong, <a href="#">logged in</a>, <b>enter</b>))
.toEqual(["Only who have ", [<a href="#" key="1">logged in</a>], " can ", [<b key="3">enter</b>]]);
});
it('one React component twice in a string', () => {
expect(reactStrings.formatString(reactStrings.helloThere, <i>Henrik</i>))
.toEqual(["Hello ", [<i key="1">Henrik</i>], "! Are you sure ", [<i key="3">Henrik</i>], " is your name?"]);
});
});
});

@@ -149,3 +149,3 @@ 'use strict';

return isReactComponent(valueForPlaceholder)
? React.Children.toArray(valueForPlaceholder).map(component => ({...component, key: index}))
? React.Children.toArray(valueForPlaceholder).map(component => ({...component, key: index.toString()}))
: valueForPlaceholder;

@@ -152,0 +152,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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