Socket
Socket
Sign inDemoInstall

lingui-react

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lingui-react - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

12

lib/index.js

@@ -6,4 +6,8 @@ 'use strict';

});
exports.Select = exports.Plural = exports.Trans = exports.WithI18n = exports.InjectI18n = exports.I18nProvider = undefined;
exports.Select = exports.Plural = exports.Trans = exports.WithI18n = exports.InjectI18n = exports.I18nProvider = exports.NumberFormat = exports.DateFormat = undefined;
var _linguiFormats = require('lingui-formats');
var Formats = _interopRequireWildcard(_linguiFormats);
var _I18nProvider = require('./I18nProvider');

@@ -31,2 +35,4 @@

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
var InjectI18n = function InjectI18n(WrappedComponent) {

@@ -36,2 +42,6 @@ console.warn('DEPRECATED (removal in 1.x): InjectI18n was replaced with WithI18n([ options ])');

};
var DateFormat = exports.DateFormat = (0, _WithI18n2.default)()(Formats.DateFormat);
var NumberFormat = exports.NumberFormat = (0, _WithI18n2.default)()(Formats.NumberFormat);
exports.I18nProvider = _I18nProvider2.default;

@@ -38,0 +48,0 @@ exports.InjectI18n = InjectI18n;

14

lib/Trans.js

@@ -58,3 +58,5 @@ 'use strict';

value: function compileMessage(translation) {
var i18n = this.props.i18n;
var _props = this.props,
i18n = _props.i18n,
formats = _props.formats;

@@ -65,3 +67,3 @@

};
return i18n.compile(translation);
return i18n.compile(translation, formats);
}

@@ -89,6 +91,6 @@ }, {

value: function render() {
var _props = this.props,
params = _props.params,
components = _props.components,
className = _props.className;
var _props2 = this.props,
params = _props2.params,
components = _props2.components,
className = _props2.className;
var msgCache = this.state.msgCache;

@@ -95,0 +97,0 @@

{
"name": "lingui-react",
"version": "0.3.1",
"version": "0.4.0",
"description": "React components for translations",

@@ -32,3 +32,4 @@ "main": "lib/index.js",

"dependencies": {
"lingui-i18n": "^0.2.2"
"lingui-formats": "^0.1.0",
"lingui-i18n": "^0.3.0"
},

@@ -35,0 +36,0 @@ "devDependencies": {

@@ -28,3 +28,3 @@ // @flow

it('should throw an error on incorrect language', function () {
const component = () => mount(<I18nProvider language="xyz"><div/></I18nProvider>)
const component = () => mount(<I18nProvider language="xyz" messages={{}}><div/></I18nProvider>)
expect(component).toThrowErrorMatchingSnapshot()

@@ -31,0 +31,0 @@ })

// @flow
import * as Formats from 'lingui-formats'
import I18nProvider from './I18nProvider'

@@ -13,2 +14,5 @@ import WithI18n from './WithI18n'

export const DateFormat = WithI18n()(Formats.DateFormat)
export const NumberFormat = WithI18n()(Formats.NumberFormat)
export { I18nProvider, InjectI18n, WithI18n, Trans, Plural, Select }

@@ -12,2 +12,3 @@ // @flow

params?: Object,
formats?: Object,
components?: Array<React$Element<any>>,

@@ -51,6 +52,6 @@

compileMessage (translation: string): Function {
const { i18n } = this.props
const { i18n, formats } = this.props
if (!i18n.compile) return () => translation
return i18n.compile(translation)
return i18n.compile(translation, formats)
}

@@ -57,0 +58,0 @@

@@ -18,3 +18,4 @@ /* @flow */

'Original': 'Původní',
'Updated': 'Aktualizovaný'
'Updated': 'Aktualizovaný',
'msg.currency': '{value, number, currency}'
}

@@ -71,2 +72,15 @@ })

})
it('should render custom format', function () {
const translation = text(
<Trans
id="msg.currency"
params={{ value: 1 }}
formats={{ currency: {
style: 'currency',
currency: 'EUR'
}}}
/>)
expect(translation).toEqual('€1.00')
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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