Skip to content
Snippets Groups Projects
Commit 0e4047b9 authored by Tom Robinson's avatar Tom Robinson
Browse files

Ensure we call setLocalization before loading any files with translated strings

parent 9a58673a
Branches
Tags
No related merge requests found
......@@ -12,18 +12,11 @@ import "number-to-locale-string";
// strings/elements to assist in finding untranslated strings.
import "metabase/lib/i18n-debug";
import "metabase/lib/colors";
// make the i18n function "t" global so we don't have to import it in basically every file
import { t, jt } from "c-3po";
global.t = t;
global.jt = jt;
// set the locale before loading anything else
import { setLocalization } from "metabase/lib/i18n";
if (window.MetabaseLocalization) {
setLocalization(window.MetabaseLocalization);
}
import "metabase/lib/i18n";
// NOTE: why do we need to load this here?
import "metabase/lib/colors";
import React from "react";
import ReactDOM from "react-dom";
......
import { addLocale, useLocale } from "c-3po";
import { I18NApi } from "metabase/services";
export async function loadLocalization(locale) {
// load and parse the locale
const translationsObject = await I18NApi.locale({ locale });
setLocalization(translationsObject);
}
// NOTE: loadLocalization not currently used, and we need to be sure to set the
// initial localization before loading any files, so don't load metabase/services
// just in case
// import { I18NApi } from "metabase/services";
//
// export async function loadLocalization(locale) {
// // load and parse the locale
// const translationsObject = await I18NApi.locale({ locale });
// setLocalization(translationsObject);
// }
export function setLocalization(translationsObject) {
const locale = translationsObject.headers.language;
......@@ -27,3 +32,8 @@ function addMsgIds(translationsObject) {
}
}
}
// set the initial localization
if (window.MetabaseLocalization) {
setLocalization(window.MetabaseLocalization);
}
......@@ -55,18 +55,8 @@ let simulateOfflineMode = false;
let apiRequestCompletedCallback = null;
let skippedApiRequests = [];
// These i18n settings are same is beginning of app.js
// make the i18n function "t" global so we don't have to import it in basically every file
import { t, jt } from "c-3po";
global.t = t;
global.jt = jt;
// set the locale before loading anything else
import { setLocalization } from "metabase/lib/i18n";
if (window.MetabaseLocalization) {
setLocalization(window.MetabaseLocalization);
}
// load files that are loaded at the top if app.js
import "metabase/lib/i18n";
const warnAboutCreatingStoreBeforeLogin = () => {
if (!loginSession && hasStartedCreatingStore) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment