@@ -9,7 +9,7 @@ import { safeLoad } from "js-yaml"
9
9
import * as path from "path"
10
10
import sanitizeFileName from "sanitize-filename"
11
11
import { v5 as uuid5 } from "uuid-1345"
12
- import { NsisOptions } from "../options/winOptions"
12
+ import { NsisOptions , PortableOptions } from "../options/winOptions"
13
13
import { normalizeExt } from "../platformPackager"
14
14
import { getSignVendorPath } from "../windowsCodeSign"
15
15
import { WinPackager } from "../winPackager"
@@ -154,7 +154,10 @@ export default class NsisTarget extends Target {
154
154
}
155
155
156
156
this . configureDefinesForAllTypeOfInstaller ( defines )
157
- if ( ! isPortable ) {
157
+ if ( isPortable ) {
158
+ defines . REQUEST_EXECUTION_LEVEL = ( < PortableOptions > options ) . requestExecutionLevel || "user"
159
+ }
160
+ else {
158
161
await this . configureDefines ( oneClick , defines )
159
162
}
160
163
@@ -375,31 +378,16 @@ export default class NsisTarget extends Target {
375
378
scriptHeader += createMacro ( "licensePage" , licensePage )
376
379
}
377
380
378
- const messages = safeLoad ( await readFile ( path . join ( __dirname , ".." , ".." , "templates" , "nsis" , "messages.yml" ) , "utf-8" ) )
379
- const langs : Array < string > = [ ]
380
- for ( const messageId of Object . keys ( messages ) ) {
381
- const langToTranslations = messages [ messageId ]
382
- const unspecifiedLangs = new Set ( bundledLanguages )
383
- for ( const lang of Object . keys ( langToTranslations ) ) {
384
- const langWithRegion = toLangWithRegion ( lang )
385
- langs . push ( `LangString ${ messageId } ${ lcid [ langWithRegion ] } "${ langToTranslations [ lang ] . replace ( / \n / g, "$\\r$\\n" ) } "` )
386
- unspecifiedLangs . delete ( langWithRegion )
387
- }
388
-
389
- const defaultTranslation = langToTranslations [ "en" ] . replace ( / \n / g, "$\\r$\\n" )
390
- for ( const langWithRegion of unspecifiedLangs ) {
391
- langs . push ( `LangString ${ messageId } ${ lcid [ langWithRegion ] } "${ defaultTranslation } "` )
392
- }
393
- }
394
-
395
- if ( langs . length > 0 ) {
396
- scriptHeader += "\n" + langs . join ( "\n" ) + "\n\n"
397
- }
381
+ scriptHeader += "\n" + computeCustomMessageTranslations ( safeLoad ( await readFile ( path . join ( this . nsisTemplatesDir , "messages.yml" ) , "utf-8" ) ) ) . join ( "\n" ) + "\n\n"
398
382
399
383
if ( this . isPortable ) {
400
384
return scriptHeader + originalScript
401
385
}
402
386
387
+ if ( this . options . oneClick === false ) {
388
+ scriptHeader += "\n" + computeCustomMessageTranslations ( safeLoad ( await readFile ( path . join ( this . nsisTemplatesDir , "boringMessages.yml" ) , "utf-8" ) ) ) . join ( "\n" ) + "\n\n"
389
+ }
390
+
403
391
const customInclude = await packager . getResource ( this . options . include , "installer.nsh" )
404
392
if ( customInclude != null ) {
405
393
scriptHeader += `!addincludedir "${ packager . buildResourcesDir } "\n`
@@ -504,6 +492,25 @@ export default class NsisTarget extends Target {
504
492
}
505
493
}
506
494
495
+ function computeCustomMessageTranslations ( messages : any ) : Array < string > {
496
+ const result : Array < string > = [ ]
497
+ for ( const messageId of Object . keys ( messages ) ) {
498
+ const langToTranslations = messages [ messageId ]
499
+ const unspecifiedLangs = new Set ( bundledLanguages )
500
+ for ( const lang of Object . keys ( langToTranslations ) ) {
501
+ const langWithRegion = toLangWithRegion ( lang )
502
+ result . push ( `LangString ${ messageId } ${ lcid [ langWithRegion ] } "${ langToTranslations [ lang ] . replace ( / \n / g, "$\\r$\\n" ) } "` )
503
+ unspecifiedLangs . delete ( langWithRegion )
504
+ }
505
+
506
+ const defaultTranslation = langToTranslations [ "en" ] . replace ( / \n / g, "$\\r$\\n" )
507
+ for ( const langWithRegion of unspecifiedLangs ) {
508
+ result . push ( `LangString ${ messageId } ${ lcid [ langWithRegion ] } "${ defaultTranslation } "` )
509
+ }
510
+ }
511
+ return result
512
+ }
513
+
507
514
function toLangWithRegion ( lang : string ) : string {
508
515
let langWithRegion = langToLangWithRegion . get ( lang )
509
516
if ( langWithRegion == null ) {
0 commit comments