Skip to content

Commit cc1dca5

Browse files
committed
Add multilingual support
1 parent 0f78e00 commit cc1dca5

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
可以列出当前桌面正在显示的进程列表,并将选中的进程、游戏窗口转换为无边框全屏或顶置
1+
A command-line tool,it is possible to list the processes currently displayed on the current desktop and convert the selected processes and game windows to borderless full screen or topmost.
22

3-
It is possible to list the processes currently displayed on the current desktop and convert the selected processes and game windows to borderless full screen or topmost.
3+
一个命令行工具,可以列出当前桌面正在显示的进程列表,并将选中的进程、游戏窗口转换为无边框全屏或顶置.
44

55
現在のデスクトップに表示されているプロセスのリストを表示でき、選択されたプロセスやゲームウィンドウを枠なしの全画面または最前面表示に変換できます。

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use windows::Win32::Foundation::HWND;
22

33

44
mod utils;
5-
pub struct window_controller;
6-
impl window_controller{
5+
pub struct WindowController;
6+
impl WindowController {
77
pub fn frameless(hwnd: HWND){
88
utils::controller::frameless(hwnd)
99
}

src/main.rs

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use clap::Parser;
22
use inquire::{Select};
33
use std::collections::HashMap;
4-
use windows::core::*;
5-
64
use windows::{
75
core::{
86
PCWSTR,
@@ -24,7 +22,6 @@ use windows::Win32::Foundation::{
2422
HWND,
2523
BOOL,
2624
};
27-
use windows::Win32::UI::WindowsAndMessaging::{GetWindowLongA, GWL_STYLE};
2825

2926
#[derive(Parser, Debug)]
3027
#[command(version, about, long_about = None)]
@@ -55,32 +52,40 @@ extern "system" fn enum_window(window: HWND, _: LPARAM) -> BOOL {
5552
}
5653

5754
fn main() {
55+
let binding = std::env::var("LANG").unwrap();
56+
let mut os_lang = binding.as_str().split(".").collect::<Vec<_>>()[0];
57+
let lang_eunm: HashMap<&str, [&str; 6]> = HashMap::from([
58+
("zh_CN", ["全屏无边框","顶置","选择窗口","选择模式","方向键切换/enter选择","There was an error, please try again"]),
59+
("en_US", ["Full screen without borders", "Top placement","Select window", "Selection mode", "Direction key switching/enter selection","There was an error, please try again"]),
60+
("ja_JP", ["全画面ボーダレス","最前面表示","ウィンドウを選択する","選択モード","矢印キーで切り替え / エンターキーで選択","There was an error, please try again"]),
61+
]);
62+
if !lang_eunm.contains_key(os_lang){
63+
os_lang = "en_US"
64+
}
5865
unsafe {
5966
EnumWindows(Some(enum_window), LPARAM(0));
6067
}
6168
let mut mode_eunm: HashMap<&str, fn( HWND)> = HashMap::new();
62-
mode_eunm.insert("全屏无边框",utils::controller::frameless);
63-
mode_eunm.insert("顶置", utils::controller::overhead);
64-
let mut title: &str = "";
69+
mode_eunm.insert(lang_eunm[os_lang][0],utils::controller::frameless);
70+
mode_eunm.insert(lang_eunm[os_lang][1], utils::controller::overhead);
6571
let args = Args::parse();
66-
let options: Vec<&str> = vec!["全屏无边框", "顶置"];
72+
let options: Vec<&str> = vec![lang_eunm[os_lang][0], lang_eunm[os_lang][1]];
6773
let mut o: Vec<&str> = vec![];
6874
unsafe {
6975
for i in 0..PROCESS.len() {
7076
o.push(PROCESS[i].as_str());
7177
}
7278
}
79+
let mut title: &str = "";
7380
if args.title == "" {
74-
title = Select::new("选择窗口", o).prompt().unwrap();
81+
title = Select::new(lang_eunm[os_lang][2], o).prompt().unwrap();
7582
} else {
7683
title = &*args.title
7784
}
78-
let mut ans: Select<&str> = Select::new("选择模式", options);
79-
ans.help_message = Option::from("方向键切换/enter选择");
85+
let mut ans: Select<&str> = Select::new(lang_eunm[os_lang][3], options);
86+
ans.help_message = Option::from(lang_eunm[os_lang][4]);
8087
unsafe {
8188
let hwnd = FindWindowW(None, PCWSTR(HSTRING::from(title).as_ptr()));
82-
let style = GetWindowLongA(hwnd, GWL_STYLE);
83-
println!("{}", style);
8489
if args.mode!="" {
8590
mode_eunm[args.mode.as_str()](hwnd)
8691
} else {

target/release/window-controller.exe

12 KB
Binary file not shown.

0 commit comments

Comments
 (0)