Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 235 additions & 0 deletions README.es.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

**Rust で書かれた Windows シェル: 標準のものより高速で軽量です。** Windows の一部を置き換える小さなネイティブ プログラム群 (.NET も Electron も不要): タスクバー、エクスプローラー、ファイル検索、タスク マネージャー、さらにディスク クリーナー、ディスク マップ、フォト ビューアー。インストーラー 1 つで導入でき、ボタン 1 つですべて元に戻せます。

[English](README.md) | [Русский](README.ru.md) | 日本語 | [Português (Brasil)](README.pt-BR.md) | [简体中文](README.zh.md)
[English](README.md) | [Русский](README.ru.md) | 日本語 | [Português (Brasil)](README.pt-BR.md) | [简体中文](README.zh.md) | [Español](README.es.md)

<p align="center">
<a href="https://github.com/Lemxy/WinRust/releases/latest"><img src="https://img.shields.io/github/v/release/Lemxy/WinRust?style=for-the-badge&logo=github&label=release&color=B7410E" alt="Latest release"></a>
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<a href="https://discord.gg/5H4r7kBsxP">Discord</a>
</p>

<p align="center">English | <a href="README.ru.md">Русский</a> | <a href="README.ja.md">日本語</a> | <a href="README.pt-BR.md">Português (Brasil)</a> | <a href="README.zh.md">简体中文</a></p>
<p align="center">English | <a href="README.ru.md">Русский</a> | <a href="README.ja.md">日本語</a> | <a href="README.pt-BR.md">Português (Brasil)</a> | <a href="README.zh.md">简体中文</a> | <a href="README.es.md">Español</a></p>

![The WinRust bar with its settings menu, Ruby theme](docs/screenshots/taskbar.webp)

Expand All @@ -43,7 +43,7 @@
</tr>
<tr>
<td width="33%" valign="top">↩️ <b>Reversible</b><br>Every value is saved before it is changed and put back on uninstall. One button removes everything.</td>
<td width="33%" valign="top">🎨 <b>Yours</b><br>Eight styles (Ruby, Terminal, Floating dock, Windows 98 and more), any colour, the bar on any edge, English, Русский, 日本語 or Português.</td>
<td width="33%" valign="top">🎨 <b>Yours</b><br>Eight styles (Ruby, Terminal, Floating dock, Windows 98 and more), any colour, the bar on any edge, English, Русский, 日本語, Português, 简体中文 or Español.</td>
<td width="33%" valign="top">💬 <b>Together</b><br>Help, ideas and setups in English and Russian on <a href="https://discord.gg/5H4r7kBsxP">Discord</a>.</td>
</tr>
</table>
Expand Down Expand Up @@ -74,7 +74,7 @@ If UAC asks for **another administrator's** password, the per-user settings (sta

**Manual update:** download the new `WinRust.exe` from the releases page, run it as administrator and press **Update** on the Express card (it reinstalls what is installed and adds what is missing), or use Custom. An existing `rust-explorer` stays ticked. Your settings and the saved original Windows values stay.

The installer is in English. Its corner holds a language drop-down — English, Русский, 日本語, Português (Brasil), 简体中文; the same list sits behind the gear on the bar (**Bar settings → Language**), and rust-settings has it on its Personalization page (**Interface language**). The choice is stored in `%ProgramData%\WinRust\lang.txt` (`en`, `ru`, `ja`, `pt`, `zh`); every running WinRust program switches within a second, no restart needed (a window that builds some texts when it opens, such as menus or column headers, shows those in the new language the next time it opens).
The installer is in English. Its corner holds a language drop-down — English, Русский, 日本語, Português (Brasil), 简体中文, Español; the same list sits behind the gear on the bar (**Bar settings → Language**), and rust-settings has it on its Personalization page (**Interface language**). The choice is stored in `%ProgramData%\WinRust\lang.txt` (`en`, `ru`, `ja`, `pt`, `zh`, `es`); every running WinRust program switches within a second, no restart needed (a window that builds some texts when it opens, such as menus or column headers, shows those in the new language the next time it opens).

## Remove

