File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ const AUTHORITY = process.env.VSCODE_AUTHORITY || `${HOST}:${PORT}`;
58
58
59
59
const exists = ( path ) => util . promisify ( fs . exists ) ( path ) ;
60
60
const readFile = ( path ) => util . promisify ( fs . readFile ) ( path ) ;
61
+ const CharCode_PC = '%' . charCodeAt ( 0 ) ;
61
62
62
63
async function initialize ( ) {
63
64
const extensionFolders = await util . promisify ( fs . readdir ) ( EXTENSIONS_ROOT ) ;
@@ -95,6 +96,26 @@ async function initialize() {
95
96
}
96
97
}
97
98
99
+ const packageNlsPath = path . join ( EXTENSIONS_ROOT , extensionFolder , 'package.nls.json' ) ;
100
+ if ( await exists ( packageNlsPath ) ) {
101
+ const packageNls = JSON . parse ( ( await readFile ( packageNlsPath ) ) . toString ( ) ) ;
102
+ const translate = ( obj ) => {
103
+ for ( let key in obj ) {
104
+ const val = obj [ key ] ;
105
+ if ( Array . isArray ( val ) ) {
106
+ val . forEach ( translate ) ;
107
+ } else if ( val && typeof val === 'object' ) {
108
+ translate ( val ) ;
109
+ } else if ( typeof val === 'string' && val . charCodeAt ( 0 ) === CharCode_PC && val . charCodeAt ( val . length - 1 ) === CharCode_PC ) {
110
+ const translated = packageNls [ val . substr ( 1 , val . length - 2 ) ] ;
111
+ if ( translated ) {
112
+ obj [ key ] = translated ;
113
+ }
114
+ }
115
+ }
116
+ } ;
117
+ translate ( packageJSON ) ;
118
+ }
98
119
packageJSON . extensionKind = [ 'web' ] ; // enable for Web
99
120
staticExtensions . push ( {
100
121
packageJSON,
You can’t perform that action at this time.
0 commit comments