summaryrefslogtreecommitdiffstats
path: root/src/I18n.tsx
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-11-18 17:37:45 +0100
committerLibravatar GitHub <noreply@github.com>2021-11-18 22:07:45 +0530
commitb37a6b07b39c8c7827052dc6fb97f490f1e0f514 (patch)
tree0276e7c51f5ebfa14c566def7aac39f014c2291d /src/I18n.tsx
parentUpdate github issues template [skip ci] (diff)
downloadferdium-app-b37a6b07b39c8c7827052dc6fb97f490f1e0f514.tar.gz
ferdium-app-b37a6b07b39c8c7827052dc6fb97f490f1e0f514.tar.zst
ferdium-app-b37a6b07b39c8c7827052dc6fb97f490f1e0f514.zip
chore: convert various files to TS (#2246)
* convert various files to TS * removed outdated docs/example-feature folder * turn off unicorn/no-empty-file * update eslint config
Diffstat (limited to 'src/I18n.tsx')
-rw-r--r--src/I18n.tsx42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/I18n.tsx b/src/I18n.tsx
new file mode 100644
index 000000000..39b5273c1
--- /dev/null
+++ b/src/I18n.tsx
@@ -0,0 +1,42 @@
1import { Component, ReactNode } from 'react';
2import { inject, observer } from 'mobx-react';
3import { IntlProvider } from 'react-intl';
4
5import { generatedTranslations } from './i18n/translations';
6import UserStore from './stores/UserStore';
7import AppStore from './stores/AppStore';
8
9const translations = generatedTranslations();
10
11type Props = {
12 stores: {
13 app: typeof AppStore;
14 user: typeof UserStore;
15 };
16 children: ReactNode;
17};
18
19@inject('stores')
20@observer
21class I18N extends Component<Props> {
22 componentDidUpdate() {
23 window['ferdi'].menu.rebuild();
24 }
25
26 render() {
27 const { stores, children } = this.props;
28 const { locale } = stores.app;
29 return (
30 <IntlProvider
31 {...{ locale, key: locale, messages: translations[locale] }}
32 ref={intlProvider => {
33 window['ferdi'].intl = intlProvider ? intlProvider.state.intl : null;
34 }}
35 >
36 {children}
37 </IntlProvider>
38 );
39 }
40}
41
42export default I18N;