terra-i18n
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -7,2 +7,7 @@ Changelog | ||
1.4.0 - (August 31, 2017) | ||
------------------ | ||
### Changed | ||
* Improved terra-i18n example in README.md | ||
1.3.0 - (August 8, 2017) | ||
@@ -9,0 +14,0 @@ ------------------ |
@@ -14,7 +14,34 @@ # Terra I18n | ||
```jsx | ||
import React from 'react'; | ||
import { I18nProvider, i18nLoader } from 'terra-i18n'; | ||
i18nLoader('en', this.setState, this) | ||
export default class ExampleLoader extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
<I18nProvider locale={this.state.locale} messages={this.state.messages} /> | ||
this.state = { | ||
areTranslationsLoaded: false, | ||
locale: props.locale, | ||
messages: {}, | ||
}; | ||
} | ||
componentDidMount() { | ||
i18nLoader(this.state.locale, this.setState, this); | ||
} | ||
render() { | ||
// Do not render components or the provider until translations and other | ||
// dependencies are loaded. | ||
if (!this.state.areTranslationsLoaded) { | ||
return null; | ||
} | ||
return ( | ||
<I18nProvider locale={this.state.locale} messages={this.state.messages}> | ||
{this.props.children} | ||
</I18nProvider> | ||
); | ||
} | ||
} | ||
``` | ||
@@ -21,0 +48,0 @@ |
{ | ||
"name": "terra-i18n", | ||
"main": "lib/I18n.js", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "The terra-i18n component provides the internationalization to the React component. Terra supports the following locales: 'de' 'es' 'en' 'en-US' 'en-GB', 'fi-FI', 'fr', 'pt'. All locales related files are loading on demand.", | ||
@@ -25,3 +25,3 @@ "repository": { | ||
"babel-jest": "^19.0.0", | ||
"terra-props-table": "^1.3.0" | ||
"terra-props-table": "^1.4.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "peerDependencies": { |
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
26882
23