diff --git a/src/initializers/configLoader.ts b/src/initializers/configLoader.ts index 90e5ada01..b69385a26 100644 --- a/src/initializers/configLoader.ts +++ b/src/initializers/configLoader.ts @@ -3,22 +3,18 @@ import {setFrontendConfig} from "../redux/frontend-config/methods"; import {setBackendConfig} from "../redux/backend-config/methods"; import {getAndSetUser} from "../utils/apiUtils"; -export function loadAllConfig() { - return getFrontendConfig() - .then((frontendConfig) => { - if (!frontendConfig) { - return Promise.reject("Frontend config empty!"); - } - setFrontendConfig(frontendConfig); - return getBackendConfig() - }) - .then((backendConfig) => { - if (!backendConfig) { - return Promise.reject("Backend config empty!"); - } - setBackendConfig(backendConfig) - }).then(() => { - getAndSetUser(); - }) -} +export async function loadAllConfig() { + const frontendConfig = await getFrontendConfig(); + if (!frontendConfig) { + return Promise.reject("Frontend config empty!"); + } + setFrontendConfig(frontendConfig); + const backendConfig = await getBackendConfig() + if (!backendConfig) { + return Promise.reject("Backend config empty!"); + } + setBackendConfig(backendConfig) + + await getAndSetUser(); +} \ No newline at end of file diff --git a/src/initializers/i18n.ts b/src/initializers/i18n.ts index 6460760c7..ea0916d61 100644 --- a/src/initializers/i18n.ts +++ b/src/initializers/i18n.ts @@ -31,18 +31,11 @@ import "moment/locale/vi"; import "moment/locale/zh-cn"; import "moment/locale/zh-tw"; -export function setUpI18n() { - return i18n - // load translation using http -> see /public/locales - // learn more: https://github.com/i18next/i18next-http-backend +export async function setUpI18n() { + await i18n .use(Backend) - // detect user language - // learn more: https://github.com/i18next/i18next-browser-languageDetector .use(LanguageDetector) - // pass the i18n instance to react-i18next. .use(initReactI18next) - // init i18next - // for all options read: https://www.i18next.com/overview/configuration-options .init({ fallbackLng: 'en', debug: true, @@ -53,9 +46,9 @@ export function setUpI18n() { interpolation: { escapeValue: false, // not needed for react as it escapes by default }, - }).then(() => { - moment.locale(i18n.language); }) + + moment.locale(i18n.language); }