Skip to content

Commit

Permalink
fix nwutils#315: macPlistStrings added to config
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaroslav Nazarov authored and flohdot committed May 30, 2016
1 parent 1385605 commit a12eb03
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ Default value: `false`

MAC ONLY: Pass a string containing the path to your own plist file. If a string isn't passed, a plist file will be generated from your package.json. Pass an object to overwrite or add properties to the generated plist file.

#### options.macPlistStrings
Type: `Object`
Default value: `{}`

MAC ONLY: Pass an object where keys are laungauge abbreviations and values are the strings containing path to the localization file. If passed, these files will replace plistInfo.strings files for each passed language.

#### options.winIco
Type: `String`
Default value: `null`
Expand Down
22 changes: 22 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function NwBuilder(options) {
macZip: null,
zip: null,
macPlist: false,
macPlistStrings: {},
winIco: null,
argv: process.argv.slice(2)
};
Expand Down Expand Up @@ -549,6 +550,27 @@ NwBuilder.prototype.handleMacApp = function () {

allDone.push(Utils.editPlist(PlistPath, PlistPath, plistOptions));
}

// Let's handle Plist localization files
for (l18n in self.options.macPlistStrings) {
// Plist localization name and value should be strings
if (typeof l18n === 'string') {
if (typeof self.options.macPlistStrings[l18n] === 'string') {
var l18lFolder = path.resolve(platform.releasePath, self.options.appName+'.app', 'Contents', 'Resources', l18n+'.lproj');
// The folder may not exist
if (!fs.existsSync(l18lFolder)) {
fs.mkdirSync(l18lFolder);
}

var l18lpath = path.resolve(l18lFolder, 'InfoPlist.strings');
allDone.push(Utils.copyFile(self.options.macPlistStrings[l18n], l18lpath, self));
} else {
reject('Path to the localization file is not a string');
}
} else {
reject('Name of the localization is not a string');
}
}
});

return Promise.all(allDone);
Expand Down

0 comments on commit a12eb03

Please sign in to comment.