@@ -513,11 +513,11 @@ private Map<String, String> prepareMainProjectFile(
513
513
}
514
514
515
515
// Copy standard l10n files.
516
- for (String loc : Arrays .asList ("en" , "ja" , "zh_CN" )) {
516
+ for (String loc : Arrays .asList ("de" , " en" , "ja" , "zh_CN" )) {
517
517
String fname = "MsiInstallerStrings_" + loc + ".wxl" ;
518
- try ( InputStream is = OverridableResource . readDefault ( fname )) {
519
- Files . copy ( is , CONFIG_ROOT . fetchFrom ( params ). resolve ( fname ));
520
- }
518
+ createResource ( fname , params )
519
+ . setCategory ( I18N . getString ( "resource.wxl-file" ))
520
+ . saveToFile ( configDir . resolve ( fname ));
521
521
}
522
522
523
523
createResource ("main.wxs" , params )
@@ -563,16 +563,36 @@ private Path buildMSI(Map<String, ? super Object> params,
563
563
wixPipeline .addLightOptions ("-sice:ICE91" );
564
564
}
565
565
566
- final Path primaryWxlFile = CONFIG_ROOT .fetchFrom (params ).resolve (
567
- I18N .getString ("resource.wxl-file-name" )).toAbsolutePath ();
568
-
569
- wixPipeline .addLightOptions ("-loc" , primaryWxlFile .toString ());
566
+ // Filter out custom l10n files that were already used to
567
+ // override primary l10n files. Ignore case filename comparison,
568
+ // both lists are expected to be short.
569
+ List <Path > primaryWxlFiles = getWxlFilesFromDir (params , CONFIG_ROOT );
570
+ List <Path > customWxlFiles = getWxlFilesFromDir (params , RESOURCE_DIR ).stream ()
571
+ .filter (custom -> primaryWxlFiles .stream ().noneMatch (primary ->
572
+ primary .getFileName ().toString ().equalsIgnoreCase (
573
+ custom .getFileName ().toString ())))
574
+ .peek (custom -> Log .verbose (MessageFormat .format (
575
+ I18N .getString ("message.using-custom-resource" ),
576
+ String .format ("[%s]" , I18N .getString ("resource.wxl-file" )),
577
+ custom .getFileName ().toString ())))
578
+ .toList ();
579
+
580
+ // All l10n files are supplied to WiX with "-loc", but only
581
+ // Cultures from custom files and a single primary Culture are
582
+ // included into "-cultures" list
583
+ for (var wxl : primaryWxlFiles ) {
584
+ wixPipeline .addLightOptions ("-loc" , wxl .toAbsolutePath ().normalize ().toString ());
585
+ }
570
586
571
587
List <String > cultures = new ArrayList <>();
572
- for (var wxl : getCustomWxlFiles ( params ) ) {
573
- wixPipeline .addLightOptions ("-loc" , wxl .toAbsolutePath ().toString ());
588
+ for (var wxl : customWxlFiles ) {
589
+ wixPipeline .addLightOptions ("-loc" , wxl .toAbsolutePath ().normalize (). toString ());
574
590
cultures .add (getCultureFromWxlFile (wxl ));
575
591
}
592
+
593
+ // Append a primary culture bases on runtime locale.
594
+ final Path primaryWxlFile = CONFIG_ROOT .fetchFrom (params ).resolve (
595
+ I18N .getString ("resource.wxl-file-name" ));
576
596
cultures .add (getCultureFromWxlFile (primaryWxlFile ));
577
597
578
598
// Build ordered list of unique cultures.
@@ -586,18 +606,18 @@ private Path buildMSI(Map<String, ? super Object> params,
586
606
return msiOut ;
587
607
}
588
608
589
- private static List <Path > getCustomWxlFiles (Map <String , ? super Object > params )
590
- throws IOException {
591
- Path resourceDir = RESOURCE_DIR .fetchFrom (params );
592
- if (resourceDir == null ) {
609
+ private static List <Path > getWxlFilesFromDir (Map <String , ? super Object > params ,
610
+ StandardBundlerParam < Path > pathParam ) throws IOException {
611
+ Path dir = pathParam .fetchFrom (params );
612
+ if (dir == null ) {
593
613
return Collections .emptyList ();
594
614
}
595
615
596
616
final String glob = "glob:**/*.wxl" ;
597
617
final PathMatcher pathMatcher = FileSystems .getDefault ().getPathMatcher (
598
618
glob );
599
619
600
- try (var walk = Files .walk (resourceDir , 1 )) {
620
+ try (var walk = Files .walk (dir , 1 )) {
601
621
return walk
602
622
.filter (Files ::isReadable )
603
623
.filter (pathMatcher ::matches )
0 commit comments