File tree Expand file tree Collapse file tree 4 files changed +19
-7
lines changed
features/dashboard/config-profiles/monaco-setup
widgets/dashboard/config-profiles/config-editor Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -141,4 +141,5 @@ build.info.json
141
141
142
142
public /wasm_exec.js
143
143
public /xray.schema.json
144
- public /main.wasm
144
+ public /main.wasm
145
+ public /xray.schema.cn.json
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ export const app = {
8
8
configEditor : {
9
9
wasmUrl : '/main.wasm' ,
10
10
wasmJsUrl : '/wasm_exec.js' ,
11
- jsonSchemaUrl : '/xray.schema.json'
11
+ jsonSchemaUrl : '/xray.schema.json' ,
12
+ jsonSchemaCnUrl : '/xray.schema.cn.json'
12
13
}
13
14
}
Original file line number Diff line number Diff line change @@ -5,9 +5,19 @@ import axios from 'axios'
5
5
import { app } from 'src/config'
6
6
7
7
export const MonacoSetupFeature = {
8
- setup : async ( monaco : Monaco ) => {
8
+ setup : async ( monaco : Monaco , currentLanguage : string ) => {
9
9
try {
10
- const response = await axios . get ( app . configEditor . jsonSchemaUrl )
10
+ let { jsonSchemaUrl } = app . configEditor
11
+ switch ( currentLanguage ) {
12
+ case 'zh' :
13
+ jsonSchemaUrl = app . configEditor . jsonSchemaCnUrl
14
+ break
15
+ default :
16
+ jsonSchemaUrl = app . configEditor . jsonSchemaUrl
17
+ }
18
+
19
+ const response = await axios . get ( jsonSchemaUrl )
20
+
11
21
const schema = await response . data
12
22
13
23
monaco . languages . json . jsonDefaults . setDiagnosticsOptions ( {
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import styles from './ConfigEditor.module.css'
12
12
import { IProps } from './interfaces'
13
13
14
14
export function ConfigEditorWidget ( props : IProps ) {
15
- const { t } = useTranslation ( )
15
+ const { t, i18n } = useTranslation ( )
16
16
17
17
const { configProfile } = props
18
18
const [ result , setResult ] = useState ( '' )
@@ -23,8 +23,8 @@ export function ConfigEditorWidget(props: IProps) {
23
23
24
24
useEffect ( ( ) => {
25
25
if ( ! monacoRef . current ) return
26
- MonacoSetupFeature . setup ( monacoRef . current as Monaco )
27
- } , [ monacoRef . current ] )
26
+ MonacoSetupFeature . setup ( monacoRef . current as Monaco , i18n . language )
27
+ } , [ monacoRef . current , i18n . language ] )
28
28
29
29
const handleEditorDidMount = ( monaco : Monaco ) => {
30
30
monaco . editor . defineTheme ( 'GithubDark' , {
You can’t perform that action at this time.
0 commit comments