nunopinheiro / react-i18n-helper Goto Github PK
View Code? Open in Web Editor NEWHelper functions and mixins to help localization (translation) of react applications
License: MIT License
Helper functions and mixins to help localization (translation) of react applications
License: MIT License
If all you need is the ability to fetch a document on a server you could use simply fetch
and a polyfill or something like axios
Running 'npm install --save react-i18n-helper' gives me an npm error 'Refusing to install react-i18n-helper as a dependency of itself'.
*edit
Adding it to package dependencies worked. But now I get this on npm start:
'Failed at the [email protected] start script 'rackt server'.
It seems that react doesn't have built in support for mixins when using ES6 style classes.
So I'm importing react-mixin which should help me. But I'm getting an error on changeLocale forceUpdate is not a function.
The initialData is loaded fine and I can see the right json being loaded on changeLocale. This is my component:
import React, {Component} from 'react';
import {changeLocale, i18nEventsListenerMixin, setupI18NConfiguration, i18n } from 'react-i18n-helper';
import reactMixin from 'react-mixin';
export default class Locale extends Component {
constructor(props) {
const initialData = {HelloWorld: 'Hello, World!'};
super(props);
setupI18NConfiguration({clientPath: 'static/i18n', fallBackLocale: 'en-GB', initialState: {locale: 'en-GB', data: initialData}});
}
state = {
desktop: true
};
render() {
return (
<div>
<span>{i18n('HelloWorld')}</span>
<button onClick={() => changeLocale('pt-PT')}>pt-PT</button>
<button onClick={() => changeLocale('en-GB')}>en-GB</button>
</div>
);
}
}
reactMixin(Locale.prototype, i18nEventsListenerMixin);
Do you have an idea about what I'm doing wrong?...thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.