Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
0e4047b9
Commit
0e4047b9
authored
6 years ago
by
Tom Robinson
Browse files
Options
Downloads
Patches
Plain Diff
Ensure we call setLocalization before loading any files with translated strings
parent
9a58673a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
frontend/src/metabase/app.js
+4
-11
4 additions, 11 deletions
frontend/src/metabase/app.js
frontend/src/metabase/lib/i18n.js
+16
-6
16 additions, 6 deletions
frontend/src/metabase/lib/i18n.js
frontend/test/__support__/integrated_tests.js
+2
-12
2 additions, 12 deletions
frontend/test/__support__/integrated_tests.js
with
22 additions
and
29 deletions
frontend/src/metabase/app.js
+
4
−
11
View file @
0e4047b9
...
...
@@ -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
"
;
...
...
This diff is collapsed.
Click to expand it.
frontend/src/metabase/lib/i18n.js
+
16
−
6
View file @
0e4047b9
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
);
}
This diff is collapsed.
Click to expand it.
frontend/test/__support__/integrated_tests.js
+
2
−
12
View file @
0e4047b9
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment