From 0325ddee7f8a131a845efb0bbf6f8d72dfdcdbfd Mon Sep 17 00:00:00 2001 From: Wankko Ree Date: Sat, 27 Jul 2024 04:41:34 +0800 Subject: [PATCH] feat: custom file language property --- README.md | 1 + src/bld.js | 9 ++++----- src/index.d.ts | 2 ++ src/util.js | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 770cda73..7d4b7e3e 100644 --- a/README.md +++ b/README.md @@ -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`) diff --git a/src/bld.js b/src/bld.js index be185f99..2c3d2a02 100644 --- a/src/bld.js +++ b/src/bld.js @@ -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 */ /** @@ -317,8 +318,6 @@ 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); @@ -326,15 +325,15 @@ const setWinConfig = async ({ app, outDir }) => { 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); diff --git a/src/index.d.ts b/src/index.d.ts index ce4855b4..4f248177 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -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 diff --git a/src/util.js b/src/util.js index 1b8bd5cd..7c57690c 100644 --- a/src/util.js +++ b/src/util.js @@ -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") {