Expand Down Expand Up @@ -174,7 +174,7 @@ src/ the installer (plugin-launcher.exe)
main.rs the plugin table PLUGINS: name, texts, install/uninstall pair, icon
install/ what each plugin changes and how it is undone (one file per plugin)
cli.rs, ui.rs the command line and the window; both call the same install functions
common/ winrust-common: language switch (t!/tf!: English, Russian, Japanese, Brazilian Portuguese), UI styles and palettes, reg.exe output parser, NTFS MFT reader
common/ winrust-common: language switch (t!/tf!: English, Russian, Japanese, Brazilian Portuguese, Simplified Chinese, Spanish), UI styles and palettes, reg.exe output parser, NTFS MFT reader
plugins/ sources of every plugin, each its own crate
ReShell/ reshell (desktop hotkeys, topbar safety net), ships with topbar
payload.txt the exes embedded into the installer, and where the build puts them
Expand All @@ -184,7 +184,7 @@ scripts/ build, update, release
Everything is one cargo workspace (one `Cargo.lock`, every exe in `target\release`). `plugins/rust-search` and `plugins/chrome-rs` build separately because they need `panic = "unwind"` (see `Cargo.toml`).

### Adding a language
`t!("русский", "english", ja: "日本語", pt: "português", zh: "中文")` and `tf!(…)` return each text in the current language (without `ja:`/`pt:`/`zh:` those languages show the English one). The languages are the `Lang` enum in `common/src/lib.rs`.
`t!("русский", "english", ja: "日本語", pt: "português", zh: "中文", es: "español")` and `tf!(…)` return each text in the current language (without `ja:`/`pt:`/`zh:`/`es:` those languages show the English one). The languages are the `Lang` enum in `common/src/lib.rs`.

### Build
Needs Windows x64, Rust stable (1.85+) with the MSVC toolchain.
Expand Down
2 changes: 1 addition & 1 deletion README.pt-BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

**Um shell do Windows escrito em Rust: mais rápido e mais leve que o original.** Programas nativos pequenos (sem .NET, sem Electron) que substituem partes do Windows: a barra de tarefas, o Explorador de Arquivos, a pesquisa de arquivos, o Gerenciador de Tarefas, além de um limpador de disco, um mapa de disco e um visualizador de fotos. Um instalador coloca tudo, um botão tira tudo.

[English](README.md) | [Русский](README.ru.md) | [日本語](README.ja.md) | Português (Brasil) | [简体中文](README.zh.md)
[English](README.md) | [Русский](README.ru.md) | [日本語](README.ja.md) | Português (Brasil) | [简体中文](README.zh.md) | [Español](README.es.md)

<p align="center">
<a href="https://github.com/Lemxy/WinRust/releases/latest"><img src="https://img.shields.io/github/v/release/Lemxy/WinRust?style=for-the-badge&logo=github&label=release&color=B7410E" alt="Latest release"></a>
Expand Down
2 changes: 1 addition & 1 deletion README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<a href="https://discord.gg/5H4r7kBsxP">Discord</a>
</p>

<p align="center"><a href="README.md">English</a> | <b>Русский</b> | <a href="README.ja.md">日本語</a> | <a href="README.pt-BR.md">Português (Brasil)</a> | <a href="README.zh.md">简体中文</a></p>
<p align="center"><a href="README.md">English</a> | <b>Русский</b> | <a href="README.ja.md">日本語</a> | <a href="README.pt-BR.md">Português (Brasil)</a> | <a href="README.zh.md">简体中文</a> | <a href="README.es.md">Español</a></p>

![Панель WinRust с меню настроек, тема «Рубин»](docs/screenshots/taskbar.webp)

Expand Down
2 changes: 1 addition & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

**用 Rust 编写的 Windows 外壳:比系统自带的更快、更轻。** 一批原生小程序(不用 .NET,不用 Electron)替换掉 Windows 的部件:任务栏、资源管理器、文件搜索、任务管理器,另外还有磁盘清理、磁盘占用图和图片查看器。一个安装程序全部装好,一个按钮全部卸掉。

[English](README.md) | [Русский](README.ru.md) | [日本語](README.ja.md) | [Português (Brasil)](README.pt-BR.md) | **简体中文**
[English](README.md) | [Русский](README.ru.md) | [日本語](README.ja.md) | [Português (Brasil)](README.pt-BR.md) | **简体中文** | [Español](README.es.md)

