This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5741200
commit c06f233
Showing
12 changed files
with
122 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"configPages": { | ||
"config": "Config" | ||
}, | ||
"home": { | ||
"greeting": "Hello World!" | ||
}, | ||
"config": { | ||
"description": "The Abc App, is a plugin for Grafana that...", | ||
"updateButton": "Update Settings" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"configPages": { | ||
"config": "Config" | ||
}, | ||
"home": { | ||
"greeting": "Hello World!" | ||
}, | ||
"config": { | ||
"description": "The Abc App, is a plugin for Grafana that...", | ||
"updateButton": "Update Settings" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"configPages": { | ||
"config": "Config" | ||
}, | ||
"home": { | ||
"greeting": "Hello World!" | ||
}, | ||
"config": { | ||
"description": "The Abc App, is a plugin for Grafana that...", | ||
"updateButton": "Update Settings" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"configPages": { | ||
"config": "Config" | ||
}, | ||
"home": { | ||
"greeting": "Hello World!" | ||
}, | ||
"config": { | ||
"description": "The Abc App, is a plugin for Grafana that...", | ||
"updateButton": "Update Settings" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
import { config } from '@grafana/runtime'; | ||
import { DefaultLanguage } from './constants'; | ||
import { DefaultLanguage, Languages } from './constants'; | ||
import { SupportedLanguage } from './types'; | ||
|
||
/** | ||
* Get User Language | ||
* @param fallback | ||
*/ | ||
export const getUserLanguage = (fallback = DefaultLanguage): SupportedLanguage => { | ||
const locale = config?.bootData?.user?.language; | ||
const lang = locale?.split('-')?.[0]; | ||
const locale = config?.bootData?.user?.language; | ||
const lang = locale?.split('-')?.[0]; | ||
|
||
/** | ||
* Validate supported languages | ||
*/ | ||
switch (lang) { | ||
case 'en': | ||
case 'es': | ||
case 'fr': | ||
case 'de': | ||
case 'zh': { | ||
return lang; | ||
} | ||
/** | ||
* Validate supported languages | ||
*/ | ||
switch (lang) { | ||
case Languages.EN: | ||
case Languages.ES: | ||
case Languages.FR: | ||
case Languages.DE: | ||
case Languages.ZH: { | ||
return lang; | ||
} | ||
|
||
default: { | ||
return fallback; | ||
} | ||
default: { | ||
return fallback; | ||
} | ||
} | ||
}; |