diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-11-18 17:37:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-18 22:07:45 +0530 |
commit | b37a6b07b39c8c7827052dc6fb97f490f1e0f514 (patch) | |
tree | 0276e7c51f5ebfa14c566def7aac39f014c2291d /src/I18n.tsx | |
parent | Update github issues template [skip ci] (diff) | |
download | ferdium-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.tsx | 42 |
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 @@ | |||
1 | import { Component, ReactNode } from 'react'; | ||
2 | import { inject, observer } from 'mobx-react'; | ||
3 | import { IntlProvider } from 'react-intl'; | ||
4 | |||
5 | import { generatedTranslations } from './i18n/translations'; | ||
6 | import UserStore from './stores/UserStore'; | ||
7 | import AppStore from './stores/AppStore'; | ||
8 | |||
9 | const translations = generatedTranslations(); | ||
10 | |||
11 | type Props = { | ||
12 | stores: { | ||
13 | app: typeof AppStore; | ||
14 | user: typeof UserStore; | ||
15 | }; | ||
16 | children: ReactNode; | ||
17 | }; | ||
18 | |||
19 | @inject('stores') | ||
20 | @observer | ||
21 | class 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 | |||
42 | export default I18N; | ||