Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit cf77784

Browse files
committed
Add lazy loader for translations
1 parent 55649ec commit cf77784

File tree

4 files changed

+16
-22
lines changed

4 files changed

+16
-22
lines changed

containers/app/StandardPrivateApp.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
import React, { useState, useRef } from 'react';
22
import PropTypes from 'prop-types';
3-
import { EventManagerProvider, ModalsChildren, ThemeInjector } from 'react-components';
3+
import { EventManagerProvider, ModalsChildren, ThemeInjector, lazyLocales as locales } from 'react-components';
44

55
import EventModelListener from '../eventManager/EventModelListener';
66
import EventNotices from '../eventManager/EventNotices';
77
import LoaderPage from './LoaderPage';
88
import StandardPreload from './StandardPreload';
99
import ForceRefreshProvider from '../forceRefresh/Provider';
1010

11-
const StandardPrivateApp = ({
12-
locales = {},
13-
onLogout,
14-
openpgpConfig,
15-
preloadModels = [],
16-
eventModels = [],
17-
children
18-
}) => {
11+
const StandardPrivateApp = ({ onLogout, openpgpConfig, preloadModels = [], eventModels = [], children }) => {
1912
const [loading, setLoading] = useState(true);
2013
const eventManagerRef = useRef();
2114

@@ -52,7 +45,6 @@ const StandardPrivateApp = ({
5245
StandardPrivateApp.propTypes = {
5346
onLogout: PropTypes.func.isRequired,
5447
children: PropTypes.node.isRequired,
55-
locales: PropTypes.object,
5648
openpgpConfig: PropTypes.object,
5749
preloadModels: PropTypes.array,
5850
eventModels: PropTypes.array

containers/app/StandardPublicApp.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, { useEffect, useState } from 'react';
2-
import { LoaderPage, GenericError, ModalsChildren } from 'react-components';
2+
import { LoaderPage, GenericError, ModalsChildren, lazyLocales as locales } from 'react-components';
33
import PropTypes from 'prop-types';
44
import { loadOpenPGP } from 'proton-shared/lib/openpgp';
55
import { getBrowserLocale, getClosestMatches } from 'proton-shared/lib/i18n/helper';
66
import loadLocale from 'proton-shared/lib/i18n/loadLocale';
77

8-
const StandardPublicApp = ({ locales = {}, openpgpConfig, children }) => {
8+
const StandardPublicApp = ({ openpgpConfig, children }) => {
99
const [loading, setLoading] = useState(true);
1010
const [error, setError] = useState(false);
1111

@@ -46,7 +46,6 @@ const StandardPublicApp = ({ locales = {}, openpgpConfig, children }) => {
4646
};
4747

4848
StandardPublicApp.propTypes = {
49-
locales: PropTypes.object,
5049
openpgpConfig: PropTypes.object,
5150
children: PropTypes.node
5251
};

containers/general/LanguageSection.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React from 'react';
22
import { c } from 'ttag';
3-
import PropTypes from 'prop-types';
43
import {
54
SubTitle,
65
Row,
76
Field,
87
Label,
98
Select,
9+
lazyLocales as locales,
1010
useApi,
1111
useConfig,
1212
useLoading,
@@ -19,7 +19,7 @@ import { updateLocale } from 'proton-shared/lib/api/settings';
1919
import loadLocale from 'proton-shared/lib/i18n/loadLocale';
2020
import { getBrowserLocale, getClosestMatches } from 'proton-shared/lib/i18n/helper';
2121

22-
const LanguageSection = ({ locales = {} }) => {
22+
const LanguageSection = () => {
2323
const api = useApi();
2424
const { call } = useEventManager();
2525
const { LOCALES = {} } = useConfig();
@@ -70,8 +70,4 @@ const LanguageSection = ({ locales = {} }) => {
7070
);
7171
};
7272

73-
LanguageSection.propTypes = {
74-
locales: PropTypes.object.isRequired
75-
};
76-
7773
export default LanguageSection;

index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,17 @@ export { default as AddFilterModal } from './containers/filters/AddFilterModal';
326326
export { default as AddEmailToListModal } from './containers/filters/AddEmailToListModal';
327327
export { default as StorageSpaceStatus } from './containers/sidebar/StorageSpaceStatus';
328328

329-
export { default as OpenVPNConfigurationSection } from './containers/vpn/OpenVPNConfigurationSection/OpenVPNConfigurationSection';
329+
export {
330+
default as OpenVPNConfigurationSection
331+
} from './containers/vpn/OpenVPNConfigurationSection/OpenVPNConfigurationSection';
330332
export { default as ProtonVPNClientsSection } from './containers/vpn/ProtonVPNClientsSection/ProtonVPNClientsSection';
331333
export { default as OpenVPNAccountSection } from './containers/vpn/OpenVPNAccountSection/OpenVPNAccountSection';
332-
export { default as ProtonVPNResourcesSection } from './containers/vpn/ProtonVPNResourcesSection/ProtonVPNResourcesSection';
333-
export { default as ProtonVPNCredentialsSection } from './containers/vpn/ProtonVPNCredentialsSection/ProtonVPNCredentialsSection';
334+
export {
335+
default as ProtonVPNResourcesSection
336+
} from './containers/vpn/ProtonVPNResourcesSection/ProtonVPNResourcesSection';
337+
export {
338+
default as ProtonVPNCredentialsSection
339+
} from './containers/vpn/ProtonVPNCredentialsSection/ProtonVPNCredentialsSection';
334340

335341
export { useUser, useGetUser } from './hooks/useUser';
336342
export { default as useUserVPN } from './hooks/useUserVPN';
@@ -383,3 +389,4 @@ export { default as TopNavbar } from './containers/app/TopNavbar';
383389
export { default as LoaderPage } from './containers/app/LoaderPage';
384390

385391
export * from './helpers/component';
392+
export { default as lazyLocales } from './helpers/lazyLocales';

0 commit comments

Comments
 (0)