Skip to content

Commit

Permalink
feat: custom file language property
Browse files Browse the repository at this point in the history
  • Loading branch information
WankkoRee committed Jul 26, 2024
1 parent d7b6055 commit 0325dde
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ This object defines additional properties used for building for a specific platf
| `productName` | `string` | Matches the package name defined in app's `package.json` | Name of the product with which the file is distributed. This string is required. |
| `productVersion` | `string` | Value of `version` in app's `package.json` | Version of the product with which the file is distributed—for example, 3.10 or 5.00.RC2. |
| `specialBuild` | `string` | `undefined` | Text that specifies how this version of the file differs from the standard version—for example, Private build for TESTER1 solving mouse problems on M250 and M250E computers. |
| `languageCode` | `number` | `1033` | Language of the file, defined by Microsoft, see: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a |

#### Linux-specific options (`LinuxRc`)

Expand Down
9 changes: 4 additions & 5 deletions src/bld.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import util from "./util.js";
* @property {string} productName Name of the product with which the file is distributed. This string is required.
* @property {string} productVersion Version of the product with which the file is distributed—for example, 3.10 or 5.00.RC2. This string is required.
* @property {string} specialBuild Text that specifies how this version of the file differs from the standard version—for example, Private build for TESTER1 solving mouse problems on M250 and M250E computers. This string should be present only if VS_FF_SPECIALBUILD is specified in the fileflags parameter of the root block.
* @property {string} languageCode Language of the file, defined by Microsoft, see: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a
*/

/**
Expand Down Expand Up @@ -317,24 +318,22 @@ const setWinConfig = async ({ app, outDir }) => {
await fs.promises.rename(path.resolve(outDir, "nw.exe"), outDirAppExe);
const exe = peLibrary.NtExecutable.from(await fs.promises.readFile(outDirAppExe));
const res = peLibrary.NtExecutableResource.from(exe);
// English (United States)
const EN_US = 1033;
if (app.icon) {
const iconBuffer = await fs.promises.readFile(path.resolve(app.icon));
const iconFile = resedit.Data.IconFile.from(iconBuffer);
resedit.Resource.IconGroupEntry.replaceIconsForResource(
res.entries,
// This is the name of the icon group nw.js uses that gets shown in file exlorers
'IDR_MAINFRAME',
EN_US,
app.languageCode,
iconFile.icons.map(i => i.data)
);
}
const [vi] = resedit.Resource.VersionInfo.fromEntries(res.entries);
const [major, minor, micro, revision] = app.fileVersion.split(".");
vi.setFileVersion(major, minor, micro, revision, EN_US);
vi.setFileVersion(major, minor, micro, revision, app.languageCode);
vi.setStringValues({
lang: EN_US,
lang: app.languageCode,
codepage: 1200
}, versionString);
vi.outputToResourceEntries(res.entries);
Expand Down
2 changes: 2 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export interface WindowsAppOptions {
productVersion: string,
/** Text that specifies how this version of the file differs from the standard version—for example, Private build for TESTER1 solving mouse problems on M250 and M250E computers. This string should be present only if VS_FF_SPECIALBUILD is specified in the fileflags parameter of the root block. */
specialBuild?: string,
/** Language of the file, defined by Microsoft, see: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a */
languageCode?: number,
}

/** Linux configuration options
Expand Down
1 change: 1 addition & 0 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export const parse = async (options, pkg) => {
options.app.productName = options.app.productName ?? pkg.name;
options.app.productVersion = options.app.productVersion ?? pkg.version;
options.app.specialBuild = options.app.specialBuild ?? undefined;
options.app.languageCode = options.app.languageCode ?? 1033;
}

if (options.platform === "osx") {
Expand Down

0 comments on commit 0325dde

Please sign in to comment.