-
Notifications
You must be signed in to change notification settings - Fork 630
/
Copy pathLanguage.js
30 lines (25 loc) · 874 Bytes
/
Language.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
* Copyright (c) 2018-present, Evgeny Nadymov
*
* This source code is licensed under the GPL v.3.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import { I18nextProvider } from 'react-i18next';
import { getDisplayName } from './Utils/HOC';
import LocalizationStore from './Stores/LocalizationStore';
function withLanguage(WrappedComponent) {
class LanguageWrapper extends React.Component {
render() {
const i18n = LocalizationStore.i18n;
return (
<I18nextProvider i18n={i18n}>
<WrappedComponent {...this.props} />
</I18nextProvider>
);
}
}
LanguageWrapper.displayName = `WithLanguage(${getDisplayName(WrappedComponent)})`;
return LanguageWrapper;
}
export default withLanguage;