lingui-react
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -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; |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
173456
2115
3
+ Addedlingui-formats@^0.1.0
+ Addedlingui-formats@0.1.1(transitive)
+ Addedlingui-i18n@0.3.0(transitive)
- Removedabbrev@1.1.1(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.0.6(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedlingui-i18n@0.2.2(transitive)
- Removedmessageformat@1.1.1(transitive)
- Removedminimatch@3.1.2(transitive)
- Removednopt@3.0.6(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedreserved-words@0.1.2(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedlingui-i18n@^0.3.0