Skip to content

Commit

Permalink
Merge pull request #734 from xinyii/dev
Browse files Browse the repository at this point in the history
support setting the installer language
  • Loading branch information
Tlntin authored Jun 24, 2024
2 parents 6297568 + b3a7f70 commit e376652
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 1 deletion.
8 changes: 8 additions & 0 deletions bin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ Specify the system tray icon. This is only effective when the system tray is ena
--system-tray-icon <path>
```

#### [installer-language]

Set the Windows Installer language. Options include `zh-CN`, `ja-JP`, More at [Tauri Document](https://tauri.app/zh-cn/v1/guides/building/windows/#internationalization). Default is `en-US`.

```shell
--installer-language <language>
```

#### [use-local-file]

Enable recursive copying. When the URL is a local file path, enabling this option will copy the folder containing the file specified in the URL, as well as all sub-files, to the Pake static folder. This is disabled by default.
Expand Down
8 changes: 8 additions & 0 deletions bin/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ Linux,默认为 `all`。
--system-tray-icon <path>
```

#### [installer-language]

设置 Windows 安装包语言。支持 `zh-CN``ja-JP`,更多在 [Tauri 文档](https://tauri.app/zh-cn/v1/guides/building/windows/#internationalization)。默认为 `en-US`

```shell
--installer-language <language>
```

#### [use-local-file]

`url` 为本地文件路径时,如果启用此选项,则会递归地将 `url` 路径文件所在的文件夹及其所有子文件复
Expand Down
3 changes: 3 additions & 0 deletions bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ program
.addOption(
new Option('--system-tray-icon <string>', 'Custom system tray icon').default(DEFAULT.systemTrayIcon).hideHelp(),
)
.addOption(
new Option('--installer-language <string>', 'Installer language').default(DEFAULT.installerLanguage).hideHelp(),
)
.version(packageJson.version, '-v, --version', 'Output the current version')
.action(async (url: string, options: PakeCliOptions) => {
await checkUpdateTips();
Expand Down
1 change: 1 addition & 0 deletions bin/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
debug: false,
inject: [],
safeDomain: [],
installerLanguage: 'en-US',
};

// Just for cli development
Expand Down
4 changes: 4 additions & 0 deletions bin/helpers/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
resizable = true,
inject,
safeDomain,
installerLanguage,
} = options;

const { platform } = process;
Expand All @@ -44,6 +45,9 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon

tauriConf.package.productName = name;
tauriConf.tauri.bundle.identifier = identifier;
if (platform == "win32") {
tauriConf.tauri.bundle.windows.wix.language[0] = installerLanguage;
}

//Judge the type of URL, whether it is a file or a website.
const pathExists = await fsExtra.pathExists(url);
Expand Down
3 changes: 3 additions & 0 deletions bin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export interface PakeCliOptions {

/* the domain that can use ipc or tauri javascript sdk */
safeDomain: string[];

// Installer language, valid for Windows users, default is en-US
installerLanguage: string;
}

export interface PakeAppOptions extends PakeCliOptions {
Expand Down
7 changes: 6 additions & 1 deletion dist/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ async function combineFiles(files, output) {
}

async function mergeConfig(url, options, tauriConf) {
const { width, height, fullscreen, hideTitleBar, alwaysOnTop, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, safeDomain, } = options;
const { width, height, fullscreen, hideTitleBar, alwaysOnTop, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, safeDomain, installerLanguage, } = options;
const { platform } = process;
// Set Windows parameters.
const tauriConfWindowOptions = {
Expand All @@ -492,6 +492,9 @@ async function mergeConfig(url, options, tauriConf) {
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
tauriConf.package.productName = name;
tauriConf.tauri.bundle.identifier = identifier;
if (platform == "win32") {
tauriConf.tauri.bundle.windows.wix.language[0] = installerLanguage;
}
//Judge the type of URL, whether it is a file or a website.
const pathExists = await fsExtra.pathExists(url);
if (pathExists) {
Expand Down Expand Up @@ -845,6 +848,7 @@ const DEFAULT_PAKE_OPTIONS = {
debug: false,
inject: [],
safeDomain: [],
installerLanguage: 'en-US',
};

async function checkUpdateTips() {
Expand Down Expand Up @@ -1041,6 +1045,7 @@ program
.hideHelp())
.addOption(new Option('--show-system-tray', 'Show system tray in app').default(DEFAULT_PAKE_OPTIONS.showSystemTray).hideHelp())
.addOption(new Option('--system-tray-icon <string>', 'Custom system tray icon').default(DEFAULT_PAKE_OPTIONS.systemTrayIcon).hideHelp())
.addOption(new Option('--installer-language <string>', 'Installer language').default(DEFAULT_PAKE_OPTIONS.installerLanguage).hideHelp())
.version(packageJson.version, '-v, --version', 'Output the current version')
.action(async (url, options) => {
await checkUpdateTips();
Expand Down

0 comments on commit e376652

Please sign in to comment.