mirror of https://github.com/trezor/trezor-wallet
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
49 lines
1.1 KiB
/* @flow */
|
|
import * as React from 'react';
|
|
import { connect } from 'react-redux';
|
|
import type { MapStateToProps } from 'react-redux';
|
|
import type { State } from 'flowtype';
|
|
|
|
import { IntlProvider, addLocaleData } from 'react-intl';
|
|
import en from 'react-intl/locale-data/en';
|
|
import de from 'react-intl/locale-data/de';
|
|
|
|
import messagesEn from '../../translations/en.json';
|
|
import messagesDe from '../../translations/de.json';
|
|
|
|
addLocaleData([...en, ...de]);
|
|
|
|
const messages = {
|
|
en: messagesEn,
|
|
de: messagesDe,
|
|
};
|
|
|
|
type OwnProps = {
|
|
children: React.Node
|
|
}
|
|
|
|
type StateProps = {
|
|
locale: string
|
|
}
|
|
|
|
type Props = StateProps & OwnProps;
|
|
|
|
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State): StateProps => ({
|
|
locale: state.wallet.language,
|
|
});
|
|
|
|
|
|
const ReactIntlProvider = ({ children, locale }: Props) => {
|
|
console.log(locale);
|
|
console.log(messages);
|
|
return (
|
|
<IntlProvider
|
|
locale={locale}
|
|
messages={messages[locale]}
|
|
>
|
|
{children}
|
|
</IntlProvider>
|
|
);
|
|
};
|
|
|
|
export default connect(mapStateToProps, null)(ReactIntlProvider); |