<p align="center">
<a href="https://github.com/Lemxy/WinRust/releases/latest"><img src="https://img.shields.io/github/v/release/Lemxy/WinRust?style=for-the-badge&logo=github&label=release&color=B7410E" alt="Latest release"></a>
Expand Down
109 changes: 96 additions & 13 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Code shared by the WinRust programs: the language switch (`t!`, `tf!`, `lang!`, `en!`), the NTFS MFT reader, Win+D.
//! Use it with `#[macro_use] extern crate winrust_common;` at the crate root.
//!
//! The language of %ProgramData%\WinRust\lang.txt ("en", "ru", "ja", "pt" or "zh", written by the language list in the
//! The language of %ProgramData%\WinRust\lang.txt ("en", "ru", "ja", "pt", "zh" or "es", written by the language list in the
//! installer and in rust-settings); until one is picked, the Windows display language (English if untranslated).
//! Every program follows a switch live: the file is read again at most once a second, and the switch broadcasts the
//! "style changed" message (`style::msg()`, which makes windows repaint and re-read it at once).
Expand Down Expand Up @@ -59,6 +59,7 @@ pub enum Lang {
Ja,
Pt,
Zh,
Es,
}

impl Lang {
Expand All @@ -70,6 +71,7 @@ impl Lang {
Lang::Ja => "日本語",
Lang::Pt => "Português",
Lang::Zh => "简体中文",
Lang::Es => "Español",
}
}
/// The language after this one: the switch button goes round them.
Expand All @@ -79,20 +81,22 @@ impl Lang {
Lang::Ru => Lang::Ja,
Lang::Ja => Lang::Pt,
Lang::Pt => Lang::Zh,
Lang::Zh => Lang::En,
Lang::Zh => Lang::Es,
Lang::Es => Lang::En,
}
}
fn code(self) -> &'static str {
["en", "ru", "ja", "pt", "zh"][self as usize]
["en", "ru", "ja", "pt", "zh", "es"][self as usize]
}
/// The language of a code or a lang.txt line (`en`, `ru`, `ja`, `pt`, `zh`; `zh-CN` and `zh_CN` work too).
/// The language of a code or a lang.txt line (`en`, `ru`, `ja`, `pt`, `zh`, `es`; `zh-CN` and `zh_CN` work too).
pub fn parse(s: &str) -> Lang {
let s = s.trim().to_ascii_lowercase();
match s.get(..2) {
Some("ru") => Lang::Ru,
Some("ja") => Lang::Ja,
Some("pt") => Lang::Pt,
Some("zh") => Lang::Zh,
Some("es") => Lang::Es,
_ => Lang::En,
}
}
Expand All @@ -116,6 +120,7 @@ pub fn lang() -> Lang {
2 => Lang::Ja,
3 => Lang::Pt,
4 => Lang::Zh,
5 => Lang::Es,
_ => {
let l = file().and_then(|f| std::fs::read_to_string(f).ok()).map_or_else(system_lang, |s| Lang::parse(&s));
LANG.store(l as u8, Relaxed);
Expand All @@ -138,6 +143,7 @@ fn lang_of_langid(id: u16) -> Lang {
0x11 => Lang::Ja,
0x16 => Lang::Pt,
0x04 => Lang::Zh,
0x0A => Lang::Es,
_ => Lang::En,
}
}
Expand All @@ -149,6 +155,8 @@ fn langid_maps_to_ui_language() {
assert_eq!(lang_of_langid(0x0416), Lang::Pt); // pt-BR
assert_eq!(lang_of_langid(0x0816), Lang::Pt); // pt-PT
assert_eq!(lang_of_langid(0x0804), Lang::Zh); // zh-CN
assert_eq!(lang_of_langid(0x0C0A), Lang::Es); // es-ES
assert_eq!(lang_of_langid(0x080A), Lang::Es); // es-MX
assert_eq!(lang_of_langid(0x0409), Lang::En);
assert_eq!(lang_of_langid(0x0405), Lang::En); // cs-CZ: no translation yet
}
Expand Down Expand Up @@ -205,26 +213,55 @@ macro_rules! dot {
};
}

