lingui-react
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -30,6 +30,6 @@ 'use strict'; | ||
function Trans(props, context) { | ||
function Trans(props) { | ||
_classCallCheck(this, Trans); | ||
var _this = _possibleConstructorReturn(this, (Trans.__proto__ || Object.getPrototypeOf(Trans)).call(this, props, context)); | ||
var _this = _possibleConstructorReturn(this, (Trans.__proto__ || Object.getPrototypeOf(Trans)).call(this, props)); | ||
@@ -48,3 +48,4 @@ var translation = _this.getTranslation(props); | ||
value: function getTranslation(props) { | ||
var id = props.id, | ||
var _props$id = props.id, | ||
id = _props$id === undefined ? '' : _props$id, | ||
defaults = props.defaults, | ||
@@ -54,3 +55,3 @@ i18n = props.i18n; | ||
return (i18n.messages ? i18n.messages[id] : '') || defaults || id; | ||
return (i18n.messages && id ? i18n.messages[id] : '') || defaults || id; | ||
} | ||
@@ -57,0 +58,0 @@ }, { |
{ | ||
"name": "lingui-react", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "React components for translations", | ||
@@ -32,7 +32,7 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"lingui-i18n": "^0.2.0" | ||
"lingui-i18n": "^0.2.2" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.22.2", | ||
"babel-polyfill": "^6.22.0", | ||
"babel-cli": "^6.23.0", | ||
"babel-polyfill": "^6.23.0", | ||
"babel-preset-env": "^1.1.8", | ||
@@ -39,0 +39,0 @@ "rimraf": "^2.5.4" |
@@ -11,7 +11,7 @@ // @flow | ||
messages: { | ||
'cs-cz': { | ||
'cs': { | ||
'All human beings are born free and equal in dignity and rights.': 'Všichni lidé rodí se svobodní a sobě rovní co do důstojnosti a práv.' | ||
} | ||
}, | ||
language: 'cs-cz' | ||
language: 'cs' | ||
} | ||
@@ -28,2 +28,7 @@ | ||
it('should throw an error on incorrect language', function () { | ||
const component = () => mount(<I18nProvider language="xyz"><div/></I18nProvider>) | ||
expect(component).toThrowErrorMatchingSnapshot() | ||
}) | ||
it('should render children', function () { | ||
@@ -30,0 +35,0 @@ const child = <div className="testcase" /> |
@@ -9,3 +9,3 @@ // @flow | ||
type TransProps = { | ||
id: string, | ||
id?: string, | ||
defaults?: string, | ||
@@ -24,3 +24,3 @@ params?: Object, | ||
class Trans extends React.Component<*, TransProps, TransState> { | ||
class Trans extends React.Component { | ||
props: TransProps | ||
@@ -34,4 +34,4 @@ state: TransState | ||
constructor (props, context) { | ||
super(props, context) | ||
constructor (props) { | ||
super(props) | ||
@@ -47,5 +47,5 @@ const translation = this.getTranslation(props) | ||
getTranslation (props): string { | ||
const { id, defaults, i18n } = props | ||
const { id = '', defaults, i18n } = props | ||
return (i18n.messages ? i18n.messages[id] : '') || defaults || id | ||
return (i18n.messages && id ? i18n.messages[id] : '') || defaults || id | ||
} | ||
@@ -52,0 +52,0 @@ |
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
173284
38
2091
Updatedlingui-i18n@^0.2.2