@@ -17,57 +17,66 @@ limitations under the License.
17
17
import React from 'react' ;
18
18
import ReactDOM from 'react-dom/client' ;
19
19
import App from './App.tsx' ;
20
- import i18nInstance , { getLang } from '@/utils/i18n' ;
21
- import { initReactI18next } from 'react-i18next' ;
22
- import { loader } from '@monaco-editor/react' ;
20
+ import i18nInstance , { getLang } from '@/utils/i18n' ;
21
+ import { initReactI18next } from 'react-i18next' ;
22
+ import dayjs from 'dayjs' ;
23
+ import duration from 'dayjs/plugin/duration' ;
24
+ import relativeTime from 'dayjs/plugin/relativeTime' ;
25
+ import utc from 'dayjs/plugin/utc' ;
26
+ import timezone from 'dayjs/plugin/timezone' ;
27
+ import { loader } from '@monaco-editor/react' ;
23
28
import * as monaco from 'monaco-editor' ;
24
29
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker' ;
25
30
// https://github.com/remcohaszing/monaco-yaml/issues/150
26
31
import yamlWorker from '@/utils/workaround-yaml.worker?worker' ;
27
32
import enTexts from '../locales/en-US.json' ;
28
33
import zhTexts from '../locales/zh-CN.json' ;
29
- import { initRoute } from '@/routes/route.tsx' ;
34
+ import { initRoute } from '@/routes/route.tsx' ;
30
35
36
+ dayjs . extend ( duration ) ;
37
+ dayjs . extend ( relativeTime ) ;
38
+ dayjs . extend ( utc ) ;
39
+ dayjs . extend ( timezone ) ;
31
40
window . MonacoEnvironment = {
32
- getWorker ( _ , label ) {
33
- if ( label === 'yaml' ) {
34
- return new yamlWorker ( ) ;
35
- }
36
- return new editorWorker ( ) ;
37
- } ,
41
+ getWorker ( _ , label ) {
42
+ if ( label === 'yaml' ) {
43
+ return new yamlWorker ( ) ;
44
+ }
45
+ return new editorWorker ( ) ;
46
+ } ,
38
47
} ;
39
- loader . config ( { monaco} ) ;
48
+ loader . config ( { monaco } ) ;
40
49
41
50
i18nInstance
42
- . use ( initReactI18next ) // passes i18n down to react-i18next
43
- . init ( {
44
- debug : true ,
45
- lng : getLang ( ) , // if you're using a language detector, do not define the lng option
46
- fallbackLng : [ 'zh-CN' ] ,
47
- resources : {
48
- zh : {
49
- translation : zhTexts ,
50
- } ,
51
- en : {
52
- translation : enTexts ,
53
- } ,
54
- } ,
55
- interpolation : {
56
- escapeValue : false , // react already safes from xss => https://www.i18next.com/translation-function/interpolation#unescape
57
- } ,
58
- saveMissing : true , // send not translated keys to endpoint,
59
- react : {
60
- useSuspense : false ,
61
- } ,
62
- } )
63
- . then ( ( ) => {
64
- initRoute ( ) ;
65
- ReactDOM . createRoot ( document . getElementById ( 'root' ) ! ) . render (
66
- < React . StrictMode >
67
- < App />
68
- </ React . StrictMode > ,
69
- ) ;
70
- } )
71
- . catch ( ( ) => {
72
-
73
- } )
51
+ . use ( initReactI18next ) // passes i18n down to react-i18next
52
+ . init ( {
53
+ debug : true ,
54
+ lng : getLang ( ) , // if you're using a language detector, do not define the lng option
55
+ fallbackLng : [ 'zh-CN' ] ,
56
+ resources : {
57
+ zh : {
58
+ translation : zhTexts ,
59
+ } ,
60
+ en : {
61
+ translation : enTexts ,
62
+ } ,
63
+ } ,
64
+ interpolation : {
65
+ escapeValue : false , // react already safes from xss => https://www.i18next.com/translation-function/interpolation#unescape
66
+ } ,
67
+ saveMissing : true , // send not translated keys to endpoint,
68
+ react : {
69
+ useSuspense : false ,
70
+ } ,
71
+ } )
72
+ . then ( ( ) => {
73
+ initRoute ( ) ;
74
+ ReactDOM . createRoot ( document . getElementById ( 'root' ) ! ) . render (
75
+ < React . StrictMode >
76
+ < App />
77
+ </ React . StrictMode > ,
78
+ ) ;
79
+ } )
80
+ . catch ( ( err ) => {
81
+ console . error ( 'initialization failed:' , err ) ;
82
+ } ) ;
0 commit comments