@@ -3,14 +3,14 @@ import { container } from 'tsyringe';
3
3
import React , { createContext , Component } from 'react' ;
4
4
5
5
import { defaultExtensions } from 'mo/extensions' ;
6
- import { BuiltInDefault } from 'mo/extensions/locales-defaults' ;
6
+ import { BuiltInId } from 'mo/extensions/locales-defaults' ;
7
7
import { IExtension } from 'mo/model/extension' ;
8
8
import {
9
9
ExtensionService ,
10
10
IExtensionService ,
11
11
} from 'mo/services/extensionService' ;
12
12
import { LocaleService , ILocaleService } from 'mo/i18n' ;
13
- import { STORE_KEY } from 'mo/i18n/localeService' ;
13
+ import { STORE_KEY , DEFAULT_LOCALE_ID } from 'mo/i18n/localeService' ;
14
14
import { IMonacoService , MonacoService } from 'mo/monaco/monacoService' ;
15
15
import { ILayoutService , LayoutService } from 'mo/services' ;
16
16
import * as controllers from 'mo/controller' ;
@@ -81,14 +81,22 @@ export class MoleculeProvider extends Component<IMoleculeProps> {
81
81
}
82
82
83
83
initLocaleExts ( languages : IExtension [ ] ) {
84
- const { defaultLocale = BuiltInDefault } = this . props ;
84
+ const { defaultLocale = BuiltInId } = this . props ;
85
85
86
86
this . extensionService . load ( languages ) ;
87
87
88
88
// And Molecule should set the correct locale before loading normal extensions in case of
89
89
// the localize method returns incorrect international text caused by incorrect current locale in the normal extensions
90
90
const currentLocale = localStorage . getItem ( STORE_KEY ) || defaultLocale ;
91
- this . localeService . setCurrentLocale ( currentLocale ) ;
91
+ const preDefaultLocale = localStorage . getItem ( DEFAULT_LOCALE_ID ) ;
92
+ let finalLocale = currentLocale ;
93
+
94
+ if ( defaultLocale !== preDefaultLocale ) {
95
+ finalLocale = defaultLocale ;
96
+ }
97
+
98
+ this . localeService . setCurrentLocale ( finalLocale ) ;
99
+ localStorage . setItem ( DEFAULT_LOCALE_ID , defaultLocale ) ;
92
100
}
93
101
94
102
/**
0 commit comments