44 *--------------------------------------------------------------------------------------------*/
55
66var path = require ( 'path' ) ;
7+ var fs = require ( 'fs' ) ;
8+ var app = require ( 'electron' ) . app ;
79var loader = require ( './vs/loader' ) ;
810
9- // Duplicated in ../index.html for the renderes.
10- function getNLSConfiguration ( ) {
11- if ( process . env [ 'VSCODE_NLS_CONFIG' ] ) {
12- return JSON . parse ( process . env [ 'VSCODE_NLS_CONFIG' ] ) ;
13- }
14-
15- var locale = undefined ;
16- var localeOpts = '--locale' ;
17- for ( var i = 0 ; i < process . argv . length ; i ++ ) {
18- var arg = process . argv [ i ] ;
19- if ( arg . slice ( 0 , localeOpts . length ) == localeOpts ) {
20- var segments = arg . split ( '=' ) ;
21- locale = segments [ 1 ] ;
22- break ;
23- }
24- }
25-
26- if ( locale === 'pseudo' ) {
27- return { availableLanguages : { } , pseudo : true }
28- }
29- if ( process . env . VSCODE_DEV ) {
30- return { availableLanguages : { } } ;
31- }
32- // We have a built version so we have extracted nls file. Try to find
33- // the right file to use.
34- locale = locale || app . getLocale ( ) ;
35- while ( locale ) {
36- var candidate = path . join ( __dirname , 'main.nls.' ) + locale + '.js' ;
37- if ( fs . existsSync ( candidate ) ) {
38- return { availableLanguages : { '*' : locale } } ;
39- } else {
40- var index = locale . lastIndexOf ( '-' ) ;
41- if ( index > 0 ) {
42- locale = locale . substring ( 0 , index ) ;
43- } else {
44- locale = null ;
45- }
46- }
47- }
48-
49- return { availableLanguages : { } } ;
50- }
51-
5211function uriFromPath ( _path ) {
5312 var pathName = path . resolve ( _path ) . replace ( / \\ / g, '/' ) ;
5413
@@ -59,8 +18,8 @@ function uriFromPath(_path) {
5918 return encodeURI ( 'file://' + pathName ) ;
6019}
6120
62- var nlsConfig = getNLSConfiguration ( ) ;
63- process . env [ 'VSCODE_NLS_CONFIG' ] = JSON . stringify ( nlsConfig ) ;
21+ var rawNlsConfig = process . env [ 'VSCODE_NLS_CONFIG' ] ;
22+ var nlsConfig = rawNlsConfig ? JSON . parse ( rawNlsConfig ) : { availableLanguages : { } } ;
6423
6524loader . config ( {
6625 baseUrl : uriFromPath ( path . join ( __dirname ) ) ,
0 commit comments