From b37a6b07b39c8c7827052dc6fb97f490f1e0f514 Mon Sep 17 00:00:00 2001
From: Markus Hatvan <markus_hatvan@aon.at>
Date: Thu, 18 Nov 2021 17:37:45 +0100
Subject: 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
---
 src/I18n.tsx | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 src/I18n.tsx

(limited to 'src/I18n.tsx')

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 @@
+import { Component, ReactNode } from 'react';
+import { inject, observer } from 'mobx-react';
+import { IntlProvider } from 'react-intl';
+
+import { generatedTranslations } from './i18n/translations';
+import UserStore from './stores/UserStore';
+import AppStore from './stores/AppStore';
+
+const translations = generatedTranslations();
+
+type Props = {
+  stores: {
+    app: typeof AppStore;
+    user: typeof UserStore;
+  };
+  children: ReactNode;
+};
+
+@inject('stores')
+@observer
+class I18N extends Component<Props> {
+  componentDidUpdate() {
+    window['ferdi'].menu.rebuild();
+  }
+
+  render() {
+    const { stores, children } = this.props;
+    const { locale } = stores.app;
+    return (
+      <IntlProvider
+        {...{ locale, key: locale, messages: translations[locale] }}
+        ref={intlProvider => {
+          window['ferdi'].intl = intlProvider ? intlProvider.state.intl : null;
+        }}
+      >
+        {children}
+      </IntlProvider>
+    );
+  }
+}
+
+export default I18N;
-- 
cgit v1.2.3-54-g00ecf