/// `t!("русский", "english", ja: "日本語", pt: "português", zh: "中文")`: a text in the current language.
/// Without `ja:`/`pt:`/`zh:` those languages show the English text.
/// `t!("русский", "english", ja: "日本語", pt: "português", zh: "中文", es: "español")`: a text in the current language.
/// Without `ja:`/`pt:`/`zh:`/`es:` those languages show the English text.
#[macro_export]
macro_rules! t {
($ru:expr, $en:expr, ja: $ja:expr, pt: $pt:expr, zh: $zh:expr, es: $es:expr $(,)?) => {
match $crate::lang!() {
$crate::Lang::Ru => $ru,
$crate::Lang::En => $en,
$crate::Lang::Ja => $ja,
$crate::Lang::Pt => $pt,
$crate::Lang::Zh => $zh,
$crate::Lang::Es => $es,
}
};
($ru:expr, $en:expr, ja: $ja:expr, pt: $pt:expr, zh: $zh:expr $(,)?) => {
match $crate::lang!() {
$crate::Lang::Ru => $ru,
$crate::Lang::En => $en,
$crate::Lang::Ja => $ja,
$crate::Lang::Pt => $pt,
$crate::Lang::Zh => $zh,
$crate::Lang::Es => $en,
}
};
($ru:expr, $en:expr, ja: $ja:expr, pt: $pt:expr $(,)?) => {
($ru:expr, $en:expr, ja: $ja:expr, pt: $pt:expr, es: $es:expr $(,)?) => {
match $crate::lang!() {
$crate::Lang::Ru => $ru,
$crate::Lang::En => $en,
$crate::Lang::Ja => $ja,
$crate::Lang::Pt => $pt,
$crate::Lang::Zh => $en,
$crate::Lang::Es => $es,
}
};
($ru:expr, $en:expr, ja: $ja:expr, pt: $pt:expr $(,)?) => {
match $crate::lang!() {
$crate::Lang::Ru => $ru,
$crate::Lang::En => $en,
$crate::Lang::Ja => $ja,
$crate::Lang::Pt => $pt,
$crate::Lang::Zh | $crate::Lang::Es => $en,
}
};
($ru:expr, $en:expr, zh: $zh:expr, es: $es:expr $(,)?) => {
match $crate::lang!() {
$crate::Lang::Ru => $ru,
$crate::Lang::Zh => $zh,
$crate::Lang::Es => $es,
_ => $en,
}
};
($ru:expr, $en:expr, zh: $zh:expr $(,)?) => {
Expand All @@ -234,31 +271,67 @@ macro_rules! t {
_ => $en,
}
};
($ru:expr, $en:expr, es: $es:expr $(,)?) => {
match $crate::lang!() {
$crate::Lang::Ru => $ru,
$crate::Lang::Es => $es,
_ => $en,
}
};
($ru:expr, $en:expr) => {
if $crate::lang!() == $crate::Lang::Ru { $ru } else { $en }
};
}

/// `tf!("русский {}", "english {}", ja: "日本語 {}", pt: "português {}", zh: "中文 {}", args...)`: format! in the current
/// language (all templates are checked at compile time). Without `ja:`/`pt:`/`zh:` those languages use the English one.
/// `tf!("русский {}", "english {}", ja: "日本語 {}", pt: "português {}", zh: "中文 {}", es: "español {}", args...)`: format! in the current
/// language (all templates are checked at compile time). Without `ja:`/`pt:`/`zh:`/`es:` those languages use the English one.
#[macro_export]
macro_rules! tf {
($ru:literal, $en:literal, ja: $ja:literal, pt: $pt:literal, zh: $zh:literal, es: $es:literal $(, $a:expr)* $(,)?) => {
match $crate::lang!() {
$crate::Lang::Ru => format!($ru $(, $a)*),
$crate::Lang::En => format!($en $(, $a)*),
$crate::Lang::Ja => format!($ja $(, $a)*),
$crate::Lang::Pt => format!($pt $(, $a)*),
$crate::Lang::Zh => format!($zh $(, $a)*),
$crate::Lang::Es => format!($es $(, $a)*),
}
};
($ru:literal, $en:literal, ja: $ja:literal, pt: $pt:literal, zh: $zh:literal $(, $a:expr)* $(,)?) => {
match $crate::lang!() {
$crate::Lang::Ru => format!($ru $(, $a)*),
$crate::Lang::En => format!($en $(, $a)*),
$crate::Lang::Ja => format!($ja $(, $a)*),
$crate::Lang::Pt => format!($pt $(, $a)*),
$crate::Lang::Zh => format!($zh $(, $a)*),
$crate::Lang::Es => format!($en $(, $a)*),
}
};
($ru:literal, $en:literal, ja: $ja:literal, pt: $pt:literal $(, $a:expr)* $(,)?) => {
($ru:literal, $en:literal, ja: $ja:literal, pt: $pt:literal, es: $es:literal $(, $a:expr)* $(,)?) => {
match $crate::lang!() {
$crate::Lang::Ru => format!($ru $(, $a)*),
$crate::Lang::En => format!($en $(, $a)*),
$crate::Lang::Ja => format!($ja $(, $a)*),
$crate::Lang::Pt => format!($pt $(, $a)*),
$crate::Lang::Zh => format!($en $(, $a)*),
$crate::Lang::Es => format!($es $(, $a)*),
}
};
($ru:literal, $en:literal, ja: $ja:literal, pt: $pt:literal $(, $a:expr)* $(,)?) => {
match $crate::lang!() {
$crate::Lang::Ru => format!($ru $(, $a)*),
$crate::Lang::En => format!($en $(, $a)*),
$crate::Lang::Ja => format!($ja $(, $a)*),
$crate::Lang::Pt => format!($pt $(, $a)*),
$crate::Lang::Zh | $crate::Lang::Es => format!($en $(, $a)*),
}
};
($ru:literal, $en:literal, zh: $zh:literal, es: $es:literal $(, $a:expr)* $(,)?) => {
match $crate::lang!() {
$crate::Lang::Ru => format!($ru $(, $a)*),
$crate::Lang::Zh => format!($zh $(, $a)*),
$crate::Lang::Es => format!($es $(, $a)*),
_ => format!($en $(, $a)*),
}
};
($ru:literal, $en:literal, zh: $zh:literal $(, $a:expr)* $(,)?) => {
Expand All @@ -268,6 +341,13 @@ macro_rules! tf {
_ => format!($en $(, $a)*),
}
};
($ru:literal, $en:literal, es: $es:literal $(, $a:expr)* $(,)?) => {
match $crate::lang!() {
$crate::Lang::Ru => format!($ru $(, $a)*),
$crate::Lang::Es => format!($es $(, $a)*),
_ => format!($en $(, $a)*),
}
};
($ru:literal, $en:literal $(, $a:expr)* $(,)?) => {
if $crate::lang!() == $crate::Lang::Ru { format!($ru $(, $a)*) } else { format!($en $(, $a)*) }
};
Expand All @@ -279,8 +359,8 @@ mod tests {
fn tests_run_in_russian() {
assert_eq!(t!("да", "yes"), "да");
assert_eq!(tf!("{} шт", "{} pcs", 3), "3 шт");
assert_eq!(t!("да", "yes", ja: "はい", pt: "sim", zh: "是"), "да");
assert_eq!(tf!("{} шт", "{} pcs", ja: "{} 個", pt: "{} un.", zh: "{} 个", 3), "3 шт");
assert_eq!(t!("да", "yes", ja: "はい", pt: "sim", zh: "是", es: "sí"), "да");
assert_eq!(tf!("{} шт", "{} pcs", ja: "{} 個", pt: "{} un.", zh: "{} 个", es: "{} uds.", 3), "3 шт");
}

#[test]
Expand All @@ -289,7 +369,10 @@ mod tests {
assert_eq!(Lang::parse(" pt-BR "), Lang::Pt);
assert_eq!(Lang::parse("ZH-cn"), Lang::Zh);
assert_eq!(Lang::parse("zh_Hans"), Lang::Zh);
assert_eq!(Lang::Zh.next(), Lang::En);
assert_eq!(Lang::parse("es-ES"), Lang::Es);
assert_eq!(Lang::parse("es_MX"), Lang::Es);
assert_eq!(Lang::Zh.next(), Lang::Es);
assert_eq!(Lang::Es.next(), Lang::En);
assert_eq!(Lang::parse("JA"), Lang::Ja);
assert_eq!(Lang::parse("ru"), Lang::Ru);
assert_eq!(Lang::parse("x"), Lang::En);
Expand Down
Loading