From 61a5ac2600cbe900753d2f2258f35f97c7caf8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 28 Nov 2026 19:10:35 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Turkish=20language,=20redes?= =?UTF-8?q?igned=20person=20card,=20Ctrl+K=20and=20room=20header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Translations live in crates/client/lang/{en,tr}/*.txt and build.rs turns them into typed Words; language is a setting, defaulting to the system locale. Dates take month names and order from the language files. Person card: name alone, status under it, presence is the avatar dot (own card: dot opens a presence menu), account switcher is a chevron after your name. Ctrl+K and the room header follow the approved canvas. The app reopens the last chat per account. The sidebar shield button is gone (Builder lives in Ctrl+K). Stale avatar size test fixed. --- crates/client/Cargo.toml | 1 + crates/client/build.rs | 162 ++++- .../client/lang/en/audio_capture_windows.txt | 2 + crates/client/lang/en/auth.txt | 9 + crates/client/lang/en/builder.txt | 14 + crates/client/lang/en/builder_access.txt | 12 + crates/client/lang/en/builder_backups.txt | 4 + crates/client/lang/en/builder_communities.txt | 11 + crates/client/lang/en/builder_log.txt | 37 ++ crates/client/lang/en/builder_messages.txt | 7 + crates/client/lang/en/builder_overview.txt | 9 + crates/client/lang/en/builder_reports.txt | 11 + crates/client/lang/en/builder_server.txt | 25 + crates/client/lang/en/builder_storage.txt | 8 + crates/client/lang/en/builder_ui.txt | 3 + crates/client/lang/en/builder_users.txt | 49 ++ crates/client/lang/en/builder_voice.txt | 10 + crates/client/lang/en/call_bar.txt | 11 + crates/client/lang/en/camera.txt | 3 + crates/client/lang/en/camera_view.txt | 3 + crates/client/lang/en/capture.txt | 2 + crates/client/lang/en/capture_windows.txt | 3 + crates/client/lang/en/chat.txt | 64 ++ crates/client/lang/en/common.txt | 20 + crates/client/lang/en/community_settings.txt | 31 + crates/client/lang/en/composer.txt | 18 + crates/client/lang/en/fail.txt | 6 + crates/client/lang/en/forward.txt | 3 + crates/client/lang/en/gui.txt | 8 + crates/client/lang/en/jump.txt | 19 + crates/client/lang/en/media_mod.txt | 1 + crates/client/lang/en/media_view.txt | 4 + crates/client/lang/en/message_actions.txt | 11 + crates/client/lang/en/poll.txt | 12 + crates/client/lang/en/profile.txt | 18 + crates/client/lang/en/session.txt | 1 + crates/client/lang/en/settings.txt | 3 + crates/client/lang/en/settings_page.txt | 30 + crates/client/lang/en/share_view.txt | 21 + crates/client/lang/en/sidebar.txt | 26 + crates/client/lang/en/snippet.txt | 2 + crates/client/lang/en/social.txt | 7 + crates/client/lang/en/stream_stats.txt | 4 + crates/client/lang/en/tray.txt | 3 + crates/client/lang/en/unsupported.txt | 1 + crates/client/lang/en/voice_note.txt | 4 + crates/client/lang/en/voice_settings.txt | 21 + crates/client/lang/en/voice_stats.txt | 29 + .../client/lang/tr/audio_capture_windows.txt | 2 + crates/client/lang/tr/auth.txt | 9 + crates/client/lang/tr/builder.txt | 14 + crates/client/lang/tr/builder_access.txt | 12 + crates/client/lang/tr/builder_backups.txt | 4 + crates/client/lang/tr/builder_communities.txt | 11 + crates/client/lang/tr/builder_log.txt | 37 ++ crates/client/lang/tr/builder_messages.txt | 7 + crates/client/lang/tr/builder_overview.txt | 9 + crates/client/lang/tr/builder_reports.txt | 11 + crates/client/lang/tr/builder_server.txt | 25 + crates/client/lang/tr/builder_storage.txt | 8 + crates/client/lang/tr/builder_ui.txt | 3 + crates/client/lang/tr/builder_users.txt | 49 ++ crates/client/lang/tr/builder_voice.txt | 10 + crates/client/lang/tr/call_bar.txt | 11 + crates/client/lang/tr/camera.txt | 3 + crates/client/lang/tr/camera_view.txt | 3 + crates/client/lang/tr/capture.txt | 2 + crates/client/lang/tr/capture_windows.txt | 3 + crates/client/lang/tr/chat.txt | 64 ++ crates/client/lang/tr/common.txt | 20 + crates/client/lang/tr/community_settings.txt | 31 + crates/client/lang/tr/composer.txt | 18 + crates/client/lang/tr/fail.txt | 6 + crates/client/lang/tr/forward.txt | 3 + crates/client/lang/tr/gui.txt | 8 + crates/client/lang/tr/jump.txt | 19 + crates/client/lang/tr/media_mod.txt | 1 + crates/client/lang/tr/media_view.txt | 4 + crates/client/lang/tr/message_actions.txt | 11 + crates/client/lang/tr/poll.txt | 12 + crates/client/lang/tr/profile.txt | 18 + crates/client/lang/tr/session.txt | 1 + crates/client/lang/tr/settings.txt | 3 + crates/client/lang/tr/settings_page.txt | 30 + crates/client/lang/tr/share_view.txt | 21 + crates/client/lang/tr/sidebar.txt | 26 + crates/client/lang/tr/snippet.txt | 2 + crates/client/lang/tr/social.txt | 7 + crates/client/lang/tr/stream_stats.txt | 4 + crates/client/lang/tr/tray.txt | 3 + crates/client/lang/tr/unsupported.txt | 1 + crates/client/lang/tr/voice_note.txt | 4 + crates/client/lang/tr/voice_settings.txt | 21 + crates/client/lang/tr/voice_stats.txt | 29 + crates/client/src/gui.rs | 83 +-- crates/client/src/gui/auth.rs | 29 +- crates/client/src/gui/builder.rs | 47 +- crates/client/src/gui/builder/access.rs | 48 +- crates/client/src/gui/builder/backups.rs | 17 +- crates/client/src/gui/builder/communities.rs | 35 +- crates/client/src/gui/builder/log.rs | 94 ++- crates/client/src/gui/builder/messages.rs | 24 +- crates/client/src/gui/builder/overview.rs | 39 +- crates/client/src/gui/builder/reports.rs | 32 +- crates/client/src/gui/builder/server.rs | 63 +- crates/client/src/gui/builder/storage.rs | 60 +- crates/client/src/gui/builder/ui.rs | 15 +- crates/client/src/gui/builder/users.rs | 158 +++-- crates/client/src/gui/builder/voice.rs | 25 +- crates/client/src/gui/call_bar.rs | 27 +- crates/client/src/gui/camera_view.rs | 22 +- crates/client/src/gui/chat.rs | 337 +++++----- crates/client/src/gui/community_settings.rs | 157 +++-- crates/client/src/gui/composer.rs | 47 +- crates/client/src/gui/forward.rs | 7 +- crates/client/src/gui/jump.rs | 518 ++++++++++++++-- crates/client/src/gui/media_view.rs | 11 +- crates/client/src/gui/message_actions.rs | 37 +- crates/client/src/gui/poll.rs | 25 +- crates/client/src/gui/profile.rs | 389 +++++++----- crates/client/src/gui/settings_page.rs | 98 +-- crates/client/src/gui/share_view.rs | 69 ++- crates/client/src/gui/sidebar.rs | 577 +++++++++++------- crates/client/src/gui/snippet.rs | 5 +- crates/client/src/gui/social.rs | 17 +- crates/client/src/gui/stream_stats.rs | 9 +- crates/client/src/gui/tow.rs | 502 +++++++++++++++ crates/client/src/gui/voice_note.rs | 9 +- crates/client/src/gui/voice_settings.rs | 75 ++- crates/client/src/gui/voice_stats.rs | 65 +- crates/client/src/lang.rs | 95 +++ crates/client/src/lib.rs | 1 + crates/client/src/logo.rs | 6 +- crates/client/src/logo/svg.rs | 4 + crates/client/src/main.rs | 1 + crates/client/src/media/mod.rs | 3 +- crates/client/src/net/fail.rs | 14 +- crates/client/src/settings.rs | 53 +- .../client/src/share/audio_capture_windows.rs | 5 +- crates/client/src/share/camera.rs | 7 +- crates/client/src/share/capture.rs | 6 +- crates/client/src/share/capture_windows.rs | 8 +- crates/client/src/share/session.rs | 5 +- crates/client/src/share/unsupported.rs | 8 +- crates/client/src/tray.rs | 20 +- crates/common/src/model.rs | 41 -- crates/server/src/files.rs | 5 +- 147 files changed, 4182 insertions(+), 1235 deletions(-) create mode 100644 crates/client/lang/en/audio_capture_windows.txt create mode 100644 crates/client/lang/en/auth.txt create mode 100644 crates/client/lang/en/builder.txt create mode 100644 crates/client/lang/en/builder_access.txt create mode 100644 crates/client/lang/en/builder_backups.txt create mode 100644 crates/client/lang/en/builder_communities.txt create mode 100644 crates/client/lang/en/builder_log.txt create mode 100644 crates/client/lang/en/builder_messages.txt create mode 100644 crates/client/lang/en/builder_overview.txt create mode 100644 crates/client/lang/en/builder_reports.txt create mode 100644 crates/client/lang/en/builder_server.txt create mode 100644 crates/client/lang/en/builder_storage.txt create mode 100644 crates/client/lang/en/builder_ui.txt create mode 100644 crates/client/lang/en/builder_users.txt create mode 100644 crates/client/lang/en/builder_voice.txt create mode 100644 crates/client/lang/en/call_bar.txt create mode 100644 crates/client/lang/en/camera.txt create mode 100644 crates/client/lang/en/camera_view.txt create mode 100644 crates/client/lang/en/capture.txt create mode 100644 crates/client/lang/en/capture_windows.txt create mode 100644 crates/client/lang/en/chat.txt create mode 100644 crates/client/lang/en/common.txt create mode 100644 crates/client/lang/en/community_settings.txt create mode 100644 crates/client/lang/en/composer.txt create mode 100644 crates/client/lang/en/fail.txt create mode 100644 crates/client/lang/en/forward.txt create mode 100644 crates/client/lang/en/gui.txt create mode 100644 crates/client/lang/en/jump.txt create mode 100644 crates/client/lang/en/media_mod.txt create mode 100644 crates/client/lang/en/media_view.txt create mode 100644 crates/client/lang/en/message_actions.txt create mode 100644 crates/client/lang/en/poll.txt create mode 100644 crates/client/lang/en/profile.txt create mode 100644 crates/client/lang/en/session.txt create mode 100644 crates/client/lang/en/settings.txt create mode 100644 crates/client/lang/en/settings_page.txt create mode 100644 crates/client/lang/en/share_view.txt create mode 100644 crates/client/lang/en/sidebar.txt create mode 100644 crates/client/lang/en/snippet.txt create mode 100644 crates/client/lang/en/social.txt create mode 100644 crates/client/lang/en/stream_stats.txt create mode 100644 crates/client/lang/en/tray.txt create mode 100644 crates/client/lang/en/unsupported.txt create mode 100644 crates/client/lang/en/voice_note.txt create mode 100644 crates/client/lang/en/voice_settings.txt create mode 100644 crates/client/lang/en/voice_stats.txt create mode 100644 crates/client/lang/tr/audio_capture_windows.txt create mode 100644 crates/client/lang/tr/auth.txt create mode 100644 crates/client/lang/tr/builder.txt create mode 100644 crates/client/lang/tr/builder_access.txt create mode 100644 crates/client/lang/tr/builder_backups.txt create mode 100644 crates/client/lang/tr/builder_communities.txt create mode 100644 crates/client/lang/tr/builder_log.txt create mode 100644 crates/client/lang/tr/builder_messages.txt create mode 100644 crates/client/lang/tr/builder_overview.txt create mode 100644 crates/client/lang/tr/builder_reports.txt create mode 100644 crates/client/lang/tr/builder_server.txt create mode 100644 crates/client/lang/tr/builder_storage.txt create mode 100644 crates/client/lang/tr/builder_ui.txt create mode 100644 crates/client/lang/tr/builder_users.txt create mode 100644 crates/client/lang/tr/builder_voice.txt create mode 100644 crates/client/lang/tr/call_bar.txt create mode 100644 crates/client/lang/tr/camera.txt create mode 100644 crates/client/lang/tr/camera_view.txt create mode 100644 crates/client/lang/tr/capture.txt create mode 100644 crates/client/lang/tr/capture_windows.txt create mode 100644 crates/client/lang/tr/chat.txt create mode 100644 crates/client/lang/tr/common.txt create mode 100644 crates/client/lang/tr/community_settings.txt create mode 100644 crates/client/lang/tr/composer.txt create mode 100644 crates/client/lang/tr/fail.txt create mode 100644 crates/client/lang/tr/forward.txt create mode 100644 crates/client/lang/tr/gui.txt create mode 100644 crates/client/lang/tr/jump.txt create mode 100644 crates/client/lang/tr/media_mod.txt create mode 100644 crates/client/lang/tr/media_view.txt create mode 100644 crates/client/lang/tr/message_actions.txt create mode 100644 crates/client/lang/tr/poll.txt create mode 100644 crates/client/lang/tr/profile.txt create mode 100644 crates/client/lang/tr/session.txt create mode 100644 crates/client/lang/tr/settings.txt create mode 100644 crates/client/lang/tr/settings_page.txt create mode 100644 crates/client/lang/tr/share_view.txt create mode 100644 crates/client/lang/tr/sidebar.txt create mode 100644 crates/client/lang/tr/snippet.txt create mode 100644 crates/client/lang/tr/social.txt create mode 100644 crates/client/lang/tr/stream_stats.txt create mode 100644 crates/client/lang/tr/tray.txt create mode 100644 crates/client/lang/tr/unsupported.txt create mode 100644 crates/client/lang/tr/voice_note.txt create mode 100644 crates/client/lang/tr/voice_settings.txt create mode 100644 crates/client/lang/tr/voice_stats.txt create mode 100644 crates/client/src/gui/tow.rs create mode 100644 crates/client/src/lang.rs diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index d307f02..b3864fc 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -30,6 +30,7 @@ tracing = "0.1.44" tracing-subscriber = "0.3.23" jiff = "1.0.2" dirs = "7.0.0" +sys-locale = "0.3.2" image = { version = "0.25.10", default-features = false, features = ["jpeg", "png", "webp", "gif"] } rtrb = "0.4.1" gethostname = "1.1.0" diff --git a/crates/client/build.rs b/crates/client/build.rs index d348a52..4694e60 100644 --- a/crates/client/build.rs +++ b/crates/client/build.rs @@ -25,6 +25,7 @@ const MEDIA_FOUNDATION: [&str; 3] = ["mf.dll", "mfplat.dll", "mfreadwrite.dll"]; fn main() { println!("cargo::rerun-if-changed={SOURCE}"); icons(); + words(); if env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") { for dll in MEDIA_FOUNDATION { println!("cargo::rustc-link-arg-bins=/DELAYLOAD:{dll}"); @@ -130,11 +131,15 @@ fn names(value: &Value) -> Vec { } fn camel(name: &str) -> String { - let mut chars = name.chars(); - chars - .next() - .map(|first| first.to_uppercase().chain(chars).collect()) - .unwrap_or_default() + name.split('_') + .map(|part| { + let mut chars = part.chars(); + chars + .next() + .map(|first| first.to_uppercase().chain(chars).collect::()) + .unwrap_or_default() + }) + .collect() } fn hex(color: &str) -> String { @@ -194,3 +199,150 @@ fn inset(size: u32) -> Vec { } canvas } + +const LANGS: [&str; 2] = ["en", "tr"]; + +type Section = Vec<(String, String)>; + +fn words() { + println!("cargo::rerun-if-changed=lang"); + let langs: Vec> = LANGS.map(sections).into(); + let base = &langs[0]; + for (lang, other) in LANGS.iter().zip(&langs).skip(1) { + assert_eq!( + base.iter().map(|(name, _)| name).collect::>(), + other.iter().map(|(name, _)| name).collect::>(), + "lang/{lang}: same files as lang/en" + ); + for ((name, en), (_, local)) in base.iter().zip(other) { + let keys = |section: &Section| { + section + .iter() + .map(|(key, _)| key.clone()) + .collect::>() + }; + let mut wanted = keys(en); + let mut got = keys(local); + wanted.sort(); + got.sort(); + assert_eq!(wanted, got, "lang/{lang}/{name}.txt: same keys as lang/en"); + for (key, text) in en { + let translated = &local.iter().find(|(other, _)| other == key).expect("key").1; + assert_eq!( + holes(text), + holes(translated), + "lang/{lang}/{name}.txt: {key} placeholders" + ); + } + } + } + + let mut out = String::new(); + writeln!( + out, + "pub struct Words {{\n{}}}", + base.iter() + .map(|(name, _)| format!(" pub {name}: {},\n", camel(name))) + .collect::() + ) + .unwrap(); + for (name, section) in base { + writeln!(out, "pub struct {} {{", camel(name)).unwrap(); + for (key, text) in section { + let public = if holes(text).is_empty() { "pub " } else { "" }; + writeln!(out, " {public}{key}: &'static str,").unwrap(); + } + writeln!(out, "}}\nimpl {} {{", camel(name)).unwrap(); + for (key, text) in section { + let holes = holes(text); + if holes.is_empty() { + continue; + } + writeln!( + out, + " pub fn {key}(&self, {}) -> String {{ self.{key}{} }}", + holes + .iter() + .map(|hole| format!("{hole}: impl std::fmt::Display")) + .collect::>() + .join(", "), + holes + .iter() + .map(|hole| format!(".replace(\"{{{hole}}}\", &{hole}.to_string())")) + .collect::() + ) + .unwrap(); + } + writeln!(out, "}}").unwrap(); + } + for (lang, sections) in LANGS.iter().zip(&langs) { + writeln!(out, "pub static {}: Words = Words {{", lang.to_uppercase()).unwrap(); + for (name, section) in sections { + writeln!(out, " {name}: {} {{", camel(name)).unwrap(); + for (key, text) in section { + writeln!(out, " {key}: {text:?},").unwrap(); + } + writeln!(out, " }},").unwrap(); + } + writeln!(out, "}};").unwrap(); + } + + let path = Path::new(&env::var("OUT_DIR").expect("OUT_DIR")).join("words.rs"); + fs::write(path, out).expect("write words"); +} + +fn sections(lang: &str) -> Vec<(String, Section)> { + let mut files: Vec = fs::read_dir(format!("lang/{lang}")) + .expect("lang dir") + .map(|entry| entry.expect("lang entry").path()) + .filter(|path| path.extension().is_some_and(|ext| ext == "txt")) + .collect(); + files.sort(); + files + .into_iter() + .map(|path| { + let name = path + .file_stem() + .expect("stem") + .to_string_lossy() + .to_string(); + let text = fs::read_to_string(&path).expect("read lang"); + let mut section = Section::new(); + for line in text.lines().map(str::trim) { + if line.is_empty() || line.starts_with('#') { + continue; + } + let (key, value) = line + .split_once('=') + .unwrap_or_else(|| panic!("{}: `key = text` expected: {line}", path.display())); + let key = key.trim().to_string(); + assert!( + !key.is_empty() + && key + .chars() + .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_'), + "{}: bad key {key}", + path.display() + ); + assert!( + section.iter().all(|(other, _)| *other != key), + "{}: duplicate key {key}", + path.display() + ); + section.push((key, value.trim().replace("\\n", "\n"))); + } + (name, section) + }) + .collect() +} + +fn holes(text: &str) -> Vec { + let mut holes: Vec = text + .split('{') + .skip(1) + .filter_map(|part| part.split_once('}').map(|(hole, _)| hole.to_string())) + .collect(); + holes.sort(); + holes.dedup(); + holes +} diff --git a/crates/client/lang/en/audio_capture_windows.txt b/crates/client/lang/en/audio_capture_windows.txt new file mode 100644 index 0000000..8b4e696 --- /dev/null +++ b/crates/client/lang/en/audio_capture_windows.txt @@ -0,0 +1,2 @@ +app_not_running = share audio app is not running +device_unsupported = share audio device capture is not supported diff --git a/crates/client/lang/en/auth.txt b/crates/client/lang/en/auth.txt new file mode 100644 index 0000000..4250246 --- /dev/null +++ b/crates/client/lang/en/auth.txt @@ -0,0 +1,9 @@ +server = Server +username_placeholder = Username... +password_placeholder = Password... +invite_placeholder = Invite code... +log_in = Log in +register = Register +maintenance = Maintenance +accept_any_cert = Accept any certificate +forget = Forget diff --git a/crates/client/lang/en/builder.txt b/crates/client/lang/en/builder.txt new file mode 100644 index 0000000..fe16324 --- /dev/null +++ b/crates/client/lang/en/builder.txt @@ -0,0 +1,14 @@ +overview = Overview +users = Users +communities = Communities +messages = Messages +voice = Voice +storage = Storage +access = Access +reports = Reports +server = Server +log = Log +ghost = Ghost +refresh = Refresh +save = Save +export = Export diff --git a/crates/client/lang/en/builder_access.txt b/crates/client/lang/en/builder_access.txt new file mode 100644 index 0000000..59b1c77 --- /dev/null +++ b/crates/client/lang/en/builder_access.txt @@ -0,0 +1,12 @@ +never = never +expires = expires {time} +one_use_left = 1 use left +uses_left = {count} uses left +copy = Copy +username = Username +remove = Remove +create = Create +invite_codes = Invite codes +bans = Bans +no_invite_codes = No invite codes +no_bans = No bans diff --git a/crates/client/lang/en/builder_backups.txt b/crates/client/lang/en/builder_backups.txt new file mode 100644 index 0000000..177b1b5 --- /dev/null +++ b/crates/client/lang/en/builder_backups.txt @@ -0,0 +1,4 @@ +backups = Backups +create = Create +export = Export +no_backups = No backups diff --git a/crates/client/lang/en/builder_communities.txt b/crates/client/lang/en/builder_communities.txt new file mode 100644 index 0000000..d2a4aae --- /dev/null +++ b/crates/client/lang/en/builder_communities.txt @@ -0,0 +1,11 @@ +empty = No communities +voice_off = Voice off +voice_on = Voice on +open = Open +log = Log +transfer = Transfer +confirm = Confirm +confirm_delete = Confirm delete +delete = Delete +members = {count} members +owner = owner {name} diff --git a/crates/client/lang/en/builder_log.txt b/crates/client/lang/en/builder_log.txt new file mode 100644 index 0000000..86d67a0 --- /dev/null +++ b/crates/client/lang/en/builder_log.txt @@ -0,0 +1,37 @@ +role_changed = {actor} set {target} to {role} +user_deleted = {actor} deleted {target} +user_suspended = {actor} suspended {target} +user_unsuspended = {actor} unsuspended {target} +sessions_revoked = {actor} revoked sessions of {target} +password_reset = {actor} reset password of {target} +profile_cleared = {actor} cleared profile of {target} +user_created = {actor} created {target} +community_deleted = {actor} deleted {community} +ownership_transferred = {actor} transferred {community} to {target} +settings_changed = {actor} changed settings +user_renamed = {actor} renamed {from} to {target} +user_timeout_cleared = {actor} cleared timeout of {target} +user_timed_out = {actor} timed out {target} for {minutes} min +user_banned = {actor} banned {target} +ban_removed = {actor} removed a ban +invite_created = {actor} created an invite code +invite_deleted = {actor} deleted an invite code +report_handled = {actor} marked a report of {target} as {status} +message_deleted = {actor} deleted a message of {target} in {community} +user_purged = {actor} purged {target}, {messages} messages +voice_kicked = {actor} kicked {target} from voice +voice_muted = {actor} muted {target} in voice +voice_unmuted = {actor} unmuted {target} in voice +community_voice_enabled = {actor} enabled voice in {community} +community_voice_disabled = {actor} disabled voice in {community} +attachment_deleted = {actor} deleted an attachment of {target} in {community} +ghost_enabled = {actor} enabled ghost mode +ghost_disabled = {actor} disabled ghost mode +ghost_visit = {actor} visited {community} as ghost +ghost_voice = {actor} listened in {community} as ghost for {seconds}s +backup_created = {actor} created backup {name} +backup_deleted = {actor} deleted backup {name} +backup_downloaded = {actor} exported backup {name} +unknown_user = Unknown user +apply = Apply +no_entries = No entries diff --git a/crates/client/lang/en/builder_messages.txt b/crates/client/lang/en/builder_messages.txt new file mode 100644 index 0000000..a1e76c2 --- /dev/null +++ b/crates/client/lang/en/builder_messages.txt @@ -0,0 +1,7 @@ +open_chat = Open chat +confirm_purge = Confirm purge +purge_user = Purge user +no_messages = No messages +search = Search +unknown_user = Unknown user +unknown_community = Unknown community diff --git a/crates/client/lang/en/builder_overview.txt b/crates/client/lang/en/builder_overview.txt new file mode 100644 index 0000000..e832bbb --- /dev/null +++ b/crates/client/lang/en/builder_overview.txt @@ -0,0 +1,9 @@ +users = Users +builders = Builders +communities = Communities +online = Online +in_voice = In voice +storage = Storage +active_users = Active users +messages = Messages +server = Server diff --git a/crates/client/lang/en/builder_reports.txt b/crates/client/lang/en/builder_reports.txt new file mode 100644 index 0000000..fd2de46 --- /dev/null +++ b/crates/client/lang/en/builder_reports.txt @@ -0,0 +1,11 @@ +all = All +someone = someone +deleted_community = deleted community +reported_by = reported by {name} +handled_by = by {name} +no_reports = No reports +resolve = Resolve +dismiss = Dismiss +delete_message = Delete message +timeout = Timeout 1h +ban = Ban diff --git a/crates/client/lang/en/builder_server.txt b/crates/client/lang/en/builder_server.txt new file mode 100644 index 0000000..4118259 --- /dev/null +++ b/crates/client/lang/en/builder_server.txt @@ -0,0 +1,25 @@ +name = Name +registration = Registration +open = Open +closed = Closed +maintenance = Maintenance +off = Off +on = On +announcement = Announcement +max_attachment = Max attachment (MB) +max_avatar = Max avatar (KB) +max_message_length = Max message length +communities_per_user = Communities per user +user_quota = User quota (MB) +community_quota = Community quota (MB) +message_retention = Message retention (days) +attachment_retention = Attachment retention (days) +messages_per_minute = Messages / min +logins_per_minute = Logins / min +general = General +limits = Limits +storage = Storage +rate_limits = Rate limits +zero_unlimited = 0 = unlimited +zero_off = 0 = off +invalid_number = Invalid number diff --git a/crates/client/lang/en/builder_storage.txt b/crates/client/lang/en/builder_storage.txt new file mode 100644 index 0000000..49398f7 --- /dev/null +++ b/crates/client/lang/en/builder_storage.txt @@ -0,0 +1,8 @@ +users = Users +communities = Communities +no_data = No data +search = Search +no_attachments = No attachments +attachments = Attachments +unknown_user = Unknown user +unknown_community = Unknown community diff --git a/crates/client/lang/en/builder_ui.txt b/crates/client/lang/en/builder_ui.txt new file mode 100644 index 0000000..af45392 --- /dev/null +++ b/crates/client/lang/en/builder_ui.txt @@ -0,0 +1,3 @@ +confirm = Confirm +delete = Delete +confirm_tip = Click again to confirm diff --git a/crates/client/lang/en/builder_users.txt b/crates/client/lang/en/builder_users.txt new file mode 100644 index 0000000..3ee3638 --- /dev/null +++ b/crates/client/lang/en/builder_users.txt @@ -0,0 +1,49 @@ +seen_never = never +seen_now = now +seen_minutes = {count}m ago +seen_hours = {count}h ago +no_users = No users +create = Create +confirm = Confirm +revoke = Revoke +end_session = End this session +unknown_device = unknown device +ip_on = IP: on +ip_off = IP: off +manage = Manage +remove_builder = Remove builder +make_builder = Make builder +revoke_admin = Revoke admin tools +grant_admin = Grant admin tools +unsuspend = Unsuspend +suspend = Suspend +allow_sign_in = Allow sign in again +block_until_lifted = Block sign in until lifted +sign_out = Sign out +end_all_sessions = End every session +stats = Stats +stats_tip = Live connection and machine stats +password = Password +password_tip = Set a new password +rename = Rename +rename_tip = Change username +timeout = Timeout +timeout_tip = Block sign in for a while +ban = Ban +ban_tip = Ban username or IP from the server +clear_profile = Clear profile +clear_profile_tip = Remove avatar and status +purge = Purge +purge_tip = Delete all their messages +delete = Delete +delete_tip = Delete the account +tag_suspended = Suspended +tag_timed_out = Timed out +tag_ghost = Ghost +joined_seen = joined {joined} · seen {seen} +group_account = Account +group_moderation = Moderation +group_danger = Danger +group_sessions = Sessions +group_friends = Friends +tag_builder = Builder diff --git a/crates/client/lang/en/builder_voice.txt b/crates/client/lang/en/builder_voice.txt new file mode 100644 index 0000000..16b269b --- /dev/null +++ b/crates/client/lang/en/builder_voice.txt @@ -0,0 +1,10 @@ +no_rooms = No active voice rooms +join = Join +voice_on = Voice on +voice_off = Voice off +no_users = No users +muted = Muted +ghost = Ghost +unmute = Unmute +mute = Mute +kick = Kick diff --git a/crates/client/lang/en/call_bar.txt b/crates/client/lang/en/call_bar.txt new file mode 100644 index 0000000..27c666e --- /dev/null +++ b/crates/client/lang/en/call_bar.txt @@ -0,0 +1,11 @@ +unmute = Unmute +mute = Mute +undeafen = Undeafen +deafen = Deafen +turn_off_camera = Turn off camera +turn_on_camera = Turn on camera +stop_sharing = Stop sharing +share_screen = Share screen +leave_call = Leave call +go_to_call = Go to call +connection_stats = Connection stats diff --git a/crates/client/lang/en/camera.txt b/crates/client/lang/en/camera.txt new file mode 100644 index 0000000..fc37801 --- /dev/null +++ b/crates/client/lang/en/camera.txt @@ -0,0 +1,3 @@ +needs_media_pack = Camera needs the Media Feature Pack +no_response = Camera did not respond +not_found = No camera found diff --git a/crates/client/lang/en/camera_view.txt b/crates/client/lang/en/camera_view.txt new file mode 100644 index 0000000..3e1d41e --- /dev/null +++ b/crates/client/lang/en/camera_view.txt @@ -0,0 +1,3 @@ +watch = Watch +screens = screens +more = {count} more diff --git a/crates/client/lang/en/capture.txt b/crates/client/lang/en/capture.txt new file mode 100644 index 0000000..476c0d4 --- /dev/null +++ b/crates/client/lang/en/capture.txt @@ -0,0 +1,2 @@ +did_not_start = screen capture did not start +no_stream = no screen stream diff --git a/crates/client/lang/en/capture_windows.txt b/crates/client/lang/en/capture_windows.txt new file mode 100644 index 0000000..da9dce0 --- /dev/null +++ b/crates/client/lang/en/capture_windows.txt @@ -0,0 +1,3 @@ +screen = Screen +screen_numbered = Screen {number} +window_gone = window is gone diff --git a/crates/client/lang/en/chat.txt b/crates/client/lang/en/chat.txt new file mode 100644 index 0000000..b779b50 --- /dev/null +++ b/crates/client/lang/en/chat.txt @@ -0,0 +1,64 @@ +message = Message +find = Find +find_user = Find user +search_messages = Search messages +search = Search... +new_password = New password... +password = Password... +question = Question +username = Username... +community_name = Community name... +status = Status... +actor = Actor... +target = Target... +all = All +date_from = From YYYY-MM-DD +date_to = To YYYY-MM-DD +text = Text... +user = User... +community = Community... +server_name = Server name... +announcement = Announcement... +max_message_length = Max message length... +minutes = Minutes... +reason = Reason... +uses = Uses... +hours = Hours +new_username = New username... +someone = Someone +unknown = unknown +typing_one = {name} is typing… +typing_many = {count} people are typing… +new_messages = {count} new messages +people = People +send = Send +ghost_title = Speak as ghost? +ghost_hint = Everyone in the call will hear you. +cancel = Cancel +speak = Speak +call = Call +hang_up = Hang up +join = Join +leave = Leave +calling = Calling… +accept = Accept +decline = Decline +is_calling = {name} is calling +strip = Strip +grid = Grid +hide = Hide +stats = Connection stats +stats_hide = Hide connection stats +in_call = In call +online = Online +offline = Offline +new = New +edited = (edited) +calls = {count} calls +call_started_mine = You started a call +call_started = {name} started a call +call_declined_mine = You declined the call +call_declined = {name} declined the call +call_missed_mine = You called, no answer +call_missed = Missed call from {name} +call_ended = Call ended · {duration} diff --git a/crates/client/lang/en/common.txt b/crates/client/lang/en/common.txt new file mode 100644 index 0000000..af2fd8e --- /dev/null +++ b/crates/client/lang/en/common.txt @@ -0,0 +1,20 @@ +language = English +role_user = User +role_builder = Builder +presence_online = Online +presence_busy = Busy +presence_offline = Offline +rank_member = Member +rank_moderator = Moderator +rank_admin = Admin +rank_owner = Owner +rank_builder = Builder +report_open = Open +report_resolved = Resolved +report_dismissed = Dismissed +months = Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec +stamp = %b %-d, %H:%M +year_stamp = %b %-d %Y, %H:%M +day = %b %-d +day_year = %b %-d, %Y +date = %b %-d %Y diff --git a/crates/client/lang/en/community_settings.txt b/crates/client/lang/en/community_settings.txt new file mode 100644 index 0000000..db8a35a --- /dev/null +++ b/crates/client/lang/en/community_settings.txt @@ -0,0 +1,31 @@ +profile = Profile +general = General +name = Name +voice = Voice +bans = Bans +logs = Logs +moderation = Moderation +leave_community = Leave community +delete_community = Delete community +newest = Newest +oldest = Oldest +on = On +off = Off +view = View +leave = Leave +unban = Unban +no_bans = No bans +no_logs = No logs +someone = someone +created = {actor} created the community +renamed = {actor} renamed to {name} +avatar_changed = {actor} changed the avatar +avatar_removed = {actor} removed the avatar +invited = {actor} invited {target} +joined_log = {actor} joined +left_log = {actor} left +kicked = {actor} kicked {target} +banned = {actor} banned {target} +unbanned = {actor} unbanned {target} +rank_changed = {actor} changed rank of {target} to {rank} +message_deleted = {actor} deleted a message by {target} diff --git a/crates/client/lang/en/composer.txt b/crates/client/lang/en/composer.txt new file mode 100644 index 0000000..91c9c67 --- /dev/null +++ b/crates/client/lang/en/composer.txt @@ -0,0 +1,18 @@ +selected = {count} selected +forward = Forward +replying_to = Replying to +unknown_author = unknown +slow_down = Slow down, you can send again in {seconds}s +editing = Editing +cancel = Cancel +no_community = No Community Selected +option = Option +remove_option = Remove option +file = File +poll = Poll +hour = 1h +day = 1d +week = 1w +multiple_answers = Multiple answers +show_voters = Show voters +create = Create diff --git a/crates/client/lang/en/fail.txt b/crates/client/lang/en/fail.txt new file mode 100644 index 0000000..2bea345 --- /dev/null +++ b/crates/client/lang/en/fail.txt @@ -0,0 +1,6 @@ +unreachable = Server unreachable +tls = Certificate error +outdated = Client is outdated +reset = Connection lost +offline = Offline +protocol = Protocol error diff --git a/crates/client/lang/en/forward.txt b/crates/client/lang/en/forward.txt new file mode 100644 index 0000000..2f505a2 --- /dev/null +++ b/crates/client/lang/en/forward.txt @@ -0,0 +1,3 @@ +filter = Filter +keep_authors = Keep authors +forward = Forward diff --git a/crates/client/lang/en/gui.txt b/crates/client/lang/en/gui.txt new file mode 100644 index 0000000..e7d5689 --- /dev/null +++ b/crates/client/lang/en/gui.txt @@ -0,0 +1,8 @@ +notes = Notes +connecting = Connecting… +reconnecting = Reconnecting… {error} ({attempts}) +not_connected = Not connected +banned = Banned from {community} +banned_reason = Banned from {community}: {reason} +kicked = Kicked from {community} +kicked_reason = Kicked from {community}: {reason} diff --git a/crates/client/lang/en/jump.txt b/crates/client/lang/en/jump.txt new file mode 100644 index 0000000..c6baedc --- /dev/null +++ b/crates/client/lang/en/jump.txt @@ -0,0 +1,19 @@ +placeholder = Where to? +esc = esc +hint_settings = settings +hint_theme = theme +notes = Notes +friends = Friends +mute = Mute +unmute = Unmute +deafen = Deafen +undeafen = Undeafen +stop_sharing = Stop sharing +share_screen = Share screen +camera_on = Camera on +camera_off = Camera off +leave_call = Leave call +new_community = New community +expand_sidebar = Expand sidebar +collapse_sidebar = Collapse sidebar +log_out = Log out diff --git a/crates/client/lang/en/media_mod.txt b/crates/client/lang/en/media_mod.txt new file mode 100644 index 0000000..51daf89 --- /dev/null +++ b/crates/client/lang/en/media_mod.txt @@ -0,0 +1 @@ +no_track = no playable video or audio track diff --git a/crates/client/lang/en/media_view.txt b/crates/client/lang/en/media_view.txt new file mode 100644 index 0000000..dd3eccf --- /dev/null +++ b/crates/client/lang/en/media_view.txt @@ -0,0 +1,4 @@ +save = Save +play = Play +pause = Pause +remove = Remove diff --git a/crates/client/lang/en/message_actions.txt b/crates/client/lang/en/message_actions.txt new file mode 100644 index 0000000..f5932e5 --- /dev/null +++ b/crates/client/lang/en/message_actions.txt @@ -0,0 +1,11 @@ +attachments = {count} attachments +reply = Reply +edit = Edit +forward = Forward +select = Select +pin = Pin +unpin = Unpin +report = Report +confirm = Confirm +delete = Delete +send = Send diff --git a/crates/client/lang/en/poll.txt b/crates/client/lang/en/poll.txt new file mode 100644 index 0000000..ba9d221 --- /dev/null +++ b/crates/client/lang/en/poll.txt @@ -0,0 +1,12 @@ +days_left = {count}d +hours_left = {count}h +minutes_left = {count}m +end_poll = End poll +voters_visible = Voters visible +anonymous = Anonymous +multiple_choice = Multiple choice +closed = Closed +votes = {count} votes +previous = Previous +next = Next +jump_to_message = Jump to message diff --git a/crates/client/lang/en/profile.txt b/crates/client/lang/en/profile.txt new file mode 100644 index 0000000..8286fe1 --- /dev/null +++ b/crates/client/lang/en/profile.txt @@ -0,0 +1,18 @@ +message = Message +call = Call +report = Report +more = More +kick = Kick +ban = Ban +make_rank = Make {rank} +delete_user = Delete user +confirm = Confirm +a_call = a call +in_room = in {room} +edit_status = Edit status +mute = Mute +accounts = Accounts +settings = Settings +log_out = Log out +add_account = Add account +reason_optional = Reason (optional) diff --git a/crates/client/lang/en/session.txt b/crates/client/lang/en/session.txt new file mode 100644 index 0000000..4926e65 --- /dev/null +++ b/crates/client/lang/en/session.txt @@ -0,0 +1 @@ +codec_unavailable = codec unavailable diff --git a/crates/client/lang/en/settings.txt b/crates/client/lang/en/settings.txt new file mode 100644 index 0000000..cd08b1b --- /dev/null +++ b/crates/client/lang/en/settings.txt @@ -0,0 +1,3 @@ +small = Small +medium = Medium +large = Large diff --git a/crates/client/lang/en/settings_page.txt b/crates/client/lang/en/settings_page.txt new file mode 100644 index 0000000..510aaee --- /dev/null +++ b/crates/client/lang/en/settings_page.txt @@ -0,0 +1,30 @@ +profile = Profile +voice = Voice +camera_share = Camera & share +appearance = Appearance +title = Settings +back = Back +identity = Identity +name = Name +status = Status +presence = Presence +account = Account +log_out = Log out +delete_account = Delete account +danger_zone = Danger zone +delete = Delete +confirm = Confirm +save = Save +remove = Remove +change_picture = Change picture +theme = Theme +font_size = Font size +language = Language +close_to_tray = Close to tray +your_hue = Your hue +camera = Camera +screen_share = Screen share +quality = Quality +frame_rate = Frame rate +codec = Codec +share_audio = Share audio diff --git a/crates/client/lang/en/share_view.txt b/crates/client/lang/en/share_view.txt new file mode 100644 index 0000000..9f7570e --- /dev/null +++ b/crates/client/lang/en/share_view.txt @@ -0,0 +1,21 @@ +share = Share +off = Off +all = All +pick = Pick +no_camera = No camera +resolution = Resolution +codec = Codec +sound_from = Sound from +apps = Apps +outputs = Outputs +inputs = Inputs +esc_exit = Esc to leave fullscreen +stream_stats = Stream stats +unmute = Unmute +mute = Mute +close = Close +exit_fullscreen = Exit fullscreen +fullscreen = Fullscreen +screen_settings = Screen settings +camera_settings = Camera settings +auto = Auto diff --git a/crates/client/lang/en/sidebar.txt b/crates/client/lang/en/sidebar.txt new file mode 100644 index 0000000..8f88b53 --- /dev/null +++ b/crates/client/lang/en/sidebar.txt @@ -0,0 +1,26 @@ +in_call = In call +go_to_call = Go to call +new_community = New community +create = Create +name_placeholder = Name... +expand = Expand +collapse = Collapse +notes = Notes +remove_friend = Remove friend +requests = Requests +message = Message +accept = Accept +decline = Decline +cancel = Cancel +from_user = from {name} +ghost_on = Ghost on +stop_watching = Stop watching +watch_camera = Watch camera +watch_screen = Watch screen +invite = Invite +settings = Settings +pin = Pin +unpin = Unpin +mute = Mute +unmute = Unmute +leave = Leave diff --git a/crates/client/lang/en/snippet.txt b/crates/client/lang/en/snippet.txt new file mode 100644 index 0000000..b6e27ba --- /dev/null +++ b/crates/client/lang/en/snippet.txt @@ -0,0 +1,2 @@ +forwarded = Forwarded +forwarded_from = Forwarded · {origin} diff --git a/crates/client/lang/en/social.txt b/crates/client/lang/en/social.txt new file mode 100644 index 0000000..138a337 --- /dev/null +++ b/crates/client/lang/en/social.txt @@ -0,0 +1,7 @@ +remove_friend = Remove friend +cancel_request = Cancel request +accept_friend = Accept friend +add_friend = Add friend +username_placeholder = Username... +invite = Invite +no_such_user = No such user diff --git a/crates/client/lang/en/stream_stats.txt b/crates/client/lang/en/stream_stats.txt new file mode 100644 index 0000000..c5f7247 --- /dev/null +++ b/crates/client/lang/en/stream_stats.txt @@ -0,0 +1,4 @@ +loss = loss % +latency = latency ms +buffer = buffer {count} ms +keyframes = keyframes {count} diff --git a/crates/client/lang/en/tray.txt b/crates/client/lang/en/tray.txt new file mode 100644 index 0000000..d1da932 --- /dev/null +++ b/crates/client/lang/en/tray.txt @@ -0,0 +1,3 @@ +tip = {name} · {messages} unread · {mentions} mentions +show = Show +quit = Quit diff --git a/crates/client/lang/en/unsupported.txt b/crates/client/lang/en/unsupported.txt new file mode 100644 index 0000000..0061345 --- /dev/null +++ b/crates/client/lang/en/unsupported.txt @@ -0,0 +1 @@ +not_supported = screen share is not supported on this OS diff --git a/crates/client/lang/en/voice_note.txt b/crates/client/lang/en/voice_note.txt new file mode 100644 index 0000000..5f94182 --- /dev/null +++ b/crates/client/lang/en/voice_note.txt @@ -0,0 +1,4 @@ +cancel = Cancel +send = Send +voice_message = Voice message +leave_call_first = Leave voice call first diff --git a/crates/client/lang/en/voice_settings.txt b/crates/client/lang/en/voice_settings.txt new file mode 100644 index 0000000..05d4460 --- /dev/null +++ b/crates/client/lang/en/voice_settings.txt @@ -0,0 +1,21 @@ +default = Default +voice_activity = Voice activity +push_to_talk = Push to talk +voice = Voice +music = Music +input_device = Input device +output_device = Output device +input_volume = Input volume +output_volume = Output volume +mode = Mode +profile = Profile +test = Test +sensitivity = Sensitivity +key = Key +stop = Stop +hear_yourself = Hear yourself +play_sound = Play sound +press_key = Press key +set_key = Set key +microphone = Microphone +speaker = Speaker diff --git a/crates/client/lang/en/voice_stats.txt b/crates/client/lang/en/voice_stats.txt new file mode 100644 index 0000000..64fb807 --- /dev/null +++ b/crates/client/lang/en/voice_stats.txt @@ -0,0 +1,29 @@ +good = good +fair = fair +poor = poor +connection = Connection +traffic = Traffic +this_machine = This machine +sending_screen = Sending screen +sending_camera = Sending camera +watching = Watching +streams_one = {count} stream +streams_many = {count} streams +loss = loss % +buffer = buffer ms +up = up +down = down +rate = rate +memory = memory +storage = storage +thread_gui = gui +thread_camera = camera +thread_encode = encode +thread_decode = decode +camera = camera +screen = screen +hardware = hardware +software = software +latency = latency {ms} +loss_now = loss {percent} % +keyframes = keyframes {count} diff --git a/crates/client/lang/tr/audio_capture_windows.txt b/crates/client/lang/tr/audio_capture_windows.txt new file mode 100644 index 0000000..9d87843 --- /dev/null +++ b/crates/client/lang/tr/audio_capture_windows.txt @@ -0,0 +1,2 @@ +app_not_running = paylaşılacak ses uygulaması çalışmıyor +device_unsupported = ses aygıtı yakalama desteklenmiyor diff --git a/crates/client/lang/tr/auth.txt b/crates/client/lang/tr/auth.txt new file mode 100644 index 0000000..dfaa750 --- /dev/null +++ b/crates/client/lang/tr/auth.txt @@ -0,0 +1,9 @@ +server = Sunucu +username_placeholder = Kullanıcı adı... +password_placeholder = Şifre... +invite_placeholder = Davet kodu... +log_in = Giriş yap +register = Kayıt ol +maintenance = Bakım +accept_any_cert = Her sertifikayı kabul et +forget = Unut diff --git a/crates/client/lang/tr/builder.txt b/crates/client/lang/tr/builder.txt new file mode 100644 index 0000000..7101715 --- /dev/null +++ b/crates/client/lang/tr/builder.txt @@ -0,0 +1,14 @@ +overview = Genel Bakış +users = Kullanıcılar +communities = Topluluklar +messages = Mesajlar +voice = Ses +storage = Depolama +access = Erişim +reports = Raporlar +server = Sunucu +log = Günlük +ghost = Hayalet +refresh = Yenile +save = Kaydet +export = Dışa aktar diff --git a/crates/client/lang/tr/builder_access.txt b/crates/client/lang/tr/builder_access.txt new file mode 100644 index 0000000..04f1682 --- /dev/null +++ b/crates/client/lang/tr/builder_access.txt @@ -0,0 +1,12 @@ +never = süresiz +expires = son: {time} +one_use_left = 1 kullanım kaldı +uses_left = {count} kullanım kaldı +copy = Kopyala +username = Kullanıcı adı +remove = Kaldır +create = Oluştur +invite_codes = Davet kodları +bans = Yasaklar +no_invite_codes = Davet kodu yok +no_bans = Yasak yok diff --git a/crates/client/lang/tr/builder_backups.txt b/crates/client/lang/tr/builder_backups.txt new file mode 100644 index 0000000..271fda7 --- /dev/null +++ b/crates/client/lang/tr/builder_backups.txt @@ -0,0 +1,4 @@ +backups = Yedekler +create = Oluştur +export = Dışa aktar +no_backups = Yedek yok diff --git a/crates/client/lang/tr/builder_communities.txt b/crates/client/lang/tr/builder_communities.txt new file mode 100644 index 0000000..3de161d --- /dev/null +++ b/crates/client/lang/tr/builder_communities.txt @@ -0,0 +1,11 @@ +empty = Topluluk yok +voice_off = Ses kapalı +voice_on = Ses açık +open = Aç +log = Günlük +transfer = Devret +confirm = Onayla +confirm_delete = Silmeyi onayla +delete = Sil +members = {count} üye +owner = sahip: {name} diff --git a/crates/client/lang/tr/builder_log.txt b/crates/client/lang/tr/builder_log.txt new file mode 100644 index 0000000..6469378 --- /dev/null +++ b/crates/client/lang/tr/builder_log.txt @@ -0,0 +1,37 @@ +role_changed = {actor} rolünü değiştirdi: {target} → {role} +user_deleted = {actor} sildi: {target} +user_suspended = {actor} askıya aldı: {target} +user_unsuspended = {actor} askıdan çıkardı: {target} +sessions_revoked = {actor} oturumları kapattı: {target} +password_reset = {actor} şifreyi sıfırladı: {target} +profile_cleared = {actor} profili temizledi: {target} +user_created = {actor} oluşturdu: {target} +community_deleted = {actor} topluluğu sildi: {community} +ownership_transferred = {actor} sahipliği devretti: {community} → {target} +settings_changed = {actor} ayarları değiştirdi +user_renamed = {actor} adını değiştirdi: {from} → {target} +user_timeout_cleared = {actor} susturmayı kaldırdı: {target} +user_timed_out = {actor} susturdu: {target} ({minutes} dk) +user_banned = {actor} yasakladı: {target} +ban_removed = {actor} yasağı kaldırdı +invite_created = {actor} davet kodu oluşturdu +invite_deleted = {actor} davet kodunu sildi +report_handled = {actor} raporu işaretledi: {target} → {status} +message_deleted = {actor} mesaj sildi: {target} ({community}) +user_purged = {actor} temizledi: {target}, {messages} mesaj +voice_kicked = {actor} sesten attı: {target} +voice_muted = {actor} sesli sohbette susturdu: {target} +voice_unmuted = {actor} sesli sohbette sesini açtı: {target} +community_voice_enabled = {actor} sesi açtı: {community} +community_voice_disabled = {actor} sesi kapattı: {community} +attachment_deleted = {actor} ek sildi: {target} ({community}) +ghost_enabled = {actor} hayalet modu açtı +ghost_disabled = {actor} hayalet modu kapattı +ghost_visit = {actor} hayalet olarak ziyaret etti: {community} +ghost_voice = {actor} hayalet olarak dinledi: {community} ({seconds} sn) +backup_created = {actor} yedek oluşturdu: {name} +backup_deleted = {actor} yedeği sildi: {name} +backup_downloaded = {actor} yedeği dışa aktardı: {name} +unknown_user = Bilinmeyen kullanıcı +apply = Uygula +no_entries = Kayıt yok diff --git a/crates/client/lang/tr/builder_messages.txt b/crates/client/lang/tr/builder_messages.txt new file mode 100644 index 0000000..2c3c987 --- /dev/null +++ b/crates/client/lang/tr/builder_messages.txt @@ -0,0 +1,7 @@ +open_chat = Sohbeti aç +confirm_purge = Temizlemeyi onayla +purge_user = Kullanıcıyı temizle +no_messages = Mesaj yok +search = Ara +unknown_user = Bilinmeyen kullanıcı +unknown_community = Bilinmeyen topluluk diff --git a/crates/client/lang/tr/builder_overview.txt b/crates/client/lang/tr/builder_overview.txt new file mode 100644 index 0000000..f8985fa --- /dev/null +++ b/crates/client/lang/tr/builder_overview.txt @@ -0,0 +1,9 @@ +users = Kullanıcılar +builders = Kurucular +communities = Topluluklar +online = Çevrimiçi +in_voice = Seste +storage = Depolama +active_users = Aktif kullanıcılar +messages = Mesajlar +server = Sunucu diff --git a/crates/client/lang/tr/builder_reports.txt b/crates/client/lang/tr/builder_reports.txt new file mode 100644 index 0000000..e380f88 --- /dev/null +++ b/crates/client/lang/tr/builder_reports.txt @@ -0,0 +1,11 @@ +all = Tümü +someone = birisi +deleted_community = silinmiş topluluk +reported_by = bildiren: {name} +handled_by = işleyen: {name} +no_reports = Rapor yok +resolve = Çöz +dismiss = Reddet +delete_message = Mesajı sil +timeout = 1 saat sustur +ban = Yasakla diff --git a/crates/client/lang/tr/builder_server.txt b/crates/client/lang/tr/builder_server.txt new file mode 100644 index 0000000..04e0249 --- /dev/null +++ b/crates/client/lang/tr/builder_server.txt @@ -0,0 +1,25 @@ +name = Ad +registration = Kayıt +open = Açık +closed = Kapalı +maintenance = Bakım +off = Kapalı +on = Açık +announcement = Duyuru +max_attachment = Maks. ek boyutu (MB) +max_avatar = Maks. avatar boyutu (KB) +max_message_length = Maks. mesaj uzunluğu +communities_per_user = Kullanıcı başına topluluk +user_quota = Kullanıcı kotası (MB) +community_quota = Topluluk kotası (MB) +message_retention = Mesaj saklama (gün) +attachment_retention = Ek saklama (gün) +messages_per_minute = Mesaj / dk +logins_per_minute = Giriş / dk +general = Genel +limits = Sınırlar +storage = Depolama +rate_limits = Hız sınırları +zero_unlimited = 0 = sınırsız +zero_off = 0 = kapalı +invalid_number = Geçersiz sayı diff --git a/crates/client/lang/tr/builder_storage.txt b/crates/client/lang/tr/builder_storage.txt new file mode 100644 index 0000000..c0cefce --- /dev/null +++ b/crates/client/lang/tr/builder_storage.txt @@ -0,0 +1,8 @@ +users = Kullanıcılar +communities = Topluluklar +no_data = Veri yok +search = Ara +no_attachments = Ek yok +attachments = Ekler +unknown_user = Bilinmeyen kullanıcı +unknown_community = Bilinmeyen topluluk diff --git a/crates/client/lang/tr/builder_ui.txt b/crates/client/lang/tr/builder_ui.txt new file mode 100644 index 0000000..00e6559 --- /dev/null +++ b/crates/client/lang/tr/builder_ui.txt @@ -0,0 +1,3 @@ +confirm = Onayla +delete = Sil +confirm_tip = Onaylamak için tekrar tıkla diff --git a/crates/client/lang/tr/builder_users.txt b/crates/client/lang/tr/builder_users.txt new file mode 100644 index 0000000..76e325a --- /dev/null +++ b/crates/client/lang/tr/builder_users.txt @@ -0,0 +1,49 @@ +seen_never = hiç +seen_now = şimdi +seen_minutes = {count} dk önce +seen_hours = {count} sa önce +no_users = Kullanıcı yok +create = Oluştur +confirm = Onayla +revoke = İptal et +end_session = Bu oturumu sonlandır +unknown_device = bilinmeyen cihaz +ip_on = IP: açık +ip_off = IP: kapalı +manage = Yönet +remove_builder = Kurucu yetkisini al +make_builder = Kurucu yap +revoke_admin = Yönetici araçlarını al +grant_admin = Yönetici araçlarını ver +unsuspend = Askıyı kaldır +suspend = Askıya al +allow_sign_in = Yeniden girişe izin ver +block_until_lifted = Kaldırılana kadar girişi engelle +sign_out = Oturumu kapat +end_all_sessions = Tüm oturumları sonlandır +stats = İstatistik +stats_tip = Canlı bağlantı ve makine istatistikleri +password = Şifre +password_tip = Yeni şifre belirle +rename = Yeniden adlandır +rename_tip = Kullanıcı adını değiştir +timeout = Zaman aşımı +timeout_tip = Bir süreliğine girişi engelle +ban = Yasakla +ban_tip = Kullanıcı adını veya IP'yi sunucudan yasakla +clear_profile = Profili temizle +clear_profile_tip = Avatar ve durumu kaldır +purge = Mesajları sil +purge_tip = Tüm mesajlarını sil +delete = Sil +delete_tip = Hesabı sil +tag_suspended = Askıda +tag_timed_out = Zaman aşımında +tag_ghost = Hayalet +joined_seen = katıldı {joined} · görüldü {seen} +group_account = Hesap +group_moderation = Moderasyon +group_danger = Tehlike +group_sessions = Oturumlar +group_friends = Arkadaşlar +tag_builder = Kurucu diff --git a/crates/client/lang/tr/builder_voice.txt b/crates/client/lang/tr/builder_voice.txt new file mode 100644 index 0000000..2fd2b81 --- /dev/null +++ b/crates/client/lang/tr/builder_voice.txt @@ -0,0 +1,10 @@ +no_rooms = Aktif ses odası yok +join = Katıl +voice_on = Ses açık +voice_off = Ses kapalı +no_users = Kullanıcı yok +muted = Susturuldu +ghost = Hayalet +unmute = Sesi aç +mute = Sustur +kick = At diff --git a/crates/client/lang/tr/call_bar.txt b/crates/client/lang/tr/call_bar.txt new file mode 100644 index 0000000..a41ca4b --- /dev/null +++ b/crates/client/lang/tr/call_bar.txt @@ -0,0 +1,11 @@ +unmute = Sesi aç +mute = Sessize al +undeafen = Sağırlaştırmayı kaldır +deafen = Sağırlaştır +turn_off_camera = Kamerayı kapat +turn_on_camera = Kamerayı aç +stop_sharing = Paylaşımı durdur +share_screen = Ekranı paylaş +leave_call = Görüşmeden ayrıl +go_to_call = Görüşmeye git +connection_stats = Bağlantı istatistikleri diff --git a/crates/client/lang/tr/camera.txt b/crates/client/lang/tr/camera.txt new file mode 100644 index 0000000..6436c59 --- /dev/null +++ b/crates/client/lang/tr/camera.txt @@ -0,0 +1,3 @@ +needs_media_pack = Kamera için Media Feature Pack gerekli +no_response = Kamera yanıt vermedi +not_found = Kamera bulunamadı diff --git a/crates/client/lang/tr/camera_view.txt b/crates/client/lang/tr/camera_view.txt new file mode 100644 index 0000000..8214bf0 --- /dev/null +++ b/crates/client/lang/tr/camera_view.txt @@ -0,0 +1,3 @@ +watch = İzle +screens = ekran +more = {count} daha diff --git a/crates/client/lang/tr/capture.txt b/crates/client/lang/tr/capture.txt new file mode 100644 index 0000000..91ead46 --- /dev/null +++ b/crates/client/lang/tr/capture.txt @@ -0,0 +1,2 @@ +did_not_start = ekran yakalama başlamadı +no_stream = ekran akışı yok diff --git a/crates/client/lang/tr/capture_windows.txt b/crates/client/lang/tr/capture_windows.txt new file mode 100644 index 0000000..d186d61 --- /dev/null +++ b/crates/client/lang/tr/capture_windows.txt @@ -0,0 +1,3 @@ +screen = Ekran +screen_numbered = Ekran {number} +window_gone = pencere artık yok diff --git a/crates/client/lang/tr/chat.txt b/crates/client/lang/tr/chat.txt new file mode 100644 index 0000000..274a373 --- /dev/null +++ b/crates/client/lang/tr/chat.txt @@ -0,0 +1,64 @@ +message = Mesaj +find = Bul +find_user = Kullanıcı bul +search_messages = Mesajlarda ara +search = Ara... +new_password = Yeni şifre... +password = Şifre... +question = Soru +username = Kullanıcı adı... +community_name = Topluluk adı... +status = Durum... +actor = Yapan... +target = Hedef... +all = Tümü +date_from = Başlangıç YYYY-AA-GG +date_to = Bitiş YYYY-AA-GG +text = Metin... +user = Kullanıcı... +community = Topluluk... +server_name = Sunucu adı... +announcement = Duyuru... +max_message_length = En fazla mesaj uzunluğu... +minutes = Dakika... +reason = Sebep... +uses = Kullanım... +hours = Saat +new_username = Yeni kullanıcı adı... +someone = Biri +unknown = bilinmiyor +typing_one = {name} yazıyor… +typing_many = {count} kişi yazıyor… +new_messages = {count} yeni mesaj +people = Kişiler +send = Gönder +ghost_title = Hayalet olarak konuş? +ghost_hint = Aramadaki herkes seni duyacak. +cancel = İptal +speak = Konuş +call = Ara +hang_up = Aramayı kapat +join = Katıl +leave = Ayrıl +calling = Aranıyor… +accept = Kabul et +decline = Reddet +is_calling = {name} arıyor +strip = Şerit +grid = Izgara +hide = Gizle +stats = Bağlantı istatistikleri +stats_hide = Bağlantı istatistiklerini gizle +in_call = Aramada +online = Çevrimiçi +offline = Çevrimdışı +new = Yeni +edited = (düzenlendi) +calls = {count} arama +call_started_mine = Bir arama başlattın +call_started = {name} bir arama başlattı +call_declined_mine = Aramayı reddettin +call_declined = {name} aramayı reddetti +call_missed_mine = Aradın, cevap yok +call_missed = Cevapsız arama: {name} +call_ended = Arama bitti · {duration} diff --git a/crates/client/lang/tr/common.txt b/crates/client/lang/tr/common.txt new file mode 100644 index 0000000..3e43f85 --- /dev/null +++ b/crates/client/lang/tr/common.txt @@ -0,0 +1,20 @@ +language = Türkçe +role_user = Kullanıcı +role_builder = Kurucu +presence_online = Çevrimiçi +presence_busy = Meşgul +presence_offline = Çevrimdışı +rank_member = Üye +rank_moderator = Moderatör +rank_admin = Yönetici +rank_owner = Sahip +rank_builder = Kurucu +report_open = Açık +report_resolved = Çözüldü +report_dismissed = Reddedildi +months = Oca Şub Mar Nis May Haz Tem Ağu Eyl Eki Kas Ara +stamp = %-d %b, %H:%M +year_stamp = %-d %b %Y, %H:%M +day = %-d %b +day_year = %-d %b %Y +date = %-d %b %Y diff --git a/crates/client/lang/tr/community_settings.txt b/crates/client/lang/tr/community_settings.txt new file mode 100644 index 0000000..2fc06dc --- /dev/null +++ b/crates/client/lang/tr/community_settings.txt @@ -0,0 +1,31 @@ +profile = Profil +general = Genel +name = İsim +voice = Ses +bans = Yasaklar +logs = Kayıtlar +moderation = Moderasyon +leave_community = Topluluktan ayrıl +delete_community = Topluluğu sil +newest = En yeni +oldest = En eski +on = Açık +off = Kapalı +view = Görüntüle +leave = Ayrıl +unban = Yasağı kaldır +no_bans = Yasak yok +no_logs = Kayıt yok +someone = birisi +created = {actor} topluluğu oluşturdu +renamed = {actor} adı {name} olarak değiştirdi +avatar_changed = {actor} avatarı değiştirdi +avatar_removed = {actor} avatarı kaldırdı +invited = {actor} davet etti: {target} +joined_log = {actor} katıldı +left_log = {actor} ayrıldı +kicked = {actor} çıkardı: {target} +banned = {actor} yasakladı: {target} +unbanned = {actor} yasağı kaldırdı: {target} +rank_changed = {actor} rütbe değiştirdi: {target} ({rank}) +message_deleted = {actor} bir mesaj sildi ({target}) diff --git a/crates/client/lang/tr/composer.txt b/crates/client/lang/tr/composer.txt new file mode 100644 index 0000000..9e71aba --- /dev/null +++ b/crates/client/lang/tr/composer.txt @@ -0,0 +1,18 @@ +selected = {count} seçili +forward = İlet +replying_to = Yanıt: +unknown_author = bilinmeyen +slow_down = Yavaşla, {seconds} sn sonra tekrar gönderebilirsin +editing = Düzenleniyor +cancel = İptal +no_community = Topluluk seçilmedi +option = Seçenek +remove_option = Seçeneği kaldır +file = Dosya +poll = Anket +hour = 1 sa +day = 1 gün +week = 1 hafta +multiple_answers = Birden fazla cevap +show_voters = Oy verenleri göster +create = Oluştur diff --git a/crates/client/lang/tr/fail.txt b/crates/client/lang/tr/fail.txt new file mode 100644 index 0000000..bd9341c --- /dev/null +++ b/crates/client/lang/tr/fail.txt @@ -0,0 +1,6 @@ +unreachable = Sunucuya ulaşılamıyor +tls = Sertifika hatası +outdated = İstemci sürümü eski +reset = Bağlantı koptu +offline = Çevrimdışı +protocol = Protokol hatası diff --git a/crates/client/lang/tr/forward.txt b/crates/client/lang/tr/forward.txt new file mode 100644 index 0000000..23b7ac9 --- /dev/null +++ b/crates/client/lang/tr/forward.txt @@ -0,0 +1,3 @@ +filter = Filtrele +keep_authors = Yazarları koru +forward = İlet diff --git a/crates/client/lang/tr/gui.txt b/crates/client/lang/tr/gui.txt new file mode 100644 index 0000000..70bc603 --- /dev/null +++ b/crates/client/lang/tr/gui.txt @@ -0,0 +1,8 @@ +notes = Notlar +connecting = Bağlanıyor… +reconnecting = Yeniden bağlanılıyor… {error} ({attempts}) +not_connected = Bağlı değil +banned = Yasaklandın: {community} +banned_reason = Yasaklandın: {community} ({reason}) +kicked = Atıldın: {community} +kicked_reason = Atıldın: {community} ({reason}) diff --git a/crates/client/lang/tr/jump.txt b/crates/client/lang/tr/jump.txt new file mode 100644 index 0000000..4293c98 --- /dev/null +++ b/crates/client/lang/tr/jump.txt @@ -0,0 +1,19 @@ +placeholder = Nereye? +esc = esc +hint_settings = ayarlar +hint_theme = tema +notes = Notlar +friends = Arkadaşlar +mute = Sessize al +unmute = Sesi aç +deafen = Sağırlaştır +undeafen = Sağırlaştırmayı kaldır +stop_sharing = Paylaşımı durdur +share_screen = Ekranı paylaş +camera_on = Kamerayı aç +camera_off = Kamerayı kapat +leave_call = Görüşmeden ayrıl +new_community = Yeni topluluk +expand_sidebar = Kenar çubuğunu genişlet +collapse_sidebar = Kenar çubuğunu daralt +log_out = Çıkış yap diff --git a/crates/client/lang/tr/media_mod.txt b/crates/client/lang/tr/media_mod.txt new file mode 100644 index 0000000..8ef6d49 --- /dev/null +++ b/crates/client/lang/tr/media_mod.txt @@ -0,0 +1 @@ +no_track = oynatılabilir video veya ses parçası yok diff --git a/crates/client/lang/tr/media_view.txt b/crates/client/lang/tr/media_view.txt new file mode 100644 index 0000000..e4f77be --- /dev/null +++ b/crates/client/lang/tr/media_view.txt @@ -0,0 +1,4 @@ +save = Kaydet +play = Oynat +pause = Duraklat +remove = Kaldır diff --git a/crates/client/lang/tr/message_actions.txt b/crates/client/lang/tr/message_actions.txt new file mode 100644 index 0000000..f42ee28 --- /dev/null +++ b/crates/client/lang/tr/message_actions.txt @@ -0,0 +1,11 @@ +attachments = {count} ek +reply = Yanıtla +edit = Düzenle +forward = İlet +select = Seç +pin = Sabitle +unpin = Sabitlemeyi kaldır +report = Bildir +confirm = Onayla +delete = Sil +send = Gönder diff --git a/crates/client/lang/tr/poll.txt b/crates/client/lang/tr/poll.txt new file mode 100644 index 0000000..f6b3944 --- /dev/null +++ b/crates/client/lang/tr/poll.txt @@ -0,0 +1,12 @@ +days_left = {count}g +hours_left = {count}sa +minutes_left = {count}dk +end_poll = Anketi bitir +voters_visible = Oylar görünür +anonymous = Anonim +multiple_choice = Çoklu seçim +closed = Kapalı +votes = {count} oy +previous = Önceki +next = Sonraki +jump_to_message = Mesaja git diff --git a/crates/client/lang/tr/profile.txt b/crates/client/lang/tr/profile.txt new file mode 100644 index 0000000..51cb24d --- /dev/null +++ b/crates/client/lang/tr/profile.txt @@ -0,0 +1,18 @@ +message = Mesaj +call = Ara +report = Bildir +more = Daha fazla +kick = Çıkar +ban = Yasakla +make_rank = {rank} yap +delete_user = Kullanıcıyı sil +confirm = Onayla +a_call = bir arama +in_room = {room} içinde +edit_status = Durumu düzenle +mute = Sustur +accounts = Hesaplar +settings = Ayarlar +log_out = Çıkış yap +add_account = Hesap ekle +reason_optional = Sebep (isteğe bağlı) diff --git a/crates/client/lang/tr/session.txt b/crates/client/lang/tr/session.txt new file mode 100644 index 0000000..1c20e35 --- /dev/null +++ b/crates/client/lang/tr/session.txt @@ -0,0 +1 @@ +codec_unavailable = codec kullanılamıyor diff --git a/crates/client/lang/tr/settings.txt b/crates/client/lang/tr/settings.txt new file mode 100644 index 0000000..f62247a --- /dev/null +++ b/crates/client/lang/tr/settings.txt @@ -0,0 +1,3 @@ +small = Küçük +medium = Orta +large = Büyük diff --git a/crates/client/lang/tr/settings_page.txt b/crates/client/lang/tr/settings_page.txt new file mode 100644 index 0000000..cfa7846 --- /dev/null +++ b/crates/client/lang/tr/settings_page.txt @@ -0,0 +1,30 @@ +profile = Profil +voice = Ses +camera_share = Kamera ve paylaşım +appearance = Görünüm +title = Ayarlar +back = Geri +identity = Kimlik +name = Ad +status = Durum +presence = Görünürlük +account = Hesap +log_out = Çıkış yap +delete_account = Hesabı sil +danger_zone = Tehlikeli bölge +delete = Sil +confirm = Onayla +save = Kaydet +remove = Kaldır +change_picture = Resmi değiştir +theme = Tema +font_size = Yazı boyutu +language = Dil +close_to_tray = Tepsiye küçült +your_hue = Rengin +camera = Kamera +screen_share = Ekran paylaşımı +quality = Kalite +frame_rate = Kare hızı +codec = Kodek +share_audio = Sesi paylaş diff --git a/crates/client/lang/tr/share_view.txt b/crates/client/lang/tr/share_view.txt new file mode 100644 index 0000000..fa1d1cc --- /dev/null +++ b/crates/client/lang/tr/share_view.txt @@ -0,0 +1,21 @@ +share = Paylaş +off = Kapalı +all = Tümü +pick = Seç +no_camera = Kamera yok +resolution = Çözünürlük +codec = Kodek +sound_from = Ses kaynağı +apps = Uygulamalar +outputs = Çıkışlar +inputs = Girişler +esc_exit = Tam ekrandan çıkmak için Esc +stream_stats = Yayın istatistikleri +unmute = Sesi aç +mute = Sessize al +close = Kapat +exit_fullscreen = Tam ekrandan çık +fullscreen = Tam ekran +screen_settings = Ekran ayarları +camera_settings = Kamera ayarları +auto = Otomatik diff --git a/crates/client/lang/tr/sidebar.txt b/crates/client/lang/tr/sidebar.txt new file mode 100644 index 0000000..8aae1c4 --- /dev/null +++ b/crates/client/lang/tr/sidebar.txt @@ -0,0 +1,26 @@ +in_call = Görüşmede +go_to_call = Görüşmeye git +new_community = Yeni topluluk +create = Oluştur +name_placeholder = Ad... +expand = Genişlet +collapse = Daralt +notes = Notlar +remove_friend = Arkadaşlıktan çıkar +requests = İstekler +message = Mesaj +accept = Kabul et +decline = Reddet +cancel = İptal +from_user = gönderen: {name} +ghost_on = Hayalet açık +stop_watching = İzlemeyi bırak +watch_camera = Kamerayı izle +watch_screen = Ekranı izle +invite = Davet et +settings = Ayarlar +pin = Sabitle +unpin = Sabitlemeyi kaldır +mute = Sessize al +unmute = Sesi aç +leave = Ayrıl diff --git a/crates/client/lang/tr/snippet.txt b/crates/client/lang/tr/snippet.txt new file mode 100644 index 0000000..74bfd2c --- /dev/null +++ b/crates/client/lang/tr/snippet.txt @@ -0,0 +1,2 @@ +forwarded = İletildi +forwarded_from = İletildi · {origin} diff --git a/crates/client/lang/tr/social.txt b/crates/client/lang/tr/social.txt new file mode 100644 index 0000000..f882137 --- /dev/null +++ b/crates/client/lang/tr/social.txt @@ -0,0 +1,7 @@ +remove_friend = Arkadaşlıktan çıkar +cancel_request = İsteği iptal et +accept_friend = Arkadaşlığı kabul et +add_friend = Arkadaş ekle +username_placeholder = Kullanıcı adı... +invite = Davet et +no_such_user = Böyle bir kullanıcı yok diff --git a/crates/client/lang/tr/stream_stats.txt b/crates/client/lang/tr/stream_stats.txt new file mode 100644 index 0000000..13f987a --- /dev/null +++ b/crates/client/lang/tr/stream_stats.txt @@ -0,0 +1,4 @@ +loss = kayıp % +latency = gecikme ms +buffer = tampon {count} ms +keyframes = anahtar kare {count} diff --git a/crates/client/lang/tr/tray.txt b/crates/client/lang/tr/tray.txt new file mode 100644 index 0000000..b205ab0 --- /dev/null +++ b/crates/client/lang/tr/tray.txt @@ -0,0 +1,3 @@ +tip = {name} · {messages} okunmamış · {mentions} bahsetme +show = Göster +quit = Çık diff --git a/crates/client/lang/tr/unsupported.txt b/crates/client/lang/tr/unsupported.txt new file mode 100644 index 0000000..9e6011e --- /dev/null +++ b/crates/client/lang/tr/unsupported.txt @@ -0,0 +1 @@ +not_supported = Ekran paylaşımı bu işletim sisteminde desteklenmiyor diff --git a/crates/client/lang/tr/voice_note.txt b/crates/client/lang/tr/voice_note.txt new file mode 100644 index 0000000..7199aba --- /dev/null +++ b/crates/client/lang/tr/voice_note.txt @@ -0,0 +1,4 @@ +cancel = İptal +send = Gönder +voice_message = Sesli mesaj +leave_call_first = Önce sesli aramadan ayrıl diff --git a/crates/client/lang/tr/voice_settings.txt b/crates/client/lang/tr/voice_settings.txt new file mode 100644 index 0000000..3103b72 --- /dev/null +++ b/crates/client/lang/tr/voice_settings.txt @@ -0,0 +1,21 @@ +default = Varsayılan +voice_activity = Ses algılama +push_to_talk = Bas konuş +voice = Ses +music = Müzik +input_device = Giriş aygıtı +output_device = Çıkış aygıtı +input_volume = Giriş sesi +output_volume = Çıkış sesi +mode = Mod +profile = Profil +test = Test +sensitivity = Hassasiyet +key = Tuş +stop = Durdur +hear_yourself = Kendini dinle +play_sound = Ses çal +press_key = Tuşa bas +set_key = Tuş ata +microphone = Mikrofon +speaker = Hoparlör diff --git a/crates/client/lang/tr/voice_stats.txt b/crates/client/lang/tr/voice_stats.txt new file mode 100644 index 0000000..3f321b1 --- /dev/null +++ b/crates/client/lang/tr/voice_stats.txt @@ -0,0 +1,29 @@ +good = iyi +fair = orta +poor = kötü +connection = Bağlantı +traffic = Trafik +this_machine = Bu makine +sending_screen = Ekran gönderiliyor +sending_camera = Kamera gönderiliyor +watching = İzleniyor +streams_one = {count} akış +streams_many = {count} akış +loss = kayıp % +buffer = tampon ms +up = yükleme +down = indirme +rate = hız +memory = bellek +storage = depolama +thread_gui = arayüz +thread_camera = kamera +thread_encode = kodlama +thread_decode = kod çözme +camera = kamera +screen = ekran +hardware = donanım +software = yazılım +latency = gecikme {ms} +loss_now = kayıp {percent} % +keyframes = anahtar kare {count} diff --git a/crates/client/src/gui.rs b/crates/client/src/gui.rs index c0db314..a908f12 100644 --- a/crates/client/src/gui.rs +++ b/crates/client/src/gui.rs @@ -1,4 +1,5 @@ use crate::gui::glyph::Fill as _; +use crate::lang::{Label as _, w}; use common::model::{Hue, Id}; use std::{collections::HashMap, fmt::Display, rc::Rc, sync::Arc, time::Instant}; @@ -17,9 +18,10 @@ use gpui_kit::{ Entity, FontWeight, Hsla, Image, ImageFormat, InteractiveElement, IntoElement, KeyBinding, KeyDownEvent, KeyUpEvent, ModifiersChangedEvent, ParentElement, Pixels, Rems, Render, RenderOnce, Stateful, StatefulInteractiveElement, Styled, WeakEntity, Window, actions, + assets::IconName, base::Selectable, component::{ - Sizable, Theme, ThemeRegistry, WindowExt, + Icon, Sizable, Theme, ThemeRegistry, WindowExt, input::{Input, InputEvent, InputState}, notification::Notification, spinner::Spinner, @@ -61,6 +63,7 @@ mod social; mod stream_stats; pub mod style; mod surface; +mod tow; mod voice_note; mod voice_settings; mod voice_stats; @@ -318,7 +321,7 @@ pub fn community_name(community: &Community) -> &str { CommunityKind::Group => &community.name, CommunityKind::Direct { peer } if community.name.is_empty() => &peer.username, CommunityKind::Direct { .. } => &community.name, - CommunityKind::Notes => "Notes", + CommunityKind::Notes => w().gui.notes, } } @@ -343,7 +346,7 @@ pub fn community_icon( }, CommunityKind::Direct { peer } => avatar(palette, peer, size, font, avatars), CommunityKind::Notes => { - badge(palette, community.id, "Notes", size, font).rounded(px(radius::SM)) + badge(palette, community.id, w().gui.notes, size, font).rounded(px(radius::SM)) } } } @@ -352,12 +355,7 @@ pub const KB: f64 = 1024.0; pub const MB: f64 = KB * 1024.0; const GB: f64 = MB * 1024.0; -pub const STAMP: &str = "%b %-d, %H:%M"; -pub const YEAR_STAMP: &str = "%b %-d %Y, %H:%M"; pub const CLOCK: &str = "%H:%M"; -pub const DAY: &str = "%b %-d"; -pub const DAY_YEAR: &str = "%b %-d, %Y"; -pub const DATE: &str = "%b %-d %Y"; pub fn storage(bytes: u64) -> String { let bytes = bytes as f64; @@ -375,12 +373,22 @@ pub fn millis_time(millis: u64, format: &str) -> String { return String::new(); }; - timestamp - .to_zoned_datetime(TimeZone::system()) - .strftime(format) + let zoned = timestamp.to_zoned_datetime(TimeZone::system()); + zoned + .strftime(&month_named(format, zoned.month())) .to_string() } +pub fn month_named(format: &str, month: i8) -> String { + let name = crate::lang::w() + .common + .months + .split(' ') + .nth(month as usize - 1) + .unwrap_or_default(); + format.replace("%b", name) +} + pub use parts::motion; pub fn hoverable(id: impl Into, element: Div, palette: Palette) -> Stateful
{ @@ -481,19 +489,18 @@ impl RenderOnce for Trigger { } pub fn rank_tag(rank: Option, palette: Palette) -> Option
{ - let rank = rank?; - let color = match rank { - Rank::Member => return None, - Rank::Builder => palette.text, - _ => palette.muted, - }; - - Some( - div() - .text_size(text(style::text::CAPTION)) - .text_color(color) - .child(rank.label()), - ) + let tag = div() + .flex_shrink_0() + .text_size(text(style::text::CAPTION)) + .text_color(palette.muted); + match rank? { + Rank::Member => None, + Rank::Builder => Some( + tag.text_color(palette.accent) + .child(Icon::new(IconName::Shield).size(px(size::ICON_SM))), + ), + rank => Some(tag.child(rank.label())), + } } pub fn presence_color(presence: Presence, palette: Palette) -> Hsla { @@ -570,10 +577,10 @@ impl Connection { fn connection_notice(connection: &Connection, palette: Palette) -> Option
{ let (label, color) = match connection { - Connection::Connecting => ("Connecting…".to_string(), palette.muted), + Connection::Connecting => (w().gui.connecting.to_string(), palette.muted), Connection::Connected => return None, Connection::Lost { error, attempts } => { - (format!("Reconnecting… {error} ({attempts})"), palette.alert) + (w().gui.reconnecting(attempts, error), palette.alert) } }; Some( @@ -660,6 +667,7 @@ impl Yumush { }) .detach(); + sidebar::wander(cx); let voice = VoiceControls::new(&settings.voice, window, cx); let server = network.server(); @@ -765,7 +773,7 @@ impl Yumush { return; }; if !self.connection.is_connected() { - window.push_notification(Notification::error("Not connected"), cx); + window.push_notification(Notification::error(w().gui.not_connected), cx); return; } if self.user.is_some() { @@ -1205,13 +1213,15 @@ impl Yumush { } => { self.leave_voice_in(community_id, cx); self.chat.remove_community(community_id); - let action = match sanction { - Sanction::Ban => "Banned from", - Sanction::Kick => "Kicked from", - }; - let text = match reason { - Some(reason) => format!("{action} {community_name}: {reason}"), - None => format!("{action} {community_name}"), + let text = match (sanction, reason) { + (Sanction::Ban, Some(reason)) => { + w().gui.banned_reason(community_name, reason) + } + (Sanction::Ban, None) => w().gui.banned(community_name), + (Sanction::Kick, Some(reason)) => { + w().gui.kicked_reason(community_name, reason) + } + (Sanction::Kick, None) => w().gui.kicked(community_name), }; window.push_notification(Notification::warning(text), cx); } @@ -1405,6 +1415,9 @@ impl Render for Yumush { self.fullscreen = fullscreen; window.toggle_fullscreen(); } + if window.focused(cx).is_none() { + window.focus(&self.focus, cx); + } self.hide_idle_cursor(window, cx); self.schedule_pump(window, cx); let palette = palette(cx); @@ -1432,7 +1445,7 @@ impl Render for Yumush { this.zoom = None; cx.notify(); } else if this.chat.friends_open { - this.close_friends(cx); + this.close_friends(window, cx); } else if this.chat.goto.open { this.close_jump(window, cx); } else if this.fullscreen { diff --git a/crates/client/src/gui/auth.rs b/crates/client/src/gui/auth.rs index 15a4b2a..97630b6 100644 --- a/crates/client/src/gui/auth.rs +++ b/crates/client/src/gui/auth.rs @@ -18,6 +18,7 @@ use super::{ text, widget::{field, frame}, }; +use crate::lang::w; pub struct Auth { server_input: Entity, @@ -30,7 +31,7 @@ pub struct Auth { impl Auth { pub fn new(server: &crate::Server, window: &mut Window, cx: &mut Context) -> Self { - let server_input = new_input("Server", window, cx); + let server_input = new_input(w().auth.server, window, cx); server_input.update(cx, |input, cx| input.set_value(&server.address, window, cx)); cx.subscribe_in(&server_input, window, |this, _, event, _, cx| { if matches!(event, InputEvent::PressEnter { .. }) { @@ -38,9 +39,9 @@ impl Auth { } }) .detach(); - let username_input = new_input("Username...", window, cx); - let password_input = new_input("Password...", window, cx); - let invite_input = new_input("Invite code...", window, cx); + let username_input = new_input(w().auth.username_placeholder, window, cx); + let password_input = new_input(w().auth.password_placeholder, window, cx); + let invite_input = new_input(w().auth.invite_placeholder, window, cx); password_input.update(cx, |input, cx| input.set_masked(true, window, cx)); username_input.update(cx, |input, cx| input.focus(window, cx)); @@ -162,8 +163,8 @@ impl Yumush { pub(super) fn auth_page(&self, route: Route, cx: &mut Context) -> impl IntoElement { let palette = palette(cx); let action_label = match route { - Route::Register => "Register", - Route::Login | Route::Chat => "Log in", + Route::Register => w().auth.register, + Route::Login | Route::Chat => w().auth.log_in, }; let entity = cx.entity(); @@ -185,8 +186,14 @@ impl Yumush { let title = server.map_or_else(|| "yumush".to_string(), |settings| settings.name.clone()); let tabs = segment_track(palette) - .child(tab(palette, &entity, Route::Login, "Log in", route)) - .child(tab(palette, &entity, Route::Register, "Register", route)); + .child(tab(palette, &entity, Route::Login, w().auth.log_in, route)) + .child(tab( + palette, + &entity, + Route::Register, + w().auth.register, + route, + )); let invite = (route == Route::Register && !registration_open) .then(|| field(palette, &self.auth.invite_input)); @@ -213,7 +220,7 @@ impl Yumush { div() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child("Maintenance") + .child(w().auth.maintenance) })) .children(self.saved_accounts(&entity, palette)) .child(tabs) @@ -242,7 +249,7 @@ impl Yumush { .justify_between() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child("Accept any certificate") + .child(w().auth.accept_any_cert) .child(super::parts::toggle( "any_cert_switch", self.auth.any_cert, @@ -308,7 +315,7 @@ impl Yumush { }); }, ) - .tip("Forget") + .tip(w().auth.forget) .size(px(size::CHIP)) .flex() .items_center() diff --git a/crates/client/src/gui/builder.rs b/crates/client/src/gui/builder.rs index 3b2568a..89d346f 100644 --- a/crates/client/src/gui/builder.rs +++ b/crates/client/src/gui/builder.rs @@ -11,6 +11,7 @@ mod ui; mod users; mod voice; +use crate::lang::{Label as _, w}; use common::model::Id; use std::{fmt::Display, future::Future, path::PathBuf}; @@ -69,18 +70,34 @@ impl BuilderTab { Self::Log, ]; + pub(super) fn id(self) -> &'static str { + match self { + Self::Overview => "overview", + Self::Users => "users", + Self::Communities => "communities", + Self::Messages => "messages", + Self::Voice => "voice", + Self::Storage => "storage", + Self::Access => "access", + Self::Reports => "reports", + Self::Server => "server", + Self::Log => "log", + } + } + pub(super) fn label(self) -> &'static str { + let w = &w().builder; match self { - Self::Overview => "Overview", - Self::Users => "Users", - Self::Communities => "Communities", - Self::Messages => "Messages", - Self::Voice => "Voice", - Self::Storage => "Storage", - Self::Access => "Access", - Self::Reports => "Reports", - Self::Server => "Server", - Self::Log => "Log", + Self::Overview => w.overview, + Self::Users => w.users, + Self::Communities => w.communities, + Self::Messages => w.messages, + Self::Voice => w.voice, + Self::Storage => w.storage, + Self::Access => w.access, + Self::Reports => w.reports, + Self::Server => w.server, + Self::Log => w.log, } } } @@ -169,7 +186,7 @@ impl Yumush { BuilderTab::Voice => vec![ plain_button( "refresh_voice_button".to_string(), - "Refresh", + w().builder.refresh, palette, entity_action(entity, |yumush, window, cx| { yumush.load_voice_rooms(window, cx) @@ -180,7 +197,7 @@ impl Yumush { BuilderTab::Server if self.server_form(cx) != self.server => vec![ accent_button( "save_server", - "Save", + w().builder.save, palette, entity_action(entity, |yumush, window, cx| { yumush.save_server_settings(window, cx) @@ -192,7 +209,7 @@ impl Yumush { icon_button( "export_builder_log".to_string(), IconName::Download, - "Export", + w().builder.export, palette.muted, palette, entity_action(entity, |yumush, window, cx| { @@ -233,7 +250,7 @@ impl Yumush { .filter(|count| *count > 0); clickable( - format!("builder_tab_{label}"), + format!("builder_tab_{}", tab.id()), palette, entity_action(entity, move |yumush, window, cx| { yumush.select_builder_tab(tab, window, cx) @@ -268,7 +285,7 @@ impl Yumush { .justify_between() .text_size(text(text::LABEL)) .text_color(palette.muted) - .child("Ghost") + .child(w().builder.ghost) .child(super::parts::toggle( "ghost_switch", enabled, diff --git a/crates/client/src/gui/builder/access.rs b/crates/client/src/gui/builder/access.rs index 39e77f7..d119eb1 100644 --- a/crates/client/src/gui/builder/access.rs +++ b/crates/client/src/gui/builder/access.rs @@ -12,9 +12,9 @@ use super::ui::{ accent_button, card, card_header, confirmed, delete_icon_button, fixed, icon_button, pill, toolbar, }; -use crate::gui::STAMP; use crate::gui::style::{size, space, text}; use crate::gui::{Palette, Yumush, entity_action, millis_time, notify_error, text, widget::field}; +use crate::lang::w; fn list_card(header: Div, rows: Vec
, empty: &str, palette: Palette) -> Div { let body = if rows.is_empty() { @@ -48,9 +48,16 @@ fn invite_row( let copy_code = invite.code.clone(); let delete_code = invite.code.clone(); let expiry = invite.expires_at.map_or_else( - || "never".to_string(), - |at| format!("expires {}", millis_time(at, STAMP)), + || w().builder_access.never.to_string(), + |at| { + w().builder_access + .expires(millis_time(at, crate::lang::w().common.stamp)) + }, ); + let left = match invite.uses_left { + 1 => w().builder_access.one_use_left.to_string(), + uses => w().builder_access.uses_left(uses), + }; div() .min_h(px(size::ROW)) @@ -76,17 +83,13 @@ fn invite_row( .text_size(text(text::CAPTION)) .text_color(palette.muted) .truncate() - .child(format!( - "{} {} left · {expiry}", - invite.uses_left, - if invite.uses_left == 1 { "use" } else { "uses" } - )), + .child(format!("{left} · {expiry}")), ), ) .child(icon_button( format!("copy_invite_{}", invite.code), IconName::Copy, - "Copy", + w().builder_access.copy, palette.muted, palette, entity_action(entity, move |yumush, _, cx| { @@ -107,7 +110,7 @@ fn ban_row(ban: &ServerBan, entity: &Entity, palette: Palette) -> Div { let remove_id = ban.id; let kind = match ban.kind { ServerBanKind::Ip => "IP", - ServerBanKind::Username => "Username", + ServerBanKind::Username => w().builder_access.username, }; div() @@ -144,7 +147,7 @@ fn ban_row(ban: &ServerBan, entity: &Entity, palette: Palette) -> Div { .child(icon_button( format!("remove_ban_{}", ban.id), IconName::X, - "Remove", + w().builder_access.remove, palette.muted, palette, entity_action(entity, move |yumush, window, cx| { @@ -260,7 +263,7 @@ impl Yumush { fixed(size::THUMB, field(palette, &self.chat.invite_hours)), accent_button( "create_invite", - "Create", + w().builder_access.create, palette, entity_action(entity, |yumush, window, cx| { yumush.create_invite(window, cx) @@ -269,7 +272,7 @@ impl Yumush { .into_any_element(), ]) .into_any_element(); - let invite_header = card_header("Invite codes", vec![controls], palette); + let invite_header = card_header(w().builder_access.invite_codes, vec![controls], palette); let invites = self.chat.builder_invites.iter().map(|invite| { let pending = self.chat.pending_invite_delete.as_deref() == Some(invite.code.as_str()); invite_row(invite, pending, entity, palette) @@ -279,12 +282,23 @@ impl Yumush { .builder_bans .iter() .map(|ban| ban_row(ban, entity, palette)); - let ban_header = card_header("Bans", Vec::new(), palette); + let ban_header = card_header(w().builder_access.bans, Vec::new(), palette); vec![ - list_card(invite_header, invites.collect(), "No invite codes", palette) - .into_any_element(), - list_card(ban_header, bans.collect(), "No bans", palette).into_any_element(), + list_card( + invite_header, + invites.collect(), + w().builder_access.no_invite_codes, + palette, + ) + .into_any_element(), + list_card( + ban_header, + bans.collect(), + w().builder_access.no_bans, + palette, + ) + .into_any_element(), ] } } diff --git a/crates/client/src/gui/builder/backups.rs b/crates/client/src/gui/builder/backups.rs index 66ab034..313ec3b 100644 --- a/crates/client/src/gui/builder/backups.rs +++ b/crates/client/src/gui/builder/backups.rs @@ -12,10 +12,11 @@ use super::{ ui::{accent_button, card, card_header, confirmed, delete_icon_button, icon_button, list_row}, }; use crate::gui::{ - DATE, Palette, Yumush, entity_action, millis_time, notify_error, storage, + Palette, Yumush, entity_action, millis_time, notify_error, storage, style::{size, space, text}, text, }; +use crate::lang::w; const STORAGE_WIDTH: f32 = 72.; @@ -24,7 +25,7 @@ fn backup_row(info: &BackupInfo, pending: bool, entity: &Entity, palette let export = icon_button( format!("export_backup_{}", info.name), IconName::Download, - "Export", + w().builder_backups.export, palette.muted, palette, entity_action(entity, move |yumush, window, cx| { @@ -63,7 +64,7 @@ fn backup_row(info: &BackupInfo, pending: bool, entity: &Entity, palette .flex_shrink_0() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child(millis_time(info.created_ms, DATE)), + .child(millis_time(info.created_ms, crate::lang::w().common.date)), ) .child( div() @@ -83,7 +84,7 @@ impl Yumush { pub(super) fn backups_card(&self, entity: &Entity, palette: Palette) -> Div { let create = accent_button( "create_backup", - "Create", + w().builder_backups.create, palette, entity_action(entity, |yumush, window, cx| { yumush.create_backup(window, cx) @@ -105,7 +106,7 @@ impl Yumush { .justify_center() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child("No backups") + .child(w().builder_backups.no_backups) } else { div() .flex() @@ -118,7 +119,11 @@ impl Yumush { }; card(palette) - .child(card_header("Backups", vec![create], palette)) + .child(card_header( + w().builder_backups.backups, + vec![create], + palette, + )) .child(body) } diff --git a/crates/client/src/gui/builder/communities.rs b/crates/client/src/gui/builder/communities.rs index 4013414..c216680 100644 --- a/crates/client/src/gui/builder/communities.rs +++ b/crates/client/src/gui/builder/communities.rs @@ -24,6 +24,7 @@ use crate::gui::{ text, widget::search_text, }; +use crate::lang::w; impl Yumush { pub(super) fn set_builder_community_voice( @@ -309,7 +310,7 @@ impl Yumush { .child(Input::new(&self.chat.builder_search)), ), ) - .child(rows_body(rows, "No communities", palette)) + .child(rows_body(rows, w().builder_communities.empty, palette)) .into_any_element(), ] } @@ -355,7 +356,11 @@ impl Yumush { ) .child(plain_button( format!("transfer_to_{}", member.user.id), - if pending { "Confirm" } else { "Transfer" }, + if pending { + w().builder_communities.confirm + } else { + w().builder_communities.transfer + }, palette, entity_action(entity, move |yumush, window, cx| { yumush.transfer_to(user_id, window, cx) @@ -384,9 +389,12 @@ impl Yumush { .as_ref() .is_some_and(|transfer| transfer.community_id == id); let owner = summary.owner.as_ref().map_or(String::new(), |owner| { - format!(" · owner {}", owner.username) + format!(" · {}", w().builder_communities.owner(&owner.username)) }); - let meta = format!("{} members{owner}", summary.members); + let meta = format!( + "{}{owner}", + w().builder_communities.members(summary.members) + ); let row = div() .min_h(px(size::ROW)) @@ -424,11 +432,14 @@ impl Yumush { .child(meta), ), ) - .children((!voice_enabled).then(|| pill("Voice off", palette.muted, palette))) + .children( + (!voice_enabled) + .then(|| pill(w().builder_communities.voice_off, palette.muted, palette)), + ) .child(icon_button( format!("open_community_{id}"), IconName::ArrowUpRight, - "Open", + w().builder_communities.open, palette.muted, palette, entity_action(entity, move |yumush, window, cx| { @@ -438,7 +449,7 @@ impl Yumush { .child(icon_button( format!("log_community_{id}"), IconName::ScrollText, - "Log", + w().builder_communities.log, palette.muted, palette, entity_action(entity, move |yumush, window, cx| { @@ -453,9 +464,9 @@ impl Yumush { IconName::PhoneOff }, if voice_enabled { - "Voice on" + w().builder_communities.voice_on } else { - "Voice off" + w().builder_communities.voice_off }, palette.muted, palette, @@ -466,7 +477,7 @@ impl Yumush { .child(icon_button( format!("transfer_community_{id}"), IconName::ArrowRightLeft, - "Transfer", + w().builder_communities.transfer, if expanded { palette.text } else { @@ -482,9 +493,9 @@ impl Yumush { format!("delete_community_{id}_{pending_delete}"), IconName::Trash, if pending_delete { - "Confirm delete" + w().builder_communities.confirm_delete } else { - "Delete" + w().builder_communities.delete }, if pending_delete { palette.on_accent diff --git a/crates/client/src/gui/builder/log.rs b/crates/client/src/gui/builder/log.rs index 01457e9..5fa67f7 100644 --- a/crates/client/src/gui/builder/log.rs +++ b/crates/client/src/gui/builder/log.rs @@ -17,7 +17,6 @@ use super::{ save_directory, ui::{accent_button, card, end_of_day_ms, fixed, list_row, pill, start_of_day_ms, toolbar}, }; -use crate::gui::STAMP; use crate::gui::{ Palette, Yumush, community_settings::user_name, @@ -26,69 +25,58 @@ use crate::gui::{ text, widget::{field, search_text}, }; +use crate::lang::{Label as _, w}; fn builder_log_text(entry: &AdminLogEntry) -> String { let actor = user_name(&entry.actor); let target = user_name(&entry.target); let community = entry.community.as_deref().unwrap_or_default(); + let words = &w().builder_log; match &entry.action { - AdminAction::RoleChanged { role } => format!("{actor} set {target} to {}", role.as_str()), - AdminAction::UserDeleted => format!("{actor} deleted {target}"), - AdminAction::UserSuspended => format!("{actor} suspended {target}"), - AdminAction::UserUnsuspended => format!("{actor} unsuspended {target}"), - AdminAction::SessionsRevoked => format!("{actor} revoked sessions of {target}"), - AdminAction::PasswordReset => format!("{actor} reset password of {target}"), - AdminAction::ProfileCleared => format!("{actor} cleared profile of {target}"), - AdminAction::UserCreated => format!("{actor} created {target}"), - AdminAction::CommunityDeleted => format!("{actor} deleted {community}"), - AdminAction::OwnershipTransferred => { - format!("{actor} transferred {community} to {target}") - } - AdminAction::SettingsChanged => format!("{actor} changed settings"), - AdminAction::UserRenamed { from } => format!("{actor} renamed {from} to {target}"), - AdminAction::UserTimedOut { minutes: 0 } => format!("{actor} cleared timeout of {target}"), - AdminAction::UserTimedOut { minutes } => { - format!("{actor} timed out {target} for {minutes} min") - } - AdminAction::UserBanned { .. } => format!("{actor} banned {target}"), - AdminAction::BanRemoved => format!("{actor} removed a ban"), - AdminAction::InviteCreated => format!("{actor} created an invite code"), - AdminAction::InviteDeleted => format!("{actor} deleted an invite code"), + AdminAction::RoleChanged { role } => words.role_changed(actor, role.label(), target), + AdminAction::UserDeleted => words.user_deleted(actor, target), + AdminAction::UserSuspended => words.user_suspended(actor, target), + AdminAction::UserUnsuspended => words.user_unsuspended(actor, target), + AdminAction::SessionsRevoked => words.sessions_revoked(actor, target), + AdminAction::PasswordReset => words.password_reset(actor, target), + AdminAction::ProfileCleared => words.profile_cleared(actor, target), + AdminAction::UserCreated => words.user_created(actor, target), + AdminAction::CommunityDeleted => words.community_deleted(actor, community), + AdminAction::OwnershipTransferred => words.ownership_transferred(actor, community, target), + AdminAction::SettingsChanged => words.settings_changed(actor), + AdminAction::UserRenamed { from } => words.user_renamed(actor, from, target), + AdminAction::UserTimedOut { minutes: 0 } => words.user_timeout_cleared(actor, target), + AdminAction::UserTimedOut { minutes } => words.user_timed_out(actor, minutes, target), + AdminAction::UserBanned { .. } => words.user_banned(actor, target), + AdminAction::BanRemoved => words.ban_removed(actor), + AdminAction::InviteCreated => words.invite_created(actor), + AdminAction::InviteDeleted => words.invite_deleted(actor), AdminAction::ReportHandled { status } => { - format!("{actor} marked a report of {target} as {}", status.as_str()) - } - AdminAction::MessageDeleted => { - format!("{actor} deleted a message of {target} in {community}") - } - AdminAction::UserPurged { messages } => { - format!("{actor} purged {target}, {messages} messages") + words.report_handled(actor, status.label(), target) } - AdminAction::VoiceKicked => format!("{actor} kicked {target} from voice"), - AdminAction::VoiceMuted { muted: true } => format!("{actor} muted {target} in voice"), - AdminAction::VoiceMuted { muted: false } => format!("{actor} unmuted {target} in voice"), + AdminAction::MessageDeleted => words.message_deleted(actor, community, target), + AdminAction::UserPurged { messages } => words.user_purged(actor, messages, target), + AdminAction::VoiceKicked => words.voice_kicked(actor, target), + AdminAction::VoiceMuted { muted: true } => words.voice_muted(actor, target), + AdminAction::VoiceMuted { muted: false } => words.voice_unmuted(actor, target), AdminAction::CommunityVoiceSet { enabled: true } => { - format!("{actor} enabled voice in {community}") + words.community_voice_enabled(actor, community) } AdminAction::CommunityVoiceSet { enabled: false } => { - format!("{actor} disabled voice in {community}") + words.community_voice_disabled(actor, community) } AdminAction::Community(action) => { - crate::gui::community_settings::community_log_text(&actor, &target, action) - } - - AdminAction::AttachmentDeleted => { - format!("{actor} deleted an attachment of {target} in {community}") - } - AdminAction::GhostEnabled => format!("{actor} enabled ghost mode"), - AdminAction::GhostDisabled => format!("{actor} disabled ghost mode"), - AdminAction::GhostVisit => format!("{actor} visited {community} as ghost"), - AdminAction::GhostVoice { seconds } => { - format!("{actor} listened in {community} as ghost for {seconds}s") + crate::gui::community_settings::community_log_text(actor, target, action) } - AdminAction::BackupCreated { name } => format!("{actor} created backup {name}"), - AdminAction::BackupDeleted { name } => format!("{actor} deleted backup {name}"), - AdminAction::BackupDownloaded { name } => format!("{actor} exported backup {name}"), + AdminAction::AttachmentDeleted => words.attachment_deleted(actor, community, target), + AdminAction::GhostEnabled => words.ghost_enabled(actor), + AdminAction::GhostDisabled => words.ghost_disabled(actor), + AdminAction::GhostVisit => words.ghost_visit(actor, community), + AdminAction::GhostVoice { seconds } => words.ghost_voice(actor, community, seconds), + AdminAction::BackupCreated { name } => words.backup_created(actor, name), + AdminAction::BackupDeleted { name } => words.backup_deleted(actor, name), + AdminAction::BackupDownloaded { name } => words.backup_downloaded(actor, name), } } @@ -209,7 +197,7 @@ fn builder_log_row(entry: &AdminLogEntry, palette: Palette) -> Div { div() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child(millis_time(entry.created_at, STAMP)), + .child(millis_time(entry.created_at, crate::lang::w().common.stamp)), ), ) .children( @@ -229,7 +217,7 @@ impl Yumush { self.filter_user(&self.chat.builder_log_actor, cx), self.filter_user(&self.chat.builder_log_target, cx), ) else { - window.push_notification(Notification::error("Unknown user"), cx); + window.push_notification(Notification::error(w().builder_log.unknown_user), cx); return; }; let action = self @@ -296,7 +284,7 @@ impl Yumush { fixed(size::THUMB, field(palette, &self.chat.builder_log_to)), accent_button( "apply_builder_log", - "Apply", + w().builder_log.apply, palette, entity_action(entity, |yumush, window, cx| { yumush.load_builder_logs(window, cx) @@ -322,7 +310,7 @@ impl Yumush { .justify_center() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child("No entries") + .child(w().builder_log.no_entries) } else { div().flex().flex_col().children(rows) }; diff --git a/crates/client/src/gui/builder/messages.rs b/crates/client/src/gui/builder/messages.rs index ef2e739..a68c5a6 100644 --- a/crates/client/src/gui/builder/messages.rs +++ b/crates/client/src/gui/builder/messages.rs @@ -16,7 +16,6 @@ use gpui_kit::{ use super::ui::{ accent_button, card, confirmed, delete_icon_button, end_of_day_ms, icon_button, start_of_day_ms, }; -use crate::gui::YEAR_STAMP; use crate::gui::style::{size, space, stroke, text}; use crate::gui::{ Palette, Yumush, @@ -26,6 +25,7 @@ use crate::gui::{ text, widget::{field, search_text}, }; +use crate::lang::w; fn message_hit_row( hit: &MessageHit, @@ -46,7 +46,7 @@ fn message_hit_row( let open = icon_button( format!("open_message_{}", hit.message.id), IconName::MessageSquare, - "Open chat", + w().builder_messages.open_chat, palette.muted, palette, entity_action(entity, move |yumush, window, cx| { @@ -67,9 +67,9 @@ fn message_hit_row( format!("purge_message_user_{}_{purge_pending}", hit.message.id), IconName::UserX, if purge_pending { - "Confirm purge" + w().builder_messages.confirm_purge } else { - "Purge user" + w().builder_messages.purge_user }, palette.danger, palette, @@ -131,7 +131,10 @@ fn message_hit_row( .flex_shrink_0() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child(millis_time(hit.message.created_at, YEAR_STAMP)), + .child(millis_time( + hit.message.created_at, + crate::lang::w().common.year_stamp, + )), ) .child( div() @@ -209,7 +212,7 @@ impl Yumush { ) .child(accent_button( "search_messages", - "Search", + w().builder_messages.search, palette, entity_action(entity, |yumush, window, cx| { yumush.search_messages(window, cx) @@ -236,7 +239,7 @@ impl Yumush { .justify_center() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child("No messages") + .child(w().builder_messages.no_messages) } else { div() .relative() @@ -263,12 +266,15 @@ impl Yumush { pub(super) fn search_messages(&mut self, window: &mut Window, cx: &mut Context) { let text = search_text(&self.chat.builder_message_text, cx); let Some(user_id) = self.filter_user(&self.chat.builder_message_user, cx) else { - window.push_notification(Notification::error("Unknown user"), cx); + window.push_notification(Notification::error(w().builder_messages.unknown_user), cx); return; }; let Some(community_id) = self.filter_community(&self.chat.builder_message_community, cx) else { - window.push_notification(Notification::error("Unknown community"), cx); + window.push_notification( + Notification::error(w().builder_messages.unknown_community), + cx, + ); return; }; let after_ms = start_of_day_ms(&search_text(&self.chat.builder_message_from, cx)); diff --git a/crates/client/src/gui/builder/overview.rs b/crates/client/src/gui/builder/overview.rs index 2a2b177..2dec2d4 100644 --- a/crates/client/src/gui/builder/overview.rs +++ b/crates/client/src/gui/builder/overview.rs @@ -10,13 +10,14 @@ use std::time::Duration; use super::ui::{card, card_header, stat_tile}; use crate::gui::{ - DAY, Palette, Yumush, + Palette, Yumush, builder::BuilderTab, chat::View, storage, style::{radius, size, space, text}, text, voice_stats, }; +use crate::lang::w; const CHART_HEIGHT: f32 = 80.; const PANEL_HEIGHT: f32 = 140.; @@ -24,7 +25,13 @@ const SERVER_STATS_TICK: Duration = Duration::from_secs(1); fn day_label(day: u64) -> String { Timestamp::from_millisecond((day * DAY_MILLIS) as i64) - .map(|timestamp| timestamp.strftime(DAY).to_string()) + .map(|timestamp| { + let format = crate::gui::month_named( + w().common.day, + timestamp.to_zoned_datetime(jiff::tz::TimeZone::UTC).month(), + ); + timestamp.strftime(&format).to_string() + }) .unwrap_or_default() } @@ -180,12 +187,18 @@ impl Yumush { let messages = stats.iter().map(|stat| stat.messages).sum::(); let tiles = [ - ("Users", overview.users.to_string()), - ("Builders", overview.builders.to_string()), - ("Communities", overview.communities.to_string()), - ("Online", overview.online.to_string()), - ("In voice", overview.voice.to_string()), - ("Storage", storage(overview.storage_bytes)), + (w().builder_overview.users, overview.users.to_string()), + (w().builder_overview.builders, overview.builders.to_string()), + ( + w().builder_overview.communities, + overview.communities.to_string(), + ), + (w().builder_overview.online, overview.online.to_string()), + (w().builder_overview.in_voice, overview.voice.to_string()), + ( + w().builder_overview.storage, + storage(overview.storage_bytes), + ), ]; let mut rows: Vec
= tiles @@ -197,14 +210,14 @@ impl Yumush { .flex() .gap(px(space::MD)) .child(bar_chart( - "Active users", + w().builder_overview.active_users, stats, |stat| stat.active_users, active, palette, )) .child(bar_chart( - "Messages", + w().builder_overview.messages, stats, |stat| stat.messages, messages, @@ -214,7 +227,11 @@ impl Yumush { if let Some(stats) = &self.chat.server_stats { rows.push( card(palette) - .child(card_header("Server", Vec::new(), palette)) + .child(card_header( + w().builder_overview.server, + Vec::new(), + palette, + )) .child(div().p(px(space::LG)).child(voice_stats::stats_panel( stats, &|id| self.chat.name_of(id), diff --git a/crates/client/src/gui/builder/reports.rs b/crates/client/src/gui/builder/reports.rs index 1e8de2f..498afd6 100644 --- a/crates/client/src/gui/builder/reports.rs +++ b/crates/client/src/gui/builder/reports.rs @@ -1,3 +1,4 @@ +use crate::lang::{Label as _, w}; use common::model::Id; use std::future::Future; @@ -11,7 +12,6 @@ use gpui_kit::{ }; use super::ui::{danger_button, list_card, pill, plain_button}; -use crate::gui::STAMP; use crate::{ gui::{ Palette, Yumush, avatar, badge, clickable, @@ -169,7 +169,7 @@ impl Yumush { pub(super) fn report_filters(&self, entity: &Entity, palette: Palette) -> Div { div().flex().child( segment_track(palette).children(REPORT_FILTERS.map(|status| { - let label = status.map_or("All", ReportStatus::label); + let label = status.map_or(w().builder_reports.all, ReportStatus::label); segment( clickable( label, @@ -197,7 +197,7 @@ impl Yumush { vec![ self.report_filters(entity, palette).into_any_element(), - list_card(None, rows, "No reports", palette).into_any_element(), + list_card(None, rows, w().builder_reports.no_reports, palette).into_any_element(), ] } @@ -219,7 +219,7 @@ impl Yumush { None => badge( palette, report.id, - "someone", + w().builder_reports.someone, px(size::AVATAR), text_fn(text::CAPTION), ) @@ -260,7 +260,7 @@ impl Yumush { .text_size(text_fn(text::CAPTION)) .text_color(palette.muted) .truncate() - .child(format!("reported by {}", user_name(&report.reporter))), + .child(w().builder_reports.reported_by(user_name(&report.reporter))), )); let meta = div() .flex_shrink_0() @@ -268,15 +268,21 @@ impl Yumush { .text_color(palette.muted) .child(format!( "{} · {}", - report.community.as_deref().unwrap_or("deleted community"), - millis_time(report.created_at, STAMP) + report + .community + .as_deref() + .unwrap_or(w().builder_reports.deleted_community), + millis_time(report.created_at, crate::lang::w().common.stamp) )); let actions = self.report_actions(report, entity, palette); let handled = (report.status != ReportStatus::Open).then(|| { div() .text_size(text_fn(text::CAPTION)) .text_color(palette.muted) - .child(format!("by {}", user_name(&report.handled_by))) + .child( + w().builder_reports + .handled_by(user_name(&report.handled_by)), + ) }); div() @@ -341,7 +347,7 @@ impl Yumush { let mut buttons = vec![ plain_button( format!("resolve_report_{}", report.id), - "Resolve", + w().builder_reports.resolve, palette, entity_action(entity, move |yumush, window, cx| { yumush.handle_report(resolve_id, ReportStatus::Resolved, window, cx) @@ -350,7 +356,7 @@ impl Yumush { .into_any_element(), plain_button( format!("dismiss_report_{}", report.id), - "Dismiss", + w().builder_reports.dismiss, palette, entity_action(entity, move |yumush, window, cx| { yumush.handle_report(dismiss_id, ReportStatus::Dismissed, window, cx) @@ -362,7 +368,7 @@ impl Yumush { buttons.push( plain_button( format!("delete_report_message_{}", report.id), - "Delete message", + w().builder_reports.delete_message, palette, entity_action(entity, move |yumush, window, cx| { yumush.delete_report_message(message_id, window, cx) @@ -378,7 +384,7 @@ impl Yumush { buttons.push( plain_button( format!("timeout_report_{}", report.id), - "Timeout 1h", + w().builder_reports.timeout, palette, entity_action(entity, move |yumush, window, cx| { yumush.timeout_report_target(timeout_id, window, cx) @@ -389,7 +395,7 @@ impl Yumush { buttons.push( danger_button( format!("ban_report_{}", report.id), - "Ban", + w().builder_reports.ban, palette, entity_action(entity, move |yumush, window, cx| { yumush.ban_report_target(ban_id, &ban_reason, window, cx) diff --git a/crates/client/src/gui/builder/server.rs b/crates/client/src/gui/builder/server.rs index 5619a77..9ceef4f 100644 --- a/crates/client/src/gui/builder/server.rs +++ b/crates/client/src/gui/builder/server.rs @@ -7,6 +7,7 @@ use gpui_kit::{ use super::ui::{field_row, list_card, number, to_bytes, to_units}; use crate::gui::{KB, MB, Palette, Yumush, notify_error, settings_page::segmented, widget::field}; +use crate::lang::w; fn input_text(input: &Entity, cx: &App) -> String { input.read(cx).text().to_string() @@ -123,7 +124,7 @@ impl Yumush { pub(super) fn save_server_settings(&mut self, window: &mut Window, cx: &mut Context) { let Some(settings) = self.server_form(cx) else { - window.push_notification(Notification::error("Invalid number"), cx); + window.push_notification(Notification::error(w().builder_server.invalid_number), cx); return; }; let network = self.network.clone(); @@ -145,16 +146,19 @@ impl Yumush { pub(super) fn server_body(&self, entity: &Entity, palette: Palette) -> Vec { let general = vec![ field_row( - "Name", + w().builder_server.name, None, field(palette, &self.chat.server_name), palette, ), field_row( - "Registration", + w().builder_server.registration, None, segmented( - [(true, "Open"), (false, "Closed")], + [ + (true, w().builder_server.open), + (false, w().builder_server.closed), + ], self.chat.server_registration_open, entity, palette, @@ -163,10 +167,13 @@ impl Yumush { palette, ), field_row( - "Maintenance", + w().builder_server.maintenance, None, segmented( - [(false, "Off"), (true, "On")], + [ + (false, w().builder_server.off), + (true, w().builder_server.on), + ], self.chat.server_maintenance, entity, palette, @@ -175,7 +182,7 @@ impl Yumush { palette, ), field_row( - "Announcement", + w().builder_server.announcement, None, field(palette, &self.chat.server_announcement), palette, @@ -183,76 +190,76 @@ impl Yumush { ]; let limits = vec![ field_row( - "Max attachment (MB)", + w().builder_server.max_attachment, None, field(palette, &self.chat.server_limit), palette, ), field_row( - "Max avatar (KB)", + w().builder_server.max_avatar, None, field(palette, &self.chat.server_max_avatar), palette, ), field_row( - "Max message length", + w().builder_server.max_message_length, None, field(palette, &self.chat.server_max_message_length), palette, ), field_row( - "Communities per user", - Some("0 = unlimited"), + w().builder_server.communities_per_user, + Some(w().builder_server.zero_unlimited), field(palette, &self.chat.server_max_communities), palette, ), ]; let storage = vec![ field_row( - "User quota (MB)", - Some("0 = unlimited"), + w().builder_server.user_quota, + Some(w().builder_server.zero_unlimited), field(palette, &self.chat.server_user_quota), palette, ), field_row( - "Community quota (MB)", - Some("0 = unlimited"), + w().builder_server.community_quota, + Some(w().builder_server.zero_unlimited), field(palette, &self.chat.server_community_quota), palette, ), field_row( - "Message retention (days)", - Some("0 = off"), + w().builder_server.message_retention, + Some(w().builder_server.zero_off), field(palette, &self.chat.server_message_retention), palette, ), field_row( - "Attachment retention (days)", - Some("0 = off"), + w().builder_server.attachment_retention, + Some(w().builder_server.zero_off), field(palette, &self.chat.server_attachment_retention), palette, ), ]; let rate = vec![ field_row( - "Messages / min", - Some("0 = off"), + w().builder_server.messages_per_minute, + Some(w().builder_server.zero_off), field(palette, &self.chat.server_messages_per_minute), palette, ), field_row( - "Logins / min", - Some("0 = off"), + w().builder_server.logins_per_minute, + Some(w().builder_server.zero_off), field(palette, &self.chat.server_logins_per_minute), palette, ), ]; vec![ - list_card(Some("General"), general, "", palette).into_any_element(), - list_card(Some("Limits"), limits, "", palette).into_any_element(), - list_card(Some("Storage"), storage, "", palette).into_any_element(), - list_card(Some("Rate limits"), rate, "", palette).into_any_element(), + list_card(Some(w().builder_server.general), general, "", palette).into_any_element(), + list_card(Some(w().builder_server.limits), limits, "", palette).into_any_element(), + list_card(Some(w().builder_server.storage), storage, "", palette).into_any_element(), + list_card(Some(w().builder_server.rate_limits), rate, "", palette).into_any_element(), ] } } diff --git a/crates/client/src/gui/builder/storage.rs b/crates/client/src/gui/builder/storage.rs index 319791b..726ef69 100644 --- a/crates/client/src/gui/builder/storage.rs +++ b/crates/client/src/gui/builder/storage.rs @@ -17,13 +17,14 @@ use super::ui::{ toolbar, }; use crate::gui::{ - DATE, Palette, Yumush, + Palette, Yumush, community_settings::user_name, entity_action, millis_time, notify_error, storage, style::{radius, size, space, text}, text, widget::field, }; +use crate::lang::w; fn share(bytes: u64, max: u64) -> f32 { if max == 0 { @@ -137,7 +138,7 @@ fn attachment_row( "{} · {} · {}", user_name(&info.uploader), info.community, - millis_time(info.attachment.created_at, DATE) + millis_time(info.attachment.created_at, crate::lang::w().common.date) )), ), ) @@ -195,19 +196,31 @@ impl Yumush { ) }) .collect(); - let usage = - div() - .flex() - .gap(px(space::XL)) - .child( - div() - .flex_1() - .min_w_0() - .child(list_card(Some("Users"), users, "No data", palette).h_full()), - ) - .child(div().flex_1().min_w_0().child( - list_card(Some("Communities"), communities, "No data", palette).h_full(), - )); + let usage = div() + .flex() + .gap(px(space::XL)) + .child( + div().flex_1().min_w_0().child( + list_card( + Some(w().builder_storage.users), + users, + w().builder_storage.no_data, + palette, + ) + .h_full(), + ), + ) + .child( + div().flex_1().min_w_0().child( + list_card( + Some(w().builder_storage.communities), + communities, + w().builder_storage.no_data, + palette, + ) + .h_full(), + ), + ); let controls = toolbar(vec![ fixed( @@ -220,7 +233,7 @@ impl Yumush { ), accent_button( "search_attachments", - "Search", + w().builder_storage.search, palette, entity_action(entity, |yumush, window, cx| { yumush.search_attachments(window, cx) @@ -245,7 +258,7 @@ impl Yumush { .justify_center() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child("No attachments") + .child(w().builder_storage.no_attachments) } else { div() .flex() @@ -257,7 +270,11 @@ impl Yumush { })) }; let attachments = card(palette) - .child(card_header("Attachments", vec![controls], palette)) + .child(card_header( + w().builder_storage.attachments, + vec![controls], + palette, + )) .child(body); vec![ @@ -287,12 +304,15 @@ impl Yumush { pub(super) fn search_attachments(&self, window: &mut Window, cx: &mut Context) { let Some(user_id) = self.filter_user(&self.chat.builder_attachment_user, cx) else { - window.push_notification(Notification::error("Unknown user"), cx); + window.push_notification(Notification::error(w().builder_storage.unknown_user), cx); return; }; let Some(community_id) = self.filter_community(&self.chat.builder_attachment_community, cx) else { - window.push_notification(Notification::error("Unknown community"), cx); + window.push_notification( + Notification::error(w().builder_storage.unknown_community), + cx, + ); return; }; let network = self.network.clone(); diff --git a/crates/client/src/gui/builder/ui.rs b/crates/client/src/gui/builder/ui.rs index 2789a91..730e440 100644 --- a/crates/client/src/gui/builder/ui.rs +++ b/crates/client/src/gui/builder/ui.rs @@ -1,5 +1,6 @@ use crate::gui::style::{radius, size, space, text}; use crate::gui::{Palette, Tooltip as _, clickable, primary_button, text, widget}; +use crate::lang::w; use gpui_kit::{ AnyElement, App, Div, FontWeight, Hsla, IntoElement, ParentElement, Stateful, Styled, Window, assets::IconName, component::Icon, div, prelude::FluentBuilder as _, px, @@ -58,7 +59,11 @@ pub(super) fn delete_icon_button( icon_button( format!("{id}_{pending}"), IconName::Trash, - if pending { "Confirm" } else { "Delete" }, + if pending { + w().builder_ui.confirm + } else { + w().builder_ui.delete + }, palette.danger, palette, action, @@ -105,9 +110,13 @@ pub(super) fn confirm_button( action_button( format!("{id}_{pending}"), icon, - if pending { "Confirm" } else { label }, if pending { - "Click again to confirm" + w().builder_ui.confirm + } else { + label + }, + if pending { + w().builder_ui.confirm_tip } else { tip }, diff --git a/crates/client/src/gui/builder/users.rs b/crates/client/src/gui/builder/users.rs index c2a7bfc..3e19198 100644 --- a/crates/client/src/gui/builder/users.rs +++ b/crates/client/src/gui/builder/users.rs @@ -24,10 +24,10 @@ use gpui_kit::{ use super::ui::{ accent_button, action_button, action_group, card, confirm_button, confirmed, pill, plain_button, }; +use crate::lang::w; use crate::{ gui::{ - DATE, DAY, Palette, Tooltip as _, Yumush, avatar, clickable, entity_action, millis_time, - notify_error, + Palette, Tooltip as _, Yumush, avatar, clickable, entity_action, millis_time, notify_error, profile::user_link, style::{radius, size, space, text}, text, @@ -41,15 +41,17 @@ const MINUTES_PER_DAY: u64 = DAY_MILLIS / MINUTE_MILLIS; fn seen_text(last_seen: Option) -> String { let Some(last_seen) = last_seen else { - return "never".to_string(); + return w().builder_users.seen_never.to_string(); }; let minutes = now_ms().saturating_sub(last_seen) / MINUTE_MILLIS; match minutes { - 0 => "now".to_string(), - 1..MINUTES_PER_HOUR => format!("{minutes}m ago"), - MINUTES_PER_HOUR..MINUTES_PER_DAY => format!("{}h ago", minutes / MINUTES_PER_HOUR), - _ => millis_time(last_seen, DAY), + 0 => w().builder_users.seen_now.to_string(), + 1..MINUTES_PER_HOUR => w().builder_users.seen_minutes(minutes), + MINUTES_PER_HOUR..MINUTES_PER_DAY => { + w().builder_users.seen_hours(minutes / MINUTES_PER_HOUR) + } + _ => millis_time(last_seen, crate::lang::w().common.day), } } @@ -96,14 +98,7 @@ impl Yumush { match network.call(SetRole { user_id, role }).await { Ok(user) => { let _ = this.update(cx, |yumush, cx| { - let index = yumush - .chat - .builder_users - .iter() - .position(|existing| existing.user.id == user.id); - if let Some(index) = index { - yumush.chat.builder_users[index].user = user; - } + yumush.replace_builder_user(user); cx.notify(); }); } @@ -113,6 +108,17 @@ impl Yumush { .detach(); } + fn replace_builder_user(&mut self, user: User) { + let index = self + .chat + .builder_users + .iter() + .position(|existing| existing.user.id == user.id); + if let Some(index) = index { + self.chat.builder_users[index].user = user; + } + } + pub(super) fn delete_builder_user( &mut self, user_id: Id, @@ -483,7 +489,7 @@ impl Yumush { ) .child(accent_button( "create_user", - "Create", + w().builder_users.create, palette, entity_action(entity, |yumush, window, cx| { yumush.submit_new_user(window, cx) @@ -497,7 +503,7 @@ impl Yumush { .justify_center() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child("No users".to_string()) + .child(w().builder_users.no_users) } else { div() .flex() @@ -532,7 +538,7 @@ impl Yumush { ) .child(plain_button( format!("confirm_timeout_{user_id}"), - "Confirm", + w().builder_users.confirm, palette, entity_action(entity, |yumush, window, cx| { yumush.confirm_builder_timeout(window, cx) @@ -547,9 +553,9 @@ impl Yumush { palette: Palette, ) -> Div { let ip_label = if self.chat.builder_ban_scope == BanScope::AccountAndIp { - "IP: on" + w().builder_users.ip_on } else { - "IP: off" + w().builder_users.ip_off }; div() @@ -572,7 +578,7 @@ impl Yumush { )) .child(plain_button( format!("confirm_ban_{user_id}"), - "Confirm", + w().builder_users.confirm, palette, entity_action(entity, |yumush, window, cx| { yumush.confirm_builder_ban(window, cx) @@ -612,8 +618,8 @@ impl Yumush { let revoke_button = action_button( format!("revoke_session_{}", session.id), IconName::LogOut, - "Revoke", - "End this session", + w().builder_users.revoke, + w().builder_users.end_session, palette.muted, palette, entity_action(entity, move |yumush, window, cx| { @@ -621,7 +627,7 @@ impl Yumush { }), ); let device = if session.device.is_empty() { - "unknown device" + w().builder_users.unknown_device } else { session.device.as_str() }; @@ -685,7 +691,7 @@ impl Yumush { .when(ready, |row| { row.child(plain_button( format!("confirm_rename_{user_id}"), - "Confirm", + w().builder_users.confirm, palette, entity_action(entity, |yumush, window, cx| { yumush.rename_builder_user(window, cx) @@ -718,7 +724,7 @@ impl Yumush { .when(ready, |row| { row.child(plain_button( format!("confirm_password_{user_id}"), - "Confirm", + w().builder_users.confirm, palette, entity_action(entity, |yumush, window, cx| { yumush.reset_builder_password(window, cx) @@ -766,7 +772,7 @@ impl Yumush { let timeout_id = user.id; let ban_id = user.id; let purge_id = user.id; - let joined = millis_time(user.created_at, DATE); + let joined = millis_time(user.created_at, crate::lang::w().common.date); let seen = seen_text(account.last_seen); let next_role = if builder { Role::User } else { Role::Builder }; @@ -779,14 +785,14 @@ impl Yumush { IconName::Shield }, if builder { - "Remove builder" + w().builder_users.remove_builder } else { - "Make builder" + w().builder_users.make_builder }, if builder { - "Revoke admin tools" + w().builder_users.revoke_admin } else { - "Grant admin tools" + w().builder_users.grant_admin }, tone, palette, @@ -798,11 +804,15 @@ impl Yumush { let suspend_button = action_button( format!("suspend_user_{}_{suspended}", user.id), IconName::CirclePause, - if suspended { "Unsuspend" } else { "Suspend" }, if suspended { - "Allow sign in again" + w().builder_users.unsuspend + } else { + w().builder_users.suspend + }, + if suspended { + w().builder_users.allow_sign_in } else { - "Block sign in until lifted" + w().builder_users.block_until_lifted }, tone, palette, @@ -814,8 +824,8 @@ impl Yumush { let sessions_button = action_button( format!("sessions_user_{}", user.id), IconName::LogOut, - "Sign out", - "End every session", + w().builder_users.sign_out, + w().builder_users.end_all_sessions, tone, palette, entity_action(entity, move |yumush, window, cx| { @@ -833,8 +843,8 @@ impl Yumush { let stats_button = action_button( format!("stats_user_{}", user.id), IconName::Activity, - "Stats", - "Live connection and machine stats", + w().builder_users.stats, + w().builder_users.stats_tip, if stats_open.is_some() { palette.text } else { @@ -849,8 +859,8 @@ impl Yumush { let password_button = action_button( format!("password_user_{}", user.id), IconName::KeyRound, - "Password", - "Set a new password", + w().builder_users.password, + w().builder_users.password_tip, tone, palette, entity_action(entity, move |yumush, _, cx| { @@ -865,7 +875,7 @@ impl Yumush { yumush.toggle_builder_sessions(sessions_list_id, window, cx) }), ) - .tip("Manage") + .tip(w().builder_users.manage) .size(px(size::CONTROL_SM)) .flex_shrink_0() .flex() @@ -879,8 +889,8 @@ impl Yumush { let rename_button = action_button( format!("rename_user_{}", user.id), IconName::Pencil, - "Rename", - "Change username", + w().builder_users.rename, + w().builder_users.rename_tip, tone, palette, entity_action(entity, move |yumush, _, cx| { @@ -891,8 +901,8 @@ impl Yumush { let timeout_button = action_button( format!("timeout_user_{}", user.id), IconName::Timer, - "Timeout", - "Block sign in for a while", + w().builder_users.timeout, + w().builder_users.timeout_tip, tone, palette, entity_action(entity, move |yumush, _, cx| { @@ -903,8 +913,8 @@ impl Yumush { let ban_button = action_button( format!("ban_user_{}", user.id), IconName::Ban, - "Ban", - "Ban username or IP from the server", + w().builder_users.ban, + w().builder_users.ban_tip, tone, palette, entity_action(entity, move |yumush, _, cx| { @@ -915,8 +925,8 @@ impl Yumush { let profile_button = action_button( format!("profile_user_{}", user.id), IconName::Eraser, - "Clear profile", - "Remove avatar and status", + w().builder_users.clear_profile, + w().builder_users.clear_profile_tip, palette.danger, palette, entity_action(entity, move |yumush, window, cx| { @@ -927,8 +937,8 @@ impl Yumush { let purge_button = confirm_button( format!("purge_user_{}", user.id), IconName::MessageSquareX, - "Purge", - "Delete all their messages", + w().builder_users.purge, + w().builder_users.purge_tip, pending_purge, palette, entity_action(entity, move |yumush, window, cx| { @@ -939,8 +949,8 @@ impl Yumush { let delete_button = confirm_button( format!("delete_user_{}", user.id), IconName::UserX, - "Delete", - "Delete the account", + w().builder_users.delete, + w().builder_users.delete_tip, pending_delete, palette, entity_action(entity, move |yumush, window, cx| { @@ -990,17 +1000,33 @@ impl Yumush { .text_color(palette.text) .child(user.username.clone()), )) - .when(builder, |this| { - this.child(status("Builder", palette.accent, palette)) + .when(user.role == Role::Builder, |this| { + this.child(status( + w().builder_users.tag_builder, + palette.accent, + palette, + )) }) .when(suspended, |this| { - this.child(status("Suspended", palette.danger, palette)) + this.child(status( + w().builder_users.tag_suspended, + palette.danger, + palette, + )) }) .when(timed_out, |this| { - this.child(status("Timed out", palette.danger, palette)) + this.child(status( + w().builder_users.tag_timed_out, + palette.danger, + palette, + )) }) .when(account.ghost, |this| { - this.child(status("Ghost", palette.muted, palette)) + this.child(status( + w().builder_users.tag_ghost, + palette.muted, + palette, + )) }), ) .child( @@ -1009,7 +1035,7 @@ impl Yumush { .truncate() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child(format!("joined {joined} · seen {seen}")), + .child(w().builder_users.joined_seen(joined, seen)), ), ) .children(has_actions.then_some(toggle_button)); @@ -1056,7 +1082,7 @@ impl Yumush { .border_t_1() .border_color(palette.border) .children(action_group( - "Account", + w().builder_users.group_account, palette, account_actions.into_iter().flatten().collect(), )) @@ -1067,20 +1093,24 @@ impl Yumush { rename_open.then(|| self.builder_rename_row(user.id, entity, palette, cx)), ) .children(action_group( - "Moderation", + w().builder_users.group_moderation, palette, moderation_actions.into_iter().flatten().collect(), )) .children(timeout_open.then(|| self.builder_timeout_row(user.id, entity, palette))) .children(ban_open.then(|| self.builder_ban_row(user.id, entity, palette))) .children(action_group( - "Danger", + w().builder_users.group_danger, palette, danger_actions.into_iter().flatten().collect(), )) - .children(action_group("Sessions", palette, sessions)) .children(action_group( - "Friends", + w().builder_users.group_sessions, + palette, + sessions, + )) + .children(action_group( + w().builder_users.group_friends, palette, self.chat .builder_friends diff --git a/crates/client/src/gui/builder/voice.rs b/crates/client/src/gui/builder/voice.rs index cb34f8c..9cb7851 100644 --- a/crates/client/src/gui/builder/voice.rs +++ b/crates/client/src/gui/builder/voice.rs @@ -18,6 +18,7 @@ use crate::{ style::{self, size, space}, text, }, + lang::w, net::{Fail, NetworkHandle}, }; @@ -82,7 +83,7 @@ impl Yumush { if self.chat.builder_voice_rooms.is_empty() { body.push( - list_card(None, Vec::new(), "No active voice rooms", palette).into_any_element(), + list_card(None, Vec::new(), w().builder_voice.no_rooms, palette).into_any_element(), ); } body.extend(self.chat.builder_voice_rooms.iter().map(|room| { @@ -116,7 +117,7 @@ impl Yumush { icon_button( format!("room_join_{id}"), IconName::Headphones, - "Join", + w().builder_voice.join, palette.ok, palette, entity_action(entity, move |yumush, window, cx| { @@ -135,7 +136,11 @@ impl Yumush { } else { IconName::PhoneOff }, - if enabled { "Voice on" } else { "Voice off" }, + if enabled { + w().builder_voice.voice_on + } else { + w().builder_voice.voice_off + }, palette.muted, palette, entity_action(entity, move |yumush, window, cx| { @@ -162,7 +167,7 @@ impl Yumush { card(palette) .child(card_header(&room.community, actions, palette)) - .child(rows_body(rows, "No users", palette)) + .child(rows_body(rows, w().builder_voice.no_users, palette)) } pub(super) fn voice_user_row( @@ -210,8 +215,8 @@ impl Yumush { ), )), ) - .children(muted.then(|| pill("Muted", palette.danger, palette))) - .children(ghost.then(|| pill("Ghost", palette.muted, palette))) + .children(muted.then(|| pill(w().builder_voice.muted, palette.danger, palette))) + .children(ghost.then(|| pill(w().builder_voice.ghost, palette.muted, palette))) .child(icon_button( format!("voice_mute_{id}_{muted}"), if muted { @@ -219,7 +224,11 @@ impl Yumush { } else { IconName::MicOff }, - if muted { "Unmute" } else { "Mute" }, + if muted { + w().builder_voice.unmute + } else { + w().builder_voice.mute + }, palette.muted, palette, entity_action(entity, move |yumush, window, cx| { @@ -229,7 +238,7 @@ impl Yumush { .child(icon_button( format!("voice_kick_{id}"), IconName::UserX, - "Kick", + w().builder_voice.kick, palette.danger, palette, entity_action(entity, move |yumush, window, cx| { diff --git a/crates/client/src/gui/call_bar.rs b/crates/client/src/gui/call_bar.rs index cc668d8..a8b63a4 100644 --- a/crates/client/src/gui/call_bar.rs +++ b/crates/client/src/gui/call_bar.rs @@ -11,6 +11,7 @@ use super::{ parts::{Ink, Text, Tone, Voice, band, icon_button, thread, voice_line, words}, style::{Tokens, size, space}, }; +use crate::lang::w; pub type Action = Rc; @@ -77,7 +78,11 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { } else { IconName::Mic }, - if bar.muted { "Unmute" } else { "Mute" }, + if bar.muted { + w().call_bar.unmute + } else { + w().call_bar.mute + }, alarm(bar.muted), t, run(&actions.mute), @@ -90,7 +95,11 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { } else { IconName::Headphones }, - if bar.deafened { "Undeafen" } else { "Deafen" }, + if bar.deafened { + w().call_bar.undeafen + } else { + w().call_bar.deafen + }, alarm(bar.deafened), t, run(&actions.deafen), @@ -101,9 +110,9 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { format!("bar_camera_{}", bar.camera), IconName::Video, if bar.camera { - "Turn off camera" + w().call_bar.turn_off_camera } else { - "Turn on camera" + w().call_bar.turn_on_camera }, tone(bar.camera), t, @@ -114,9 +123,9 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { format!("bar_screen_{}", bar.screen), IconName::ScreenShare, if bar.screen { - "Stop sharing" + w().call_bar.stop_sharing } else { - "Share screen" + w().call_bar.share_screen }, tone(bar.screen), t, @@ -127,7 +136,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { .child(icon_button( "bar_leave", IconName::PhoneOff, - "Leave call", + w().call_bar.leave_call, Tone::Danger, t, run(&actions.leave), @@ -150,7 +159,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { move |style| style.bg(hov) }) .cursor_pointer() - .tip("Go to call") + .tip(w().call_bar.go_to_call) .on_click({ let go = run(&actions.go); move |_, window, cx| go(window, cx) @@ -191,7 +200,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { move |style| style.bg(hov) }) .cursor_pointer() - .tip("Connection stats") + .tip(w().call_bar.connection_stats) .on_click(move |_, window, cx| stats(window, cx)) .child( div() diff --git a/crates/client/src/gui/camera_view.rs b/crates/client/src/gui/camera_view.rs index 01ef619..c6fa093 100644 --- a/crates/client/src/gui/camera_view.rs +++ b/crates/client/src/gui/camera_view.rs @@ -18,6 +18,7 @@ use super::{ surface::Surface, widget::spawn_warn, }; +use crate::lang::w; use crate::share::session::WatchQuality; const SLOTS: usize = 6; @@ -310,10 +311,13 @@ impl Yumush { ) })) }) - .chain( - (more > 0) - .then(|| caption(format!("{more} more"), voice_line(None, Voice::Quiet, t), t)), - ) + .chain((more > 0).then(|| { + caption( + w().camera_view.more(more), + voice_line(None, Voice::Quiet, t), + t, + ) + })) .collect() } @@ -485,7 +489,7 @@ fn stage_tile( div() .id(format!("stage_{user_id}_{kind:?}")) - .tip("Watch") + .tip(w().camera_view.watch) .cursor_pointer() .flex() .flex_col() @@ -543,7 +547,11 @@ fn more_tile(entity: &Entity, more: usize, palette: Palette) -> impl Int .bg(t.raise()) .child(words(format!("+{more}"), Text::Title, Ink::Paper, t)), ) - .child(caption("screens", voice_line(None, Voice::Quiet, t), t)) + .child(caption( + w().camera_view.screens, + voice_line(None, Voice::Quiet, t), + t, + )) } fn grid_cell( @@ -575,7 +583,7 @@ fn grid_cell( .flex_col() .gap(px(space::SM)) .cursor_pointer() - .tip("Watch") + .tip(w().camera_view.watch) .on_click(move |_, window, cx| { entity.update(cx, |yumush, cx| { yumush.toggle_viewer(user_id, kind, window, cx) diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index 71c67ca..e1450fb 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -2,6 +2,7 @@ use super::style::{self, radius, size, space, stroke, text}; use super::text; use crate::gui::CLOCK; use crate::gui::glyph::Fill as _; +use crate::lang::w; use std::{ collections::{BTreeMap, HashMap, HashSet, VecDeque}, sync::Arc, @@ -126,7 +127,6 @@ pub enum CardMenu { Main, More, Accounts, - Presence, Status, } @@ -310,7 +310,7 @@ impl Chat { let mut state = TextareaState::new(window, cx) .auto_grow(1, 10) .submit_on_enter(true); - state.set_placeholder("Message", window, cx); + state.set_placeholder(w().chat.message, window, cx); state }); cx.subscribe_in( @@ -329,13 +329,14 @@ impl Chat { ) .detach(); - let jump_input = new_input("Jump to…", window, cx); + let jump_input = new_input(w().jump.placeholder, window, cx); cx.subscribe_in( &jump_input, window, |this, _, event, window, cx| match event { InputEvent::Change => { this.chat.goto.cursor = 0; + this.chat.goto.scroll.scroll_to_item(0); cx.notify(); } InputEvent::PressEnter { .. } => this.jump_enter(window, cx), @@ -344,7 +345,7 @@ impl Chat { ) .detach(); - let member_input = new_input("Find", window, cx); + let member_input = new_input(w().chat.find, window, cx); cx.subscribe_in(&member_input, window, |_, _, event, _, cx| { if matches!(event, InputEvent::Change) { cx.notify(); @@ -352,7 +353,7 @@ impl Chat { }) .detach(); - let search_input = new_input("Find user", window, cx); + let search_input = new_input(w().chat.find_user, window, cx); cx.subscribe_in( &search_input, window, @@ -364,7 +365,7 @@ impl Chat { ) .detach(); - let community_search = new_input("Search messages", window, cx); + let community_search = new_input(w().chat.search_messages, window, cx); cx.subscribe_in(&community_search, window, |this, _, event, window, cx| { if matches!(event, InputEvent::PressEnter { .. }) { this.search_community(window, cx); @@ -372,12 +373,12 @@ impl Chat { }) .detach(); - let ban_search = new_input("Search...", window, cx); - let log_search = new_input("Search...", window, cx); - let builder_search = new_input("Search...", window, cx); - let builder_password = new_input("New password...", window, cx); + let ban_search = new_input(w().chat.search, window, cx); + let log_search = new_input(w().chat.search, window, cx); + let builder_search = new_input(w().chat.search, window, cx); + let builder_password = new_input(w().chat.new_password, window, cx); builder_password.update(cx, |input, cx| input.set_masked(true, window, cx)); - let new_password = new_input("Password...", window, cx); + let new_password = new_input(w().chat.password, window, cx); new_password.update(cx, |input, cx| input.set_masked(true, window, cx)); for search in [&ban_search, &log_search, &builder_search] { cx.subscribe_in(search, window, |_, _, event, window, cx| { @@ -406,7 +407,7 @@ impl Chat { invitations: vec![], messages: vec![], pins: vec![], - poll_question: new_input("Question", window, cx), + poll_question: new_input(w().chat.question, window, cx), poll_options: vec![ composer::new_poll_option(window, cx), composer::new_poll_option(window, cx), @@ -440,14 +441,14 @@ impl Chat { sidebar_toggled: None, view: View::Chat, section: 0, - username_input: editable_input("Username...", Yumush::save_username, window, cx), + username_input: editable_input(w().chat.username, Yumush::save_username, window, cx), community_name_input: editable_input( - "Community name...", + w().chat.community_name, Yumush::save_community_name, window, cx, ), - status_input: editable_input("Status...", Yumush::save_status, window, cx), + status_input: editable_input(w().chat.status, Yumush::save_status, window, cx), avatars: HashMap::new(), avatar_requests: HashSet::new(), users: HashMap::new(), @@ -463,12 +464,12 @@ impl Chat { builder_overview: None, builder_logs: vec![], builder_stats: vec![], - builder_log_actor: new_input("Actor...", window, cx), - builder_log_target: new_input("Target...", window, cx), + builder_log_actor: new_input(w().chat.actor, window, cx), + builder_log_target: new_input(w().chat.target, window, cx), builder_log_action: cx.new(|cx| { SelectState::new( SearchableVec::new( - std::iter::once("All") + std::iter::once(w().chat.all) .chain( AdminActionKind::ALL .into_iter() @@ -481,19 +482,19 @@ impl Chat { cx, ) }), - builder_log_from: new_input("From YYYY-MM-DD", window, cx), - builder_log_to: new_input("To YYYY-MM-DD", window, cx), + builder_log_from: new_input(w().chat.date_from, window, cx), + builder_log_to: new_input(w().chat.date_to, window, cx), builder_search, builder_communities: vec![], pending_community_delete: None, - builder_message_text: new_input("Text...", window, cx), - builder_message_user: new_input("User...", window, cx), - builder_message_community: new_input("Community...", window, cx), - builder_message_from: new_input("From YYYY-MM-DD", window, cx), - builder_message_to: new_input("To YYYY-MM-DD", window, cx), + builder_message_text: new_input(w().chat.text, window, cx), + builder_message_user: new_input(w().chat.user, window, cx), + builder_message_community: new_input(w().chat.community, window, cx), + builder_message_from: new_input(w().chat.date_from, window, cx), + builder_message_to: new_input(w().chat.date_to, window, cx), builder_messages: vec![], - builder_attachment_user: new_input("User...", window, cx), - builder_attachment_community: new_input("Community...", window, cx), + builder_attachment_user: new_input(w().chat.user, window, cx), + builder_attachment_community: new_input(w().chat.community, window, cx), builder_usage_users: vec![], builder_usage_communities: vec![], builder_attachments: vec![], @@ -502,42 +503,42 @@ impl Chat { pending_builder_purge: None, transfer: None, builder_password, - server_name: new_input("Server name...", window, cx), + server_name: new_input(w().chat.server_name, window, cx), server_limit: new_input("", window, cx), server_user_quota: new_input("", window, cx), server_community_quota: new_input("", window, cx), server_message_retention: new_input("", window, cx), server_attachment_retention: new_input("", window, cx), - server_announcement: new_input("Announcement...", window, cx), + server_announcement: new_input(w().chat.announcement, window, cx), server_max_communities: new_input("", window, cx), - server_max_message_length: new_input("Max message length...", window, cx), + server_max_message_length: new_input(w().chat.max_message_length, window, cx), server_max_avatar: new_input("", window, cx), server_messages_per_minute: new_input("", window, cx), server_logins_per_minute: new_input("", window, cx), server_registration_open: true, server_maintenance: false, pending_builder_timeout: None, - builder_timeout: new_input("Minutes...", window, cx), + builder_timeout: new_input(w().chat.minutes, window, cx), pending_builder_ban: None, - builder_ban_reason: new_input("Reason...", window, cx), + builder_ban_reason: new_input(w().chat.reason, window, cx), builder_ban_scope: BanScope::Account, builder_bans: vec![], builder_invites: vec![], - invite_uses: new_input("Uses...", window, cx), - invite_hours: new_input("Hours", window, cx), + invite_uses: new_input(w().chat.uses, window, cx), + invite_hours: new_input(w().chat.hours, window, cx), pending_invite_delete: None, - new_username: new_input("Username...", window, cx), + new_username: new_input(w().chat.username, window, cx), new_password, pending_builder_password: None, builder_sessions: None, builder_friends: Vec::new(), pending_builder_rename: None, - builder_rename: new_input("New username...", window, cx), + builder_rename: new_input(w().chat.new_username, window, cx), builder_reports: vec![], report_filter: Some(ReportStatus::Open), open_reports: 0, report: None, - report_reason: new_input("Reason...", window, cx), + report_reason: new_input(w().chat.reason, window, cx), voice: HashMap::new(), drafts: HashMap::new(), voice_state: VoiceState::Off, @@ -551,6 +552,7 @@ impl Chat { open: false, cursor: 0, input: jump_input, + scroll: ScrollHandle::new(), }, server_stats: None, server_stats_task: None, @@ -794,13 +796,13 @@ impl Chat { .filter(|(_, at)| at.elapsed() < TYPING_TTL) .map(|(user_id, _)| { self.author(*user_id) - .map_or("Someone", |user| user.username.as_str()) + .map_or(w().chat.someone, |user| user.username.as_str()) }) .collect(); match names.as_slice() { [] => None, - [name] => Some(format!("{name} is typing…")), - names => Some(format!("{} people are typing…", names.len())), + [name] => Some(w().chat.typing_one(name)), + names => Some(w().chat.typing_many(names.len())), } } @@ -1333,7 +1335,7 @@ fn empty_state(palette: Palette) -> impl IntoElement { .text_size(text(text::CAPTION)) .child(FIND_HINT), ) - .child("Find a user") + .child(w().chat.find_user) } pub(super) fn create_community( @@ -1506,6 +1508,7 @@ impl Yumush { let name = community.map(community_name).unwrap_or_default(); let group = community.is_some_and(|community| matches!(community.kind, CommunityKind::Group)); + let voice = self.voice_toggle(entity, palette); div() .h(px(size::ROW + space::MD)) @@ -1541,11 +1544,9 @@ impl Yumush { .children( community .is_some() - .then(|| self.voice_stack(entity, palette)) + .then(|| self.stage_controls(entity, palette)) .flatten(), ) - .children(self.calling_hint(palette)) - .children(self.voice_button(entity, palette)) .children( community .is_some_and(|community| self.chat.joined(community.id)) @@ -1560,7 +1561,7 @@ impl Yumush { "members_button", palette, IconName::Users, - "People", + w().chat.people, entity_action(entity, |yumush, _, cx| { yumush.chat.members_open = !yumush.chat.members_open; cx.notify(); @@ -1570,6 +1571,15 @@ impl Yumush { button.text_color(palette.text) }) })) + .children(self.calling_hint(palette)) + .children(voice.is_some().then(|| { + div() + .w(px(stroke::LINE)) + .h(px(size::CHIP)) + .flex_none() + .bg(palette.tokens.thread()) + })) + .children(voice) } fn message_area(&self, entity: &Entity, palette: Palette) -> impl IntoElement { @@ -1599,7 +1609,7 @@ impl Yumush { } Some( accent_bar(palette) - .child(format!("{count} new messages")) + .child(w().chat.new_messages(count)) .child( div() .flex() @@ -1873,7 +1883,7 @@ impl Yumush { clickable("send_button", palette, move |window, cx| { entity.update(cx, |yumush, cx| yumush.submit_composer(&input, window, cx)) }) - .tip("Send") + .tip(w().chat.send) .size(px(size::CONTROL_SM)) .flex() .items_center() @@ -1898,6 +1908,12 @@ impl Yumush { self.stop_playing(cx); self.save_draft(cx); self.chat.select(Some(community_id)); + if let Some(me) = &self.user + && self.settings.last_chats.get(&me.id) != Some(&community_id) + { + self.settings.last_chats.insert(me.id, community_id); + crate::settings::save(&self.settings); + } self.restore_draft(community_id, window, cx); self.chat.focus(window, cx); self.load_members(window, cx); @@ -1978,12 +1994,16 @@ impl Yumush { yumush.request_social_avatars(cx); if yumush.chat.selected_community_id.is_none() { - let first = yumush - .chat - .communities - .first() - .map(|community| community.id); - if let Some(community_id) = first { + let last = yumush + .user + .as_ref() + .and_then(|me| yumush.settings.last_chats.get(&me.id)) + .copied(); + let communities = &yumush.chat.communities; + let start = last + .filter(|last| communities.iter().any(|community| community.id == *last)) + .or_else(|| communities.first().map(|community| community.id)); + if let Some(community_id) = start { yumush.select_community(community_id, window, cx); } } @@ -2451,7 +2471,7 @@ impl Yumush { let palette = super::palette(cx); let speak = entity.clone(); - dialog.title("Speak as ghost?").child( + dialog.title(w().chat.ghost_title).child( div() .flex() .flex_col() @@ -2460,7 +2480,7 @@ impl Yumush { div() .text_size(text(text::LABEL)) .text_color(palette.muted) - .child("Everyone in the call will hear you."), + .child(w().chat.ghost_hint), ) .child( div() @@ -2477,7 +2497,7 @@ impl Yumush { .items_center() .rounded(px(radius::MD)) .text_color(palette.muted) - .child("Cancel"), + .child(w().chat.cancel), ) .child( primary_button( @@ -2493,7 +2513,7 @@ impl Yumush { .flex() .items_center() .rounded(px(radius::MD)) - .child("Speak"), + .child(w().chat.speak), ), ), ) @@ -2675,7 +2695,7 @@ impl Yumush { } } - fn voice_button(&self, entity: &Entity, palette: Palette) -> Option { + fn voice_toggle(&self, entity: &Entity, palette: Palette) -> Option { let community_id = self.chat.selected_community_id?; let direct = self.is_direct(community_id); let in_voice = self.chat.in_voice(community_id); @@ -2690,38 +2710,83 @@ impl Yumush { return None; } + let t = palette.tokens; + let users = self.voice_users(community_id); + let speaker = users + .iter() + .map(|user| user.id) + .find(|id| self.chat.waves.speaking.contains(id)); + let (icon, label) = match (direct, in_voice) { + (true, false) => (IconName::Phone, w().chat.call), + (true, true) => (IconName::PhoneOff, w().chat.hang_up), + (false, false) => (IconName::Headphones, w().chat.join), + (false, true) => (IconName::Headphones, w().chat.leave), + }; + let ink = if in_voice { + super::parts::Ink::Bad + } else if users.is_empty() { + super::parts::Ink::Dim + } else { + super::parts::Ink::Paper + }; + let voice = match speaker { + Some(id) => super::parts::Voice::Live(t.person(id)), + None => super::parts::Voice::Quiet, + }; + let bands = speaker.and_then(|id| self.chat.waves.voice(id)); let entity = entity.clone(); let on_click = move |window: &mut Window, cx: &mut App| { entity.update(cx, |yumush, cx| { yumush.toggle_voice(community_id, window, cx) }) }; - let (icon, tip) = match (direct, in_voice) { - (true, false) => (IconName::Phone, "Call"), - (true, true) => (IconName::PhoneOff, "Hang up"), - (false, false) => (IconName::Headphones, "Join voice"), - (false, true) => (IconName::Headphones, "Leave voice"), - }; - let id = format!("voice_button_{direct}_{in_voice}"); - let color = if in_voice { - palette.danger - } else { - palette.muted - }; + let hov = t.hov(); Some( - clickable(id, palette, on_click) - .text_color(color) - .tip(tip) - .size(px(size::CONTROL_SM)) + div() + .id(format!("voice_toggle_{direct}_{in_voice}")) + .h(px(size::CONTROL_SM)) + .px(px(space::MD)) .flex() .items_center() - .justify_center() - .rounded_full() - .child(Icon::new(icon).size(px(size::ICON_SM))), + .gap(px(space::SM)) + .rounded(px(radius::MD)) + .cursor_pointer() + .hover(move |style| style.bg(hov)) + .text_color(ink.color(t)) + .on_click(move |_, window, cx| on_click(window, cx)) + .child(Icon::new(icon).size(px(size::ICON_SM))) + .when(!users.is_empty(), |this| { + this.child( + div() + .w(px(size::CONTROL * 1.5)) + .h(px(space::LG)) + .child(super::parts::voice_line(bands, voice, t)), + ) + .children(users.iter().take(3).enumerate().map(|(index, user)| { + avatar( + palette, + user, + px(size::AVATAR), + super::text(super::style::text::CAPTION), + &self.chat.avatars, + ) + .when(index > 0, |avatar| avatar.ml(px(-space::XS))) + })) + }) + .child(super::parts::words(label, super::parts::Text::Ui, ink, t)), ) } + fn voice_users(&self, community_id: Id) -> Vec<&User> { + self.chat + .voice_ids(community_id) + .iter() + .filter(|id| !(self.chat.ghost && self.is_me(**id))) + .filter_map(|id| self.chat.member(*id)) + .collect() + } + fn calling_hint(&self, palette: Palette) -> Option
{ let community = self.chat.selected_community()?; let direct = self.is_direct(community.id); @@ -2736,7 +2801,7 @@ impl Yumush { div() .text_color(palette.muted) .text_size(text(text::CAPTION)) - .child("Calling…") + .child(w().chat.calling) }) } @@ -2752,7 +2817,7 @@ impl Yumush { .items_center() .gap(px(space::SM)) .child(Icon::new(IconName::PhoneIncoming).size(px(size::ICON_SM))) - .child(format!("{} is calling", caller.username)), + .child(w().chat.is_calling(&caller.username)), ) .child( div() @@ -2770,7 +2835,7 @@ impl Yumush { .font_weight(FontWeight::MEDIUM) .px(px(space::SM)) .rounded(px(radius::SM)) - .child("Accept"), + .child(w().chat.accept), ) .child( clickable( @@ -2784,7 +2849,7 @@ impl Yumush { .font_weight(FontWeight::MEDIUM) .px(px(space::SM)) .rounded(px(radius::SM)) - .child("Decline"), + .child(w().chat.decline), ), ), ) @@ -2861,61 +2926,42 @@ impl Yumush { }); } - fn voice_stack(&self, entity: &Entity, palette: Palette) -> Option { + fn stage_controls(&self, entity: &Entity, palette: Palette) -> Option { let community_id = self.chat.selected_community_id?; - let users: Vec<&User> = self - .chat - .voice_ids(community_id) - .iter() - .filter(|id| !(self.chat.ghost && self.is_me(**id))) - .filter_map(|id| self.chat.member(*id)) - .collect(); - if users.is_empty() { + if self.voice_users(community_id).is_empty() || !self.in_stage_chat() { return None; } let current = self.chat.stage; Some( div() + .ml(px(space::SM)) .flex() .items_center() - .gap(px(space::SM)) - .when(!self.is_direct(community_id), |stack| { - stack.child( - div() - .text_size(text(text::LABEL)) - .text_color(palette.muted) - .child(format!("{} in call", users.len())), - ) - }) - .children(self.in_stage_chat().then(|| { - div() - .ml(px(space::SM)) - .flex() - .items_center() - .gap(px(space::XXS)) - .child(stage_button( - entity, - palette, - Stage::Strip, - current == Stage::Strip, - IconName::GalleryHorizontal, - "Strip", - )) - .child(stage_button( - entity, - palette, - Stage::Grid, - current == Stage::Grid, - IconName::LayoutGrid, - "Grid", - )) - .child(stats_button( - entity, - palette, - self.chat.stats_at == Some(StatsAt::Header), - )) - })), + .gap(px(space::XXS)) + .child(stage_button( + entity, + palette, + Stage::Strip, + current == Stage::Strip, + IconName::GalleryHorizontal, + "Strip", + w().chat.strip, + )) + .child(stage_button( + entity, + palette, + Stage::Grid, + current == Stage::Grid, + IconName::LayoutGrid, + "Grid", + w().chat.grid, + )) + .child(stats_button( + entity, + palette, + self.chat.stats_at == Some(StatsAt::Header), + )), ) } } @@ -3065,9 +3111,9 @@ fn members_column( .border_l_1() .border_color(palette.border) .child(super::sidebar::input_box(&chat.member_input, palette)) - .children(section("In call", in_call)) - .children(section("Online", online)) - .children(section("Offline", offline)), + .children(section(w().chat.in_call, in_call)) + .children(section(w().chat.online, online)) + .children(section(w().chat.offline, offline)), ) } @@ -3112,7 +3158,7 @@ fn new_divider(palette: Palette) -> impl IntoElement { div() .text_size(text(text::CAPTION)) .text_color(palette.accent) - .child("New"), + .child(w().chat.new), ) } @@ -3163,7 +3209,7 @@ fn render_call( let mine = me.is_some_and(|me| me.id == message.user_id); let author = chat .author(message.user_id) - .map_or("unknown", |user| user.username.as_str()); + .map_or(w().chat.unknown, |user| user.username.as_str()); let message_id = message.id; let entity = entity.clone(); let toggle = match run { @@ -3171,7 +3217,7 @@ fn render_call( CallRun::Folded(calls) => Some( div() .hover(|style| style.underline()) - .child(format!("\u{a0}· {calls} calls")), + .child(format!("\u{a0}· {}", w().chat.calls(calls))), ), CallRun::Open => Some( div() @@ -3204,18 +3250,20 @@ fn render_call( } pub(super) fn call_line(call: CallLog, author: &str, mine: bool, palette: Palette) -> Div { - let who = if mine { "You" } else { author }; + let w = &w().chat; let (icon, color) = match call { CallLog::Started | CallLog::Ended { .. } => (IconName::Phone, palette.muted), CallLog::Declined => (IconName::PhoneOff, palette.danger), CallLog::Missed => (IconName::PhoneMissed, palette.danger), }; let label = match call { - CallLog::Started => format!("{who} started a call"), - CallLog::Declined => format!("{who} declined the call"), - CallLog::Missed if mine => "You called, no answer".to_string(), - CallLog::Missed => format!("Missed call from {author}"), - CallLog::Ended { seconds } => format!("Call ended · {}", call_duration(seconds)), + CallLog::Started if mine => w.call_started_mine.to_string(), + CallLog::Started => w.call_started(author), + CallLog::Declined if mine => w.call_declined_mine.to_string(), + CallLog::Declined => w.call_declined(author), + CallLog::Missed if mine => w.call_missed_mine.to_string(), + CallLog::Missed => w.call_missed(author), + CallLog::Ended { seconds } => w.call_ended(call_duration(seconds)), }; div() .relative() @@ -3258,7 +3306,7 @@ fn render_message( ); } let author = chat.author(message.user_id); - let username = author.map_or("unknown", |user| user.username.as_str()); + let username = author.map_or(w().chat.unknown, |user| user.username.as_str()); let name = div().flex().items_center().gap(px(space::SM)).child( div() .id(format!("author_name_{}", message.id)) @@ -3376,7 +3424,7 @@ fn render_message( div() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child("(edited)"), + .child(w().chat.edited), ) }), ) @@ -3484,9 +3532,9 @@ fn stats_button(entity: &Entity, palette: Palette, open: bool) -> impl I }), ) .tip(if open { - "Hide connection stats" + w().chat.stats_hide } else { - "Connection stats" + w().chat.stats }) .size(px(size::CONTROL_SM)) .flex() @@ -3505,6 +3553,7 @@ fn stage_button( active: bool, icon: IconName, name: &'static str, + label: &'static str, ) -> impl IntoElement { clickable( format!("stage_{name}_{active}"), @@ -3514,7 +3563,7 @@ fn stage_button( yumush.set_stage(next, cx) }), ) - .tip(if active { "Hide" } else { name }) + .tip(if active { w().chat.hide } else { label }) .size(px(size::CONTROL_SM)) .flex() .items_center() diff --git a/crates/client/src/gui/community_settings.rs b/crates/client/src/gui/community_settings.rs index 540bb72..e13db3d 100644 --- a/crates/client/src/gui/community_settings.rs +++ b/crates/client/src/gui/community_settings.rs @@ -1,3 +1,4 @@ +use crate::lang::{Label as _, w}; use common::model::Id; use std::{collections::HashMap, sync::Arc}; @@ -24,7 +25,7 @@ use gpui_kit::{ }; use super::{ - Palette, STAMP, Yumush, avatar, + Palette, Yumush, avatar, chat::View, clickable, community_icon, entity_action, millis_time, notify_error, profile::user_link, @@ -50,13 +51,22 @@ pub(super) enum LogSort { Oldest, } -const BAN_SORTS: [(BanSort, &str); 3] = [ - (BanSort::Newest, "Newest"), - (BanSort::Oldest, "Oldest"), - (BanSort::Name, "Name"), -]; +fn ban_sorts() -> [(BanSort, &'static str, &'static str); 3] { + let w = &w().community_settings; + [ + (BanSort::Newest, "newest", w.newest), + (BanSort::Oldest, "oldest", w.oldest), + (BanSort::Name, "name", w.name), + ] +} -const LOG_SORTS: [(LogSort, &str); 2] = [(LogSort::Newest, "Newest"), (LogSort::Oldest, "Oldest")]; +fn log_sorts() -> [(LogSort, &'static str, &'static str); 2] { + let w = &w().community_settings; + [ + (LogSort::Newest, "newest", w.newest), + (LogSort::Oldest, "oldest", w.oldest), + ] +} fn apply_community( this: &WeakEntity, @@ -92,7 +102,7 @@ impl Yumush { if let Some(community) = community.filter(|_| permission::can_rename_community(actor)) { sections.push(Section( - "Profile", + w().community_settings.profile, picture_card( Picture { id: "community_picture_picker", @@ -117,12 +127,12 @@ impl Yumush { } if permission::can_rename_community(actor) { sections.push(section( - "General", + w().community_settings.general, palette, vec![text_row( Editable { id: "save_community_name_button", - label: "Name", + label: w().community_settings.name, input: &self.chat.community_name_input, current: &name, save: Yumush::save_community_name, @@ -135,10 +145,10 @@ impl Yumush { } if let Some(community) = community.filter(|_| permission::can_manage_voice(actor)) { sections.push(section( - "Voice", + w().community_settings.voice, palette, vec![row( - "Voice", + w().community_settings.voice, voice_control(entity, community.id, community.voice_enabled, palette), )], )); @@ -146,7 +156,7 @@ impl Yumush { let mut moderation = Vec::new(); if permission::can_unban(actor) { moderation.push(row( - "Bans", + w().community_settings.bans, div() .flex() .items_center() @@ -167,23 +177,27 @@ impl Yumush { } if permission::can_read_logs(actor) { moderation.push(row( - "Logs", + w().community_settings.logs, view_control("view_logs_button", entity, palette, Yumush::open_logs), )); } if !moderation.is_empty() { - sections.push(section("Moderation", palette, moderation)); + sections.push(section( + w().community_settings.moderation, + palette, + moderation, + )); } let mut danger = Vec::new(); if let Some(community) = community.filter(|_| permission::can_leave(actor)) { danger.push(row( - "Leave community", + w().community_settings.leave_community, leave_control(entity, community.id, palette), )); } if permission::can_delete_community(actor) { danger.push(row( - "Delete community", + w().community_settings.delete_community, delete_control( "delete_community_button", self.chat.delete_step, @@ -360,20 +374,22 @@ impl Yumush { .map(|ban| ban_row(ban, &entity, palette, &yumush.chat.avatars).into_any_element()) .collect(); - dialog.title("Bans").child(moderation_body( - "bans_scroll", - &yumush.chat.ban_search, - sort_control( - BAN_SORTS, - yumush.chat.ban_sort, - &entity, + dialog + .title(w().community_settings.bans) + .child(moderation_body( + "bans_scroll", + &yumush.chat.ban_search, + sort_control( + ban_sorts(), + yumush.chat.ban_sort, + &entity, + palette, + Yumush::set_ban_sort, + ), + rows, + w().community_settings.no_bans, palette, - Yumush::set_ban_sort, - ), - rows, - "No bans", - palette, - )) + )) }); } @@ -401,20 +417,22 @@ impl Yumush { .map(|entry| log_row(entry, palette, &yumush.chat.avatars).into_any_element()) .collect(); - dialog.title("Logs").child(moderation_body( - "logs_scroll", - &yumush.chat.log_search, - sort_control( - LOG_SORTS, - yumush.chat.log_sort, - &entity, + dialog + .title(w().community_settings.logs) + .child(moderation_body( + "logs_scroll", + &yumush.chat.log_search, + sort_control( + log_sorts(), + yumush.chat.log_sort, + &entity, + palette, + Yumush::set_log_sort, + ), + rows, + w().community_settings.no_logs, palette, - Yumush::set_log_sort, - ), - rows, - "No logs", - palette, - )) + )) }); } @@ -480,7 +498,11 @@ fn voice_control( ) .border_1() .border_color(palette.border) - .child(if enabled { "On" } else { "Off" }) + .child(if enabled { + w().community_settings.on + } else { + w().community_settings.off + }) } fn view_control( @@ -492,11 +514,11 @@ fn view_control( small_button(id, palette, palette.text, entity_action(entity, open)) .border_1() .border_color(palette.border) - .child("View") + .child(w().community_settings.view) } fn sort_control( - options: [(T, &'static str); N], + options: [(T, &'static str, &'static str); N], selected: T, entity: &Entity, palette: Palette, @@ -511,11 +533,11 @@ fn sort_control( .border_1() .border_color(palette.border) .bg(palette.field) - .children(options.map(|(choice, label)| { + .children(options.map(|(choice, id, label)| { let active = choice == selected; clickable( - label, + id, palette, entity_action(entity, move |yumush, window, cx| { select(yumush, choice, window, cx) @@ -592,7 +614,9 @@ fn log_list<'a>(logs: &'a [LogEntry], query: &str, sort: LogSort) -> Vec<&'a Log pub(super) fn user_name(user: &Option) -> &str { user.as_ref() - .map_or("someone", |user| user.username.as_str()) + .map_or(w().community_settings.someone, |user| { + user.username.as_str() + }) } fn with_reason(text: String, reason: &Option) -> String { @@ -604,28 +628,29 @@ fn with_reason(text: String, reason: &Option) -> String { fn log_text(entry: &LogEntry) -> String { community_log_text( - &user_name(&entry.actor), - &user_name(&entry.target), + user_name(&entry.actor), + user_name(&entry.target), &entry.action, ) } pub(super) fn community_log_text(actor: &str, target: &str, action: &LogAction) -> String { + let w = &w().community_settings; match action { - LogAction::Created => format!("{actor} created the community"), - LogAction::Renamed { name } => format!("{actor} renamed to {name}"), - LogAction::AvatarChanged => format!("{actor} changed the avatar"), - LogAction::AvatarRemoved => format!("{actor} removed the avatar"), - LogAction::Invited => format!("{actor} invited {target}"), - LogAction::Joined => format!("{actor} joined"), - LogAction::Left => format!("{actor} left"), - LogAction::Kicked { reason } => with_reason(format!("{actor} kicked {target}"), reason), - LogAction::Banned { reason } => with_reason(format!("{actor} banned {target}"), reason), - LogAction::Unbanned => format!("{actor} unbanned {target}"), + LogAction::Created => w.created(actor), + LogAction::Renamed { name } => w.renamed(actor, name), + LogAction::AvatarChanged => w.avatar_changed(actor), + LogAction::AvatarRemoved => w.avatar_removed(actor), + LogAction::Invited => w.invited(actor, target), + LogAction::Joined => w.joined_log(actor), + LogAction::Left => w.left_log(actor), + LogAction::Kicked { reason } => with_reason(w.kicked(actor, target), reason), + LogAction::Banned { reason } => with_reason(w.banned(actor, target), reason), + LogAction::Unbanned => w.unbanned(actor, target), LogAction::RankChanged { rank } => { - format!("{actor} changed rank of {target} to {}", rank.as_str()) + w.rank_changed(actor, rank.label().to_lowercase(), target) } - LogAction::MessageDeleted => format!("{actor} deleted a message by {target}"), + LogAction::MessageDeleted => w.message_deleted(actor, target), } } @@ -651,7 +676,7 @@ fn log_row(entry: &LogEntry, palette: Palette, avatars: &HashMap> .flex_shrink_0() .text_size(text(text_token::CAPTION)) .text_color(palette.muted) - .child(millis_time(entry.created_at, STAMP)), + .child(millis_time(entry.created_at, crate::lang::w().common.stamp)), ) } @@ -670,7 +695,7 @@ fn leave_control(entity: &Entity, community_id: Id, palette: Palette) -> ) .border_1() .border_color(palette.border) - .child("Leave") + .child(w().community_settings.leave) } fn ban_row( @@ -734,6 +759,6 @@ fn ban_row( .items_center() .rounded(px(radius::MD)) .text_color(palette.danger) - .child("Unban"), + .child(w().community_settings.unban), ) } diff --git a/crates/client/src/gui/composer.rs b/crates/client/src/gui/composer.rs index c479ad6..88218a1 100644 --- a/crates/client/src/gui/composer.rs +++ b/crates/client/src/gui/composer.rs @@ -5,6 +5,7 @@ use crate::gui::glyph::Fill as _; use common::model::Id; use std::time::{Duration, Instant}; +use crate::lang::w; use crate::net::Fail; use common::{ call::{CreateMessage, CreatePoll, Typing, UpdateMessage}, @@ -103,7 +104,7 @@ pub fn selection_bar(ids: &[Id], entity: &Entity, palette: Palette) -> i .border_1() .border_color(palette.border) .bg(palette.field) - .child(div().flex_1().child(format!("{count} selected"))) + .child(div().flex_1().child(w().composer.selected(count))) .child( primary_button("forward_selected", palette, move |window, cx| { let selected = selected.clone(); @@ -115,7 +116,7 @@ pub fn selection_bar(ids: &[Id], entity: &Entity, palette: Palette) -> i .items_center() .rounded(px(radius::MD)) .text_size(text(text::CAPTION)) - .child("Forward"), + .child(w().composer.forward), ) .child(cancel_button(entity, palette)) } @@ -146,14 +147,14 @@ fn reply_bar( .find(|message| message.id == message_id); let author = message .and_then(|message| chat.author(message.user_id)) - .map_or("unknown", |user| user.username.as_str()) + .map_or(w().composer.unknown_author, |user| user.username.as_str()) .to_string(); let quote = message .map(super::message_actions::message_text) .unwrap_or_default(); bar(palette) - .child("Replying to") + .child(w().composer.replying_to) .child( div() .font_weight(FontWeight::SEMIBOLD) @@ -168,13 +169,13 @@ fn slow_bar(seconds: u64, palette: Palette) -> impl IntoElement { bar(palette) .text_color(palette.danger) .child(Icon::new(IconName::Hourglass).size(px(size::ICON_SM))) - .child(format!("Slow down, you can send again in {seconds}s")) + .child(w().composer.slow_down(seconds)) } fn edit_bar(entity: &Entity, palette: Palette) -> impl IntoElement { bar(palette) .child(Icon::new(IconName::Pencil).size(px(size::ICON_SM))) - .child("Editing") + .child(w().composer.editing) .child(div().flex_1()) .child(cancel_button(entity, palette)) } @@ -186,7 +187,7 @@ fn cancel_button(entity: &Entity, palette: Palette) -> impl IntoElement "cancel_composer", palette, IconName::Close, - "Cancel", + w().composer.cancel, move |window, cx| { entity.update(cx, |yumush, cx| yumush.cancel_composer(window, cx)); }, @@ -272,7 +273,7 @@ impl Yumush { return; } let Some(community_id) = self.chat.selected_community_id else { - window.push_notification(Notification::error("No Community Selected"), cx); + window.push_notification(Notification::error(w().composer.no_community), cx); return; }; let network = self.network.clone(); @@ -651,7 +652,7 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i .child(plus_row( "plus_file", IconName::File, - "File", + w().composer.file, palette, move |window, cx| { popover.update(cx, |state, cx| state.dismiss(window, cx)); @@ -661,7 +662,7 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i .child(plus_row( "plus_poll", IconName::ChartBar, - "Poll", + w().composer.poll, palette, move |_, cx| { poll.update(cx, |yumush, cx| { @@ -704,7 +705,7 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i format!("poll_remove_{index}"), palette, IconName::Close, - "Remove option", + w().composer.remove_option, move |_, cx| { remove.update(cx, |yumush, cx| { yumush.remove_poll_option(index, cx) @@ -721,7 +722,7 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i .gap(px(space::XS)) .text_color(palette.muted) .child(Icon::new(IconName::Timer).size(px(size::ICON_SM))) - .children(POLL_DURATIONS.map(|(label, seconds)| { + .children(poll_durations().map(|(label, seconds)| { let set = duration_entity.clone(); let active = duration == seconds; clickable(label, palette, move |_, cx| { @@ -750,7 +751,7 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i .gap(px(space::MD)) .child( Checkbox::new("poll_multiple") - .label("Multiple answers") + .label(w().composer.multiple_answers) .checked(multiple) .on_click(move |_, _, cx| { toggle.update(cx, |yumush, cx| { @@ -761,7 +762,7 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i ) .child( Checkbox::new("poll_public") - .label("Show voters") + .label(w().composer.show_voters) .checked(public) .on_click(move |_, _, cx| { toggle_public @@ -781,25 +782,27 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i .items_center() .justify_center() .rounded(px(radius::MD)) - .child("Create"), + .child(w().composer.create), ) .into_any_element() }) } -const POLL_DURATIONS: [(&str, Option); 4] = [ - ("∞", None), - ("1h", Some(3600)), - ("1d", Some(86400)), - ("1w", Some(604800)), -]; +fn poll_durations() -> [(&'static str, Option); 4] { + [ + ("∞", None), + (w().composer.hour, Some(3600)), + (w().composer.day, Some(86400)), + (w().composer.week, Some(604800)), + ] +} fn option_text(input: &Entity, cx: &App) -> String { input.read(cx).text().to_string().trim().to_owned() } pub(super) fn new_poll_option(window: &mut Window, cx: &mut Context) -> Entity { - let input = new_input("Option", window, cx); + let input = new_input(w().composer.option, window, cx); cx.subscribe_in(&input, window, |this, input, event, window, cx| { if matches!(event, InputEvent::Change) { this.grow_poll_options(input, window, cx); diff --git a/crates/client/src/gui/forward.rs b/crates/client/src/gui/forward.rs index 9c765e6..7f67e6e 100644 --- a/crates/client/src/gui/forward.rs +++ b/crates/client/src/gui/forward.rs @@ -1,4 +1,5 @@ use super::style::{radius, size, space, text}; +use crate::lang::w; use common::call::ForwardMessages; use common::model::Id; use gpui_kit::{ @@ -35,7 +36,7 @@ impl Forward { ) -> Self { let filter = cx.new(|cx| { let mut state = InputState::new(window, cx); - state.set_placeholder("Filter", window, cx); + state.set_placeholder(w().forward.filter, window, cx); state }); cx.subscribe_in(&filter, window, |_, _, event, _, cx| { @@ -110,7 +111,7 @@ impl Render for Forward { .child(compact_field(palette, &self.filter)) .child( Checkbox::new("keep_authors") - .label("Keep authors") + .label(w().forward.keep_authors) .checked(keep_authors) .on_click(move |_, _, cx| { entity.update(cx, |this, cx| { @@ -147,7 +148,7 @@ impl Yumush { window.open_dialog(cx, move |dialog, _, _| { dialog - .title("Forward") + .title(w().forward.forward) .w(px(size::SHEET)) .child(forward.clone()) }); diff --git a/crates/client/src/gui/jump.rs b/crates/client/src/gui/jump.rs index e13f2a7..c2dc32e 100644 --- a/crates/client/src/gui/jump.rs +++ b/crates/client/src/gui/jump.rs @@ -1,22 +1,28 @@ -use common::model::{CommunityKind, Id}; +use crate::lang::{Label as _, w}; +use common::model::{Community, CommunityKind, Id, Presence, User}; use gpui_kit::{ - Context, Div, Entity, InteractiveElement, KeyDownEvent, ParentElement, - StatefulInteractiveElement, Styled, Window, component::input::InputState, div, - prelude::FluentBuilder as _, px, + Context, Div, Entity, FontWeight, InteractiveElement, KeyDownEvent, ParentElement, + ScrollHandle, StatefulInteractiveElement, Styled, Window, + assets::IconName, + component::{Icon, input::Input, input::InputState}, + div, + prelude::FluentBuilder as _, + px, }; use super::{ - Palette, Yumush, + Palette, Yumush, avatar, builder::BuilderTab, chat::View, - community_name, - parts::{Ink, Text, band, popover, words}, - settings_page::SETTINGS, - style::{size, space}, - widget::field, + community_icon, community_name, + parts::{Ink, Text, band, words}, + presence_avatar, + settings_page::{SETTINGS_IDS, settings_titles}, + style::{Theme, Tokens, my_hue, radius, size, space, stroke, text}, + widget::bare_input, }; -const SHOWN: usize = 8; +const ROWS: f32 = 8.; #[derive(Clone, Copy, PartialEq)] pub(super) enum Place { @@ -26,16 +32,81 @@ pub(super) enum Place { Friends, Settings(usize), Builder(BuilderTab), + NewCommunity, + Theme(Theme), + Presence(Presence), + Sidebar, + Mute, + Deafen, + Share, + Camera, + LeaveCall, + LogOut, } pub(super) struct Jump { pub(super) open: bool, pub(super) cursor: usize, pub(super) input: Entity, + pub(super) scroll: ScrollHandle, +} + +enum Glyph { + Icon(IconName), + Person(User), + Room(Community), +} + +struct Row { + place: Place, + label: String, + glyph: Glyph, + hint: Option<&'static str>, +} + +impl Row { + fn new(place: Place, label: impl Into, glyph: Glyph) -> Self { + Self { + place, + label: label.into(), + glyph, + hint: None, + } + } + + fn hinted(self, hint: &'static str) -> Self { + Self { + hint: Some(hint), + ..self + } + } +} + +impl Place { + fn key(self) -> String { + match self { + Place::Room(id) => format!("room:{id}"), + Place::Person(id) => format!("person:{id}"), + Place::Notes => "notes".into(), + Place::Friends => "friends".into(), + Place::Settings(index) => format!("settings:{}", SETTINGS_IDS[index]), + Place::Builder(tab) => format!("builder:{}", tab.id()), + Place::NewCommunity => "new_community".into(), + Place::Theme(theme) => format!("theme:{}", theme.as_str()), + Place::Presence(presence) => format!("presence:{}", presence.as_str()), + Place::Sidebar => "sidebar".into(), + Place::Mute => "mute".into(), + Place::Deafen => "deafen".into(), + Place::Share => "share".into(), + Place::Camera => "camera".into(), + Place::LeaveCall => "leave_call".into(), + Place::LogOut => "log_out".into(), + } + } } impl Yumush { - fn places(&self, cx: &gpui_kit::App) -> Vec<(Place, String, &'static str)> { + fn places(&self, cx: &gpui_kit::App) -> Vec { let query = self.chat.goto.input.read(cx).value().to_lowercase(); let call = self.chat.voice_community(); let unread = |id: Id| { @@ -52,15 +123,10 @@ impl Yumush { .collect(); rooms.sort_by_key(|community| (Some(community.id) != call, !unread(community.id))); let rooms = rooms.into_iter().map(|community| { - let hint = if community.kind.is_direct() { - "person" - } else { - "community" - }; - ( + Row::new( Place::Room(community.id), community_name(community).to_string(), - hint, + Glyph::Room(community.clone()), ) }); let directs: Vec = self @@ -84,37 +150,160 @@ impl Yumush { && self.user.as_ref().is_none_or(|me| me.id != user.id) && seen.insert(user.id) }) - .map(|user| (Place::Person(user.id), user.username.to_string(), "person")) + .map(|user| { + Row::new( + Place::Person(user.id), + user.username.to_string(), + Glyph::Person(user.clone()), + ) + }) .collect::>(); let pages = [ - (Place::Notes, "Notes".to_string(), "page"), - (Place::Friends, "Friends".to_string(), "page"), + Row::new( + Place::Notes, + w().jump.notes.to_string(), + Glyph::Icon(IconName::Bookmark), + ), + Row::new( + Place::Friends, + w().jump.friends.to_string(), + Glyph::Icon(IconName::Users), + ), ] .into_iter() .chain( - SETTINGS - .iter() + settings_titles() + .into_iter() .enumerate() - .map(|(index, title)| (Place::Settings(index), title.to_string(), "settings")), + .map(|(index, title)| { + Row::new( + Place::Settings(index), + title.to_string(), + Glyph::Icon(IconName::Settings2), + ) + .hinted(w().jump.hint_settings) + }), ) .chain( BuilderTab::ALL .into_iter() .filter(|_| self.is_builder()) - .map(|tab| (Place::Builder(tab), tab.label().to_string(), "builder")), + .map(|tab| { + Row::new( + Place::Builder(tab), + tab.label().to_string(), + Glyph::Icon(IconName::Shield), + ) + }), ); - rooms + let action = |place: Place, label: &str, icon: IconName| { + Row::new(place, label.to_string(), Glyph::Icon(icon)) + }; + let call = self.chat.voice_flags().map(|(muted, deafened)| { + [ + action( + Place::Mute, + if muted { + w().jump.unmute + } else { + w().jump.mute + }, + if muted { + IconName::MicOff + } else { + IconName::Mic + }, + ), + action( + Place::Deafen, + if deafened { + w().jump.undeafen + } else { + w().jump.deafen + }, + if deafened { + IconName::HeadphoneOff + } else { + IconName::Headphones + }, + ), + action( + Place::Share, + if self.network.sharing() { + w().jump.stop_sharing + } else { + w().jump.share_screen + }, + IconName::Monitor, + ), + action( + Place::Camera, + if self.network.camera_on() { + w().jump.camera_off + } else { + w().jump.camera_on + }, + IconName::Video, + ), + action(Place::LeaveCall, w().jump.leave_call, IconName::PhoneOff), + ] + }); + let actions = call + .into_iter() + .flatten() + .chain([ + action(Place::NewCommunity, w().jump.new_community, IconName::Plus), + action( + Place::Sidebar, + if self.chat.sidebar_collapsed { + w().jump.expand_sidebar + } else { + w().jump.collapse_sidebar + }, + IconName::PanelLeft, + ), + ]) + .chain(Theme::ALL.into_iter().map(|theme| { + Row::new( + Place::Theme(theme), + theme.label().to_string(), + Glyph::Icon(match theme { + Theme::Gece => IconName::Moon, + Theme::Gun => IconName::Sun, + }), + ) + .hinted(w().jump.hint_theme) + })) + .chain(Presence::ALL.into_iter().map(|presence| { + Row::new( + Place::Presence(presence), + presence.label().to_string(), + Glyph::Icon(IconName::Circle), + ) + })) + .chain([action(Place::LogOut, w().jump.log_out, IconName::LogOut)]); + let mut found: Vec<_> = rooms .chain(people) .chain(pages) - .filter(|(_, label, _)| label.to_lowercase().contains(&query)) - .take(SHOWN) - .collect() + .chain(actions) + .filter_map(|row| Some((rank(&row.label, &query)?, row))) + .collect(); + let usage = &self.settings.jump_usage; + found.sort_by_key(|(rank, row)| { + ( + *rank, + std::cmp::Reverse(usage.get(&row.place.key()).copied().unwrap_or(0)), + ) + }); + found.into_iter().map(|(_, row)| row).collect() } pub(super) fn open_jump(&mut self, window: &mut Window, cx: &mut Context) { self.chat.goto.open = true; self.chat.goto.cursor = 0; + self.chat.goto.scroll.scroll_to_item(0); self.chat.goto.input.update(cx, |input, cx| { + input.set_placeholder(w().jump.placeholder, window, cx); input.set_value("", window, cx); input.focus(window, cx); }); @@ -132,6 +321,7 @@ impl Yumush { if count > 0 { self.chat.goto.cursor = (self.chat.goto.cursor as isize + step).rem_euclid(count as isize) as usize; + self.chat.goto.scroll.scroll_to_item(self.chat.goto.cursor); } cx.notify(); } @@ -140,13 +330,21 @@ impl Yumush { let place = self .places(cx) .get(self.chat.goto.cursor) - .map(|(place, ..)| *place); - self.close_jump(window, cx); + .map(|row| row.place); if let Some(place) = place { - self.go_place(place, window, cx); + self.pick(place, window, cx); + } else { + self.close_jump(window, cx); } } + fn pick(&mut self, place: Place, window: &mut Window, cx: &mut Context) { + self.close_jump(window, cx); + *self.settings.jump_usage.entry(place.key()).or_default() += 1; + crate::settings::save(&self.settings); + self.go_place(place, window, cx); + } + fn go_place(&mut self, place: Place, window: &mut Window, cx: &mut Context) { match place { Place::Room(id) => { @@ -167,18 +365,69 @@ impl Yumush { self.show_view(View::Builder, window, cx); self.select_builder_tab(tab, window, cx); } + Place::NewCommunity => self.new_community(window, cx), + Place::Theme(theme) => self.set_theme(theme, cx), + Place::Presence(presence) => self.set_presence(presence, window, cx), + Place::Sidebar => self.toggle_sidebar(), + Place::Mute => self.toggle_mute(window, cx), + Place::Deafen => self.toggle_deafen(cx), + Place::Share => self.toggle_share(window, cx), + Place::Camera => self.toggle_camera(window, cx), + Place::LeaveCall => self.end_voice(cx), + Place::LogOut => self.logout(window, cx), } cx.notify(); } + fn glyph(&self, glyph: Glyph, palette: Palette) -> Div { + let t = palette.tokens; + let face = match glyph { + Glyph::Icon(icon) => div() + .text_color(t.faint()) + .child(Icon::new(icon).size(px(size::ICON))), + Glyph::Person(user) => presence_avatar( + avatar( + palette, + &user, + px(size::CHIP), + t.text(text::CAPTION), + &self.chat.avatars, + ), + self.presence_of(user.id), + px(size::CHIP), + palette, + ), + Glyph::Room(community) => community_icon( + palette, + &community, + px(size::CHIP), + t.text(text::CAPTION), + &self.chat.avatars, + ), + }; + div() + .flex_none() + .size(px(size::CHIP)) + .flex() + .items_center() + .justify_center() + .child(face) + } + pub(super) fn jump_box(&self, palette: Palette, cx: &mut Context) -> Option
{ if !self.chat.goto.open { return None; } let t = palette.tokens; + let query = self.chat.goto.input.read(cx).value().trim().to_lowercase(); let places = self.places(cx); let cursor = self.chat.goto.cursor.min(places.len().saturating_sub(1)); let entity = cx.entity(); + let rule = if query.is_empty() { + t.thread() + } else { + t.hue(my_hue()) + }; Some( div() .absolute() @@ -196,9 +445,16 @@ impl Yumush { .on_click(cx.listener(|this, _, window, cx| this.close_jump(window, cx))), ) .child( - popover(t) + div() .w(px(size::SHEET + size::THUMB)) - .gap(px(space::XS)) + .flex() + .flex_col() + .overflow_hidden() + .bg(t.raise()) + .rounded(px(radius::LG)) + .border_1() + .border_color(t.thread()) + .shadow_lg() .occlude() .capture_action(cx.listener( |this, _: &gpui_kit::component::input::Escape, window, cx| { @@ -214,41 +470,169 @@ impl Yumush { } cx.stop_propagation(); })) - .child(field(palette, &self.chat.goto.input)) - .children(places.into_iter().enumerate().map( - |(index, (place, label, hint))| { - let entity = entity.clone(); - band(space::SM) - .id(("jump_row", index)) - .h(px(size::CONTROL_SM)) - .px(px(space::SM)) - .cursor_pointer() - .when(index == cursor, |row| row.bg(palette.hover)) - .on_click(move |_, window, cx| { - entity.update(cx, |yumush, cx| { - yumush.close_jump(window, cx); - yumush.go_place(place, window, cx); - }) - }) - .child( - words( - label, - Text::Ui, - if index == cursor { - Ink::Paper - } else { - Ink::Dim - }, - t, - ) + .child( + band(space::MD) + .py(px(space::MD)) + .px(px(space::LG)) + .child( + div() .flex_1() .min_w_0() - .truncate(), - ) - .child(words(hint, Text::Caption, Ink::Faint, t)) - }, - )), + .text_size(t.text(text::BODY)) + .child(bare_input( + palette, + Input::new(&self.chat.goto.input) + .token(super::glyph::token), + )), + ) + .child(words(w().jump.esc, Text::Caption, Ink::Faint, t)), + ) + .child(div().w_full().h(px(stroke::LINE)).flex_none().bg(rule)) + .child( + div() + .id("jump_list") + .p(px(space::SM)) + .max_h(px((size::CONTROL_SM + space::SM) * ROWS + space::SM * 2.)) + .overflow_y_scroll() + .track_scroll(&self.chat.goto.scroll) + .flex() + .flex_col() + .gap(px(space::SM)) + .children(places.into_iter().enumerate().map(|(index, row)| { + let entity = entity.clone(); + let selected = index == cursor; + let place = row.place; + band(space::SM) + .id(("jump_row", index)) + .h(px(size::CONTROL_SM)) + .px(px(space::SM)) + .rounded(px(radius::MD)) + .cursor_pointer() + .when(selected, |line| line.bg(t.hov())) + .on_click(move |_, window, cx| { + entity.update(cx, |yumush, cx| { + yumush.pick(place, window, cx) + }) + }) + .child(self.glyph(row.glyph, palette)) + .child(label_line(&row.label, &query, selected, t)) + .when_some(row.hint, |line, hint| { + line.child(words(hint, Text::Caption, Ink::Faint, t)) + }) + .when(selected, |line| { + line.child( + div().flex_none().text_color(t.faint()).child( + Icon::new(IconName::CornerDownLeft) + .size(px(size::ICON_SM)), + ), + ) + }) + })), + ), ), ) } } + +fn matched(label: &str, query: &str) -> Option<(usize, usize)> { + if query.is_empty() { + return None; + } + label.char_indices().find_map(|(start, _)| { + label[start..] + .char_indices() + .map(|(offset, letter)| start + offset + letter.len_utf8()) + .find(|&end| label[start..end].to_lowercase() == query) + .map(|end| (start, end)) + }) +} + +fn label_line(label: &str, query: &str, selected: bool, t: Tokens) -> Div { + let (before, hit, after) = match matched(label, query) { + Some((start, end)) => (&label[..start], &label[start..end], &label[end..]), + None => (label, "", ""), + }; + let tone = |ink: Ink| if selected { Ink::Paper } else { ink }; + let weight = if selected { + FontWeight::MEDIUM + } else { + FontWeight::NORMAL + }; + div().flex().flex_1().min_w_0().overflow_hidden().children( + [(before, Ink::Dim), (hit, Ink::Paper), (after, Ink::Dim)] + .into_iter() + .filter(|(piece, _)| !piece.is_empty()) + .map(|(piece, ink)| words(piece, Text::Ui, tone(ink), t).font_weight(weight)), + ) +} + +fn rank(label: &str, query: &str) -> Option { + let label = label.to_lowercase(); + let query = query.trim().to_lowercase(); + let query = query.as_str(); + if label.starts_with(query) { + return Some(0); + } + let words = || label.split_whitespace(); + if words().any(|word| word.starts_with(query)) { + return Some(1); + } + if label.contains(query) { + return Some(2); + } + let mut rest = label.chars(); + if query + .chars() + .filter(|letter| !letter.is_whitespace()) + .all(|letter| rest.any(|other| other == letter)) + { + return Some(3); + } + let query: Vec = query.chars().collect(); + let allowed = if query.len() <= 4 { 1 } else { 2 }; + let mut best = usize::MAX; + for word in std::iter::once(label.as_str()).chain(words()) { + let word: Vec = word.chars().collect(); + for end in query.len().saturating_sub(1)..=(query.len() + 1).min(word.len()) { + best = best.min(typos(&query, &word[..end])); + } + } + (query.len() > 1 && best <= allowed).then_some(3 + best) +} + +fn typos(a: &[char], b: &[char]) -> usize { + let mut rows = vec![(0..=b.len()).collect::>(); a.len() + 1]; + for (i, row) in rows.iter_mut().enumerate() { + row[0] = i; + } + for i in 1..=a.len() { + for j in 1..=b.len() { + let swap = usize::from(a[i - 1] != b[j - 1]); + let mut best = (rows[i - 1][j] + 1) + .min(rows[i][j - 1] + 1) + .min(rows[i - 1][j - 1] + swap); + if i > 1 && j > 1 && a[i - 1] == b[j - 2] && a[i - 2] == b[j - 1] { + best = best.min(rows[i - 2][j - 2] + 1); + } + rows[i][j] = best; + } + } + rows[a.len()][b.len()] +} + +#[cfg(test)] +mod tests { + use super::rank; + + #[test] + fn forgives_typos() { + assert_eq!(rank("New community", "new"), Some(0)); + assert_eq!(rank("New community", "comm"), Some(1)); + assert!(rank("New community", "nwcm").is_some()); + assert!(rank("New community", "comunity").is_some()); + assert!(rank("Settings", "settigns").is_some()); + assert!(rank("Log out", "lgo").is_some()); + assert!(rank("Friends", "zz").is_none()); + assert!(rank("Mute", "xyz").is_none()); + } +} diff --git a/crates/client/src/gui/media_view.rs b/crates/client/src/gui/media_view.rs index 722d75b..e856a9e 100644 --- a/crates/client/src/gui/media_view.rs +++ b/crates/client/src/gui/media_view.rs @@ -1,5 +1,6 @@ use super::style::{radius, size, space, text}; use super::text; +use crate::lang::w; use common::model::Id; use std::{ collections::{HashMap, HashSet}, @@ -668,7 +669,7 @@ fn file_view( .child(icon_button( format!("save_{}", attachment.id), IconName::ArrowDown, - "Save", + w().media_view.save, palette, on_attachment(entity, attachment, |yumush, attachment, window, cx| { yumush.save_attachment(attachment, window, cx) @@ -695,7 +696,11 @@ fn player_view( } else { IconName::Play }, - if playing { "Pause" } else { "Play" }, + if playing { + w().media_view.pause + } else { + w().media_view.play + }, palette, on_attachment(entity, attachment, |yumush, attachment, window, cx| { yumush.play(attachment, window, cx) @@ -914,7 +919,7 @@ pub fn pending_row( }) }, ) - .tip("Remove") + .tip(w().media_view.remove) .size(px(size::CHIP)) .flex() .items_center() diff --git a/crates/client/src/gui/message_actions.rs b/crates/client/src/gui/message_actions.rs index 72f1e0b..b7f008a 100644 --- a/crates/client/src/gui/message_actions.rs +++ b/crates/client/src/gui/message_actions.rs @@ -1,4 +1,5 @@ use super::text; +use crate::lang::w; use common::model::Id; use common::{ call::{Pin, React, ReportMessage, ReportUser}, @@ -129,7 +130,7 @@ pub fn react_popover( pub fn quote_text(body: &str, attachments: u32) -> String { if body.is_empty() { - format!("{attachments} attachments") + w().message_actions.attachments(attachments) } else { body.to_string() } @@ -348,7 +349,8 @@ pub fn actions( entity, palette, id, - "Reply", + "reply", + w().message_actions.reply, IconName::Reply, |yumush, id, window, cx| yumush.reply(id, window, cx), )) @@ -358,7 +360,8 @@ pub fn actions( entity, palette, id, - "Edit", + "edit", + w().message_actions.edit, IconName::Pencil, |yumush, id, window, cx| yumush.edit(id, window, cx), ) @@ -367,7 +370,8 @@ pub fn actions( entity, palette, id, - "Forward", + "forward", + w().message_actions.forward, IconName::Forward, |yumush, id, window, cx| yumush.open_forward(vec![id], window, cx), )) @@ -375,7 +379,8 @@ pub fn actions( entity, palette, id, - "Select", + "select", + w().message_actions.select, IconName::ListChecks, |yumush, id, window, cx| yumush.start_select(id, window, cx), )) @@ -384,7 +389,12 @@ pub fn actions( entity, palette, id, - if message.pinned { "Unpin" } else { "Pin" }, + "pin", + if message.pinned { + w().message_actions.unpin + } else { + w().message_actions.pin + }, if message.pinned { IconName::PinOff } else { @@ -398,7 +408,8 @@ pub fn actions( entity, palette, id, - "Report", + "report", + w().message_actions.report, IconName::TriangleAlert, |yumush, id, window, cx| yumush.start_report(ReportTarget::Message(id), window, cx), ) @@ -408,7 +419,12 @@ pub fn actions( entity, palette, id, - if armed { "Confirm" } else { "Delete" }, + "delete", + if armed { + w().message_actions.confirm + } else { + w().message_actions.delete + }, IconName::Trash, |yumush, id, window, cx| yumush.request_message_delete(id, window, cx), ) @@ -439,7 +455,7 @@ pub fn report_bar( .flex() .items_center() .rounded(px(radius::MD)) - .child("Send"), + .child(w().message_actions.send), ) } @@ -535,6 +551,7 @@ fn action( entity: &Entity, palette: Palette, message_id: Id, + name: &'static str, tip: &'static str, icon: IconName, run: fn(&mut Yumush, Id, &mut Window, &mut Context), @@ -542,7 +559,7 @@ fn action( let entity = entity.clone(); icon_button( - format!("{tip}_{message_id}"), + format!("{name}_{message_id}"), palette, icon, tip, diff --git a/crates/client/src/gui/poll.rs b/crates/client/src/gui/poll.rs index a1bce29..f20048f 100644 --- a/crates/client/src/gui/poll.rs +++ b/crates/client/src/gui/poll.rs @@ -1,3 +1,4 @@ +use crate::lang::w; use common::call::{ClosePoll, MyVotes, Vote}; use common::model::Id; use common::model::{Message, Poll, Rank, User}; @@ -160,11 +161,11 @@ pub fn is_closed(poll: &Poll) -> bool { fn remaining(end: u64) -> String { let left = end.saturating_sub(now_ms()); if left >= DAY_MILLIS { - format!("{}d", left / DAY_MILLIS) + w().poll.days_left(left / DAY_MILLIS) } else if left >= HOUR_MILLIS { - format!("{}h", left / HOUR_MILLIS) + w().poll.hours_left(left / HOUR_MILLIS) } else { - format!("{}m", (left / MINUTE_MILLIS).max(1)) + w().poll.minutes_left((left / MINUTE_MILLIS).max(1)) } } @@ -347,7 +348,7 @@ pub fn poll_card( format!("poll_close_{close_id}"), palette, IconName::CircleStop, - "End poll", + w().poll.end_poll, move |window, cx| { close_entity .update(cx, |yumush, cx| yumush.close_poll(close_id, window, cx)); @@ -357,9 +358,9 @@ pub fn poll_card( ); let (visibility, visibility_tip) = if poll.public { - (IconName::Eye, "Voters visible") + (IconName::Eye, w().poll.voters_visible) } else { - (IconName::EyeOff, "Anonymous") + (IconName::EyeOff, w().poll.anonymous) }; div() @@ -403,7 +404,7 @@ pub fn poll_card( status_icon( format!("poll_multiple_{key}"), IconName::ListChecks, - "Multiple choice", + w().poll.multiple_choice, palette, ) })) @@ -411,7 +412,7 @@ pub fn poll_card( status_icon( format!("poll_closed_{key}"), IconName::Lock, - "Closed", + w().poll.closed, palette, ) })), @@ -487,7 +488,7 @@ impl Yumush { div() .flex_shrink_0() .text_color(palette.muted) - .child(format!("{} votes", voter_count(poll))), + .child(w().poll.votes(voter_count(poll))), ) .child( div().flex_shrink_0().text_color(palette.muted).child( @@ -510,7 +511,7 @@ impl Yumush { .child(page_button( "poll_page_back", IconName::ChevronLeft, - "Previous", + w().poll.previous, count - 1, entity, palette, @@ -519,7 +520,7 @@ impl Yumush { .child(page_button( "poll_page_next", IconName::ChevronRight, - "Next", + w().poll.next, 1, entity, palette, @@ -529,7 +530,7 @@ impl Yumush { "poll_banner_jump", palette, IconName::ArrowUpRight, - "Jump to message", + w().poll.jump_to_message, move |window, cx| { jump.update(cx, |yumush, cx| { yumush.go_to_message(message_id, window, cx) diff --git a/crates/client/src/gui/profile.rs b/crates/client/src/gui/profile.rs index aa64c41..903d827 100644 --- a/crates/client/src/gui/profile.rs +++ b/crates/client/src/gui/profile.rs @@ -1,4 +1,5 @@ use crate::gui::glyph::Fill as _; +use crate::lang::{Label as _, w}; use common::model::Id; use gpui_kit::prelude::FluentBuilder as _; use std::collections::VecDeque; @@ -30,8 +31,8 @@ use super::social::Relation; use super::style::{radius, size, space, stroke, text}; use super::widget::spawn_done; use super::{ - DAY_YEAR, Palette, Tooltip as _, Trigger, Yumush, avatar, clickable, entity_action, - input_dialog, millis_time, notify_error, palette, presence_color, rank_tag, text, + Palette, Tooltip as _, Trigger, Yumush, avatar, clickable, entity_action, input_dialog, + millis_time, notify_error, palette, text, }; const ACCOUNTS_MAX_H: f32 = 180.; @@ -44,9 +45,10 @@ enum Removal { impl Removal { fn title(self) -> &'static str { + let w = &w().profile; match self { - Removal::Kick => "Kick", - Removal::Ban => "Ban", + Removal::Kick => w.kick, + Removal::Ban => w.ban, } } } @@ -121,7 +123,7 @@ pub(super) fn profile_popover( .map(|volume| (volume.slider.clone(), yumush.user_volume(user.id))), call: yumush.call_of(user.id).map(|community| { if community.kind.is_direct() { - "a call".to_string() + w().profile.a_call.to_string() } else { community.name.clone() } @@ -166,7 +168,7 @@ impl Card { let mut rows = vec![ menu_row( "profile_message", - "Message", + w().profile.message, menu_icon(IconName::MessageSquare), palette.text, palette, @@ -177,7 +179,7 @@ impl Card { .into_any_element(), menu_row( "profile_call", - "Call", + w().profile.call, menu_icon(IconName::Phone), palette.text, palette, @@ -192,7 +194,7 @@ impl Card { rows.push( menu_row( "profile_report", - "Report", + w().profile.report, menu_icon(IconName::TriangleAlert), palette.danger, palette, @@ -235,51 +237,98 @@ impl Card { .as_ref() .is_some_and(|viewer| viewer.id == self.user.id); let t = palette.tokens; - let rows = if is_self { - self_rows( - &self.others, - self.card_menu, - self.presence, - entity, - &popover, - palette, - ) + let actions = if is_self { + div() + .flex() + .flex_col() + .gap(px(space::XS)) + .children(self_rows( + &self.others, + self.card_menu, + entity, + &popover, + palette, + )) + .into_any_element() } else { let mut rows = self.social_rows(entity, &popover, palette); rows.extend(self.moderation_rows(entity, &popover, palette)); if self.card_menu == CardMenu::More || rows.len() < 3 { - rows + div() + .flex() + .flex_col() + .gap(px(space::XS)) + .children(rows) + .into_any_element() } else { let first = rows.remove(0); let second = rows.remove(0); - vec![ - band(space::XS) - .child(first) - .child(second) - .child(div().flex_1()) - .child(icon_button( - "profile_more", - IconName::Ellipsis, - "More", - Tone::Idle, - t, - card_menu_action(entity, CardMenu::More), - )) - .into_any_element(), - ] + band(space::XS) + .child(first) + .child(second) + .child(div().flex_1()) + .child(icon_button( + "profile_more", + IconName::Ellipsis, + w().profile.more, + Tone::Idle, + t, + card_menu_action(entity, CardMenu::More), + )) + .into_any_element() } }; - let doing = match (&self.call, is_self) { - (Some(room), _) => format!("in {room}"), - (None, true) => String::new(), - (None, false) => self.presence.label().to_lowercase(), + let location = match &self.call { + Some(room) => w().profile.in_room(room), + None => self.presence.label().to_lowercase(), }; - let joined = format!("joined {}", millis_time(self.user.created_at, DAY_YEAR)); - let about = if doing.is_empty() { - joined + let place = match self.target { + Some(Rank::Builder) => band(space::XXS) + .child( + Icon::new(IconName::Shield) + .size(px(size::ICON_SM)) + .text_color(palette.accent), + ) + .child( + words(Rank::Builder.label(), Text::Caption, Ink::Faint, t) + .text_color(palette.accent), + ) + .into_any_element(), + Some(rank @ (Rank::Moderator | Rank::Admin | Rank::Owner)) => { + words(rank.label(), Text::Caption, Ink::Faint, t).into_any_element() + } + _ => words(location, Text::Caption, Ink::Faint, t).into_any_element(), + }; + let tint = match self.presence { + Presence::Offline => t.off(), + _ => t.person(self.user.id), + }; + let line = if self.call.is_some() { + div() + .h(px(space::LG)) + .child(voice_line( + self.wave.as_ref(), + if self.speaking { + Voice::Live(t.person(self.user.id)) + } else { + Voice::Quiet + }, + t, + )) + .into_any_element() } else { - format!("{doing} · {joined}") + div() + .w_full() + .h(px(stroke::LINE)) + .bg(tint) + .into_any_element() }; + let caption = band(space::SM).justify_between().child(place).child(words( + millis_time(self.user.created_at, crate::lang::w().common.day_year), + Text::Caption, + Ink::Faint, + t, + )); super::parts::popover(t) .w(px(size::POPOVER)) @@ -308,6 +357,24 @@ impl Card { move |_, window, cx| { popover.update(cx, |state, cx| state.dismiss(window, cx)); } + }) + .map(|picture| { + if is_self { + div().relative().flex_shrink_0().child(picture).child( + div() + .absolute() + .right(px(-space::XXS)) + .bottom(px(-space::XXS)) + .child(presence_menu(self.presence, entity, palette)), + ) + } else { + super::presence_avatar( + picture, + self.presence, + px(size::AVATAR_LG), + palette, + ) + } }), ) .child( @@ -315,7 +382,7 @@ impl Card { .flex_1() .min_w_0() .child( - band(space::SM) + band(space::XS) .child( words( self.user.username.clone(), @@ -323,9 +390,13 @@ impl Card { Ink::Paper, t, ) - .font_weight(FontWeight::MEDIUM), + .font_weight(FontWeight::MEDIUM) + .min_w_0() + .truncate(), ) - .children(rank_tag(self.target, palette)), + .when(is_self, |name| { + name.child(account_toggle(self.card_menu, entity, palette)) + }), ) .map(|names| { if !is_self { @@ -391,48 +462,38 @@ impl Card { }), ), ) - .children(self.call.is_some().then(|| { - div().h(px(space::MD)).child(voice_line( - self.wave.as_ref(), - if self.speaking { - Voice::Live(t.person(self.user.id)) - } else { - Voice::Quiet - }, - t, - )) - })) - .child(words(about, Text::Caption, Ink::Faint, t)) + .when(!is_self, |card| { + card.child(stack(space::XS).child(line).child(caption)) + }) .children(self.volume.clone().map(|(slider, volume)| { - band(space::MD) - .child(words("Volume", Text::Label, Ink::Paper, t).flex_none()) - .child(super::parts::slider(&slider, t)) - .child( - words(format!("{volume:.0}%"), Text::Caption, Ink::Dim, t) - .w(px(size::CONTROL)) - .text_right(), - ) - })) - .children(self.volume.as_ref().map(|(_, volume)| { let user_id = self.user.id; - band(space::MD) - .child(words("Mute", Text::Label, Ink::Paper, t)) - .child(div().flex_1()) - .child(super::parts::toggle( + band(space::SM) + .child(icon_button( "profile_mute", - *volume == 0., + if volume == 0. { + IconName::VolumeX + } else { + IconName::Volume2 + }, + w().profile.mute, + Tone::Idle, t, entity_action(entity, move |yumush, window, cx| { yumush.toggle_user_mute(user_id, window, cx) }), )) + .child(super::parts::slider(&slider, t)) + .child( + words(format!("{volume:.0}%"), Text::Caption, Ink::Dim, t) + .w(px(size::CONTROL)) + .text_right(), + ) })) .children( self.reporting .then(|| report_bar(&self.reason, entity, palette)), ) - .children((!rows.is_empty()).then(|| div().h(px(stroke::LINE)).bg(palette.border))) - .child(div().flex().flex_col().gap(px(space::XS)).children(rows)) + .child(actions) } fn moderation_rows( @@ -448,7 +509,7 @@ impl Card { for rank in [Rank::Member, Rank::Moderator, Rank::Admin] { if target != Some(rank) && permission::can_set_rank(actor, target, rank) { - let label = format!("Make {}", rank.label().to_lowercase()); + let label = w().profile.make_rank(rank.label().to_lowercase()); rows.push( menu_row( label.clone(), @@ -471,7 +532,7 @@ impl Card { rows.push( menu_row( "kick", - "Kick", + w().profile.kick, menu_icon(IconName::Close), palette.danger, palette, @@ -484,7 +545,7 @@ impl Card { rows.push( menu_row( "ban", - "Ban", + w().profile.ban, menu_icon(IconName::Ban), palette.danger, palette, @@ -502,9 +563,9 @@ impl Card { .is_some_and(|viewer| permission::can_delete_user(viewer.role, false, self.user.role)); if deletable { let label = if self.confirming { - "Confirm" + w().profile.confirm } else { - "Delete user" + w().profile.delete_user }; rows.push( @@ -527,46 +588,27 @@ impl Card { fn self_rows( others: &[(Id, String)], card_menu: CardMenu, - presence: Presence, entity: &Entity, popover: &Entity, palette: Palette, ) -> Vec { match card_menu { + CardMenu::Accounts => accounts_rows(others, entity, popover, palette), CardMenu::Main | CardMenu::More | CardMenu::Status => { - main_self_rows(presence, entity, popover, palette) + main_self_rows(entity, popover, palette) } - CardMenu::Accounts => accounts_rows(others, entity, popover, palette), - CardMenu::Presence => presence_rows(entity, palette), } } fn main_self_rows( - presence: Presence, entity: &Entity, popover: &Entity, palette: Palette, ) -> Vec { vec![ - drill_row(menu_row( - "profile_presence", - presence.label(), - presence_dot(presence, palette), - palette.text, - palette, - card_menu_action(entity, CardMenu::Presence), - )), - drill_row(menu_row( - "profile_accounts", - "Accounts", - menu_icon(IconName::CircleUser), - palette.text, - palette, - card_menu_action(entity, CardMenu::Accounts), - )), menu_row( "profile_settings", - "Settings", + w().profile.settings, menu_icon(IconName::Settings), palette.text, palette, @@ -577,7 +619,7 @@ fn main_self_rows( .into_any_element(), menu_row( "profile_logout", - "Log out", + w().profile.log_out, menu_icon(IconName::LogOut), palette.danger, palette, @@ -609,15 +651,6 @@ fn accounts_rows( }); vec![ - menu_row( - "profile_accounts_back", - "Accounts", - menu_icon(IconName::ArrowLeft), - palette.muted, - palette, - card_menu_action(entity, CardMenu::Main), - ) - .into_any_element(), div() .id("profile_accounts") .max_h(px(ACCOUNTS_MAX_H)) @@ -628,7 +661,7 @@ fn accounts_rows( .into_any_element(), menu_row( "profile_add_account", - "Add account", + w().profile.add_account, menu_icon(IconName::UserPlus), palette.text, palette, @@ -640,34 +673,36 @@ fn accounts_rows( ] } -fn presence_rows(entity: &Entity, palette: Palette) -> Vec { - let mut rows = vec![ - menu_row( - "profile_presence_back", - "Status", - menu_icon(IconName::ArrowLeft), - palette.muted, - palette, - card_menu_action(entity, CardMenu::Main), - ) - .into_any_element(), - ]; - - rows.extend(Presence::ALL.into_iter().map(|presence| { - menu_row( - format!("presence_{}", presence.as_str()), - presence.label(), - presence_dot(presence, palette), - palette.text, - palette, - entity_action(entity, move |yumush, window, cx| { - yumush.set_presence(presence, window, cx) - }), - ) - .into_any_element() - })); - - rows +fn account_toggle( + card_menu: CardMenu, + entity: &Entity, + palette: Palette, +) -> impl IntoElement { + let open = card_menu == CardMenu::Accounts; + clickable( + "profile_accounts", + palette, + card_menu_action( + entity, + if open { + CardMenu::Main + } else { + CardMenu::Accounts + }, + ), + ) + .tip(w().profile.accounts) + .rounded(px(radius::SM)) + .flex_shrink_0() + .child( + Icon::new(if open { + IconName::ChevronUp + } else { + IconName::ChevronDown + }) + .size(px(size::ICON_SM)) + .text_color(palette.muted), + ) } fn edit_status(entity: &Entity, status: &str, palette: Palette) -> impl IntoElement { @@ -684,7 +719,7 @@ fn edit_status(entity: &Entity, status: &str, palette: Palette) -> impl cx.notify(); }), ) - .tip("Edit status") + .tip(w().profile.edit_status) .flex_none() .p(px(space::XXS)) .rounded(px(radius::SM)) @@ -705,13 +740,6 @@ fn card_menu_action( }) } -fn presence_dot(presence: Presence, palette: Palette) -> Div { - div() - .size(px(space::SM)) - .rounded_full() - .bg(presence_color(presence, palette)) -} - fn yumush_action( entity: &Entity, popover: &Entity, @@ -751,6 +779,65 @@ fn menu_icon(icon: IconName) -> Icon { Icon::new(icon).size(px(size::ICON_SM)) } +fn presence_dot(presence: Presence, palette: Palette) -> Div { + div() + .size(px(space::LG)) + .rounded_full() + .border_2() + .border_color(palette.tokens.raise()) + .bg(super::presence_color(presence, palette)) +} + +fn presence_menu(current: Presence, entity: &Entity, palette: Palette) -> Popover { + let entity = entity.clone(); + Popover::new("presence_menu") + .anchor(Anchor::TopLeft) + .appearance(false) + .trigger(Trigger::new( + clickable("presence_dot", palette, |_, _| {}) + .rounded_full() + .child(presence_dot(current, palette)), + )) + .content(move |_, _, cx| { + let popover = cx.entity(); + super::parts::popover(palette.tokens) + .p(px(space::XS)) + .children(Presence::ALL.into_iter().map(|presence| { + let popover = popover.clone(); + menu_row( + ("presence", presence as usize), + presence.label(), + div() + .size(px(size::ICON_SM)) + .flex() + .items_center() + .justify_center() + .child( + div() + .size(px(space::SM)) + .rounded_full() + .bg(super::presence_color(presence, palette)), + ), + if presence == current { + palette.text + } else { + palette.muted + }, + palette, + { + let entity = entity.clone(); + move |window, cx| { + popover.update(cx, |state, cx| state.dismiss(window, cx)); + entity.update(cx, |yumush, cx| { + yumush.set_presence(presence, window, cx) + }); + } + }, + ) + })) + }) +} + fn menu_row( id: impl Into, label: impl Into, @@ -771,12 +858,6 @@ fn menu_row( .child(label.into()) } -fn drill_row(row: Stateful
) -> AnyElement { - row.child(div().flex_1()) - .child(menu_icon(IconName::ChevronRight)) - .into_any_element() -} - impl Yumush { fn open_removal( &self, @@ -791,7 +872,7 @@ impl Yumush { input_dialog( removal.title(), removal.title(), - "Reason (optional)", + w().profile.reason_optional, window, cx, move |this, text, window, cx| { diff --git a/crates/client/src/gui/settings_page.rs b/crates/client/src/gui/settings_page.rs index 8bbcd04..49c357b 100644 --- a/crates/client/src/gui/settings_page.rs +++ b/crates/client/src/gui/settings_page.rs @@ -1,3 +1,4 @@ +use crate::lang::{self, Label as _, Lang, w}; use std::future::Future; use crate::net::Fail; @@ -22,7 +23,7 @@ use super::{ chat::DeleteStep, chat::View, clickable, notify_error, parts, primary_button, - share_view::{AudioMode, CODECS, FPS, RESOLUTIONS, share_modes}, + share_view::{AudioMode, FPS, RESOLUTIONS, codecs, share_modes}, text, widget::field, }; @@ -32,7 +33,12 @@ use crate::{ share::encode::capabilities, }; -pub(super) const SETTINGS: [&str; 4] = ["Profile", "Voice", "Camera & share", "Appearance"]; +pub(super) const SETTINGS_IDS: [&str; 4] = ["profile", "voice", "camera_share", "appearance"]; + +pub(super) fn settings_titles() -> [&'static str; 4] { + let w = &w().settings_page; + [w.profile, w.voice, w.camera_share, w.appearance] +} impl Yumush { pub(super) fn settings_page( @@ -46,7 +52,7 @@ impl Yumush { let presence_entity = entity.clone(); let logout_entity = entity.clone(); sections.push(Section( - SETTINGS[0], + settings_titles()[0], div() .flex() .flex_col() @@ -71,7 +77,7 @@ impl Yumush { palette, )) .child(titled( - "Identity", + w().settings_page.identity, palette, rows_column( palette, @@ -79,7 +85,7 @@ impl Yumush { text_row( Editable { id: "save_username_button", - label: "Name", + label: w().settings_page.name, input: &self.chat.username_input, current: &user.username, save: Yumush::save_username, @@ -91,7 +97,7 @@ impl Yumush { text_row( Editable { id: "save_status_button", - label: "Status", + label: w().settings_page.status, input: &self.chat.status_input, current: &user.status, save: Yumush::save_status, @@ -101,7 +107,7 @@ impl Yumush { cx, ), row( - "Presence", + w().settings_page.presence, parts::options( "presence", Presence::ALL.map(|presence| (presence, presence.label())), @@ -118,12 +124,12 @@ impl Yumush { ), )) .child(titled( - "Account", + w().settings_page.account, palette, rows_column( palette, vec![row( - "Log out", + w().settings_page.log_out, small_button( "logout_button", palette, @@ -133,7 +139,7 @@ impl Yumush { .update(cx, |yumush, cx| yumush.logout(window, cx)) }, ) - .child("Log out"), + .child(w().settings_page.log_out), )], ), )) @@ -141,14 +147,17 @@ impl Yumush { )); } sections.push(section( - SETTINGS[1], + settings_titles()[1], palette, self.voice_rows(entity, palette, cx), )); - sections.push(Section(SETTINGS[2], camera_share(self, entity, palette))); + sections.push(Section( + settings_titles()[2], + camera_share(self, entity, palette), + )); let mut appearance = vec![ row( - "Theme", + w().settings_page.theme, segmented( Theme::ALL.map(|choice| (choice, choice.label())), self.settings.theme, @@ -158,7 +167,7 @@ impl Yumush { ), ), row( - "Font size", + w().settings_page.font_size, segmented( FontSize::ALL.map(|size| (size, size.label())), self.settings.font_size, @@ -168,7 +177,17 @@ impl Yumush { ), ), row( - "Close to tray", + w().settings_page.language, + segmented( + Lang::ALL.map(|lang| (lang, lang.words().common.language)), + self.settings.language, + entity, + palette, + Yumush::set_language, + ), + ), + row( + w().settings_page.close_to_tray, super::parts::toggle( "close_to_tray_switch", self.settings.close_to_tray, @@ -187,16 +206,16 @@ impl Yumush { ]; if let Some(user) = self.user.as_ref() { appearance.push(row( - "Your hue", + w().settings_page.your_hue, hue_picker(Some(style::hue_of(user.id)), entity, palette), )); } - sections.push(section(SETTINGS[3], palette, appearance)); + sections.push(section(settings_titles()[3], palette, appearance)); if self.user.is_some() { sections.push(danger_section( palette, vec![row( - "Delete account", + w().settings_page.delete_account, delete_control( "delete_account_button", self.chat.delete_step, @@ -212,7 +231,7 @@ impl Yumush { "settings_scroll", entity, palette, - "Settings", + w().settings_page.title, sections, self.chat.section, ) @@ -332,6 +351,13 @@ impl Yumush { self.commit_settings(cx); } + pub(super) fn set_language(&mut self, language: Lang, cx: &mut Context) { + self.settings.language = language; + lang::set(language); + self.commit_settings(cx); + cx.refresh_windows(); + } + pub(super) fn commit_settings(&mut self, cx: &mut Context) { settings::save(&self.settings); self.network.set_voice_settings(&self.settings.voice); @@ -388,12 +414,12 @@ fn camera_share(yumush: &Yumush, entity: &Entity, palette: Palette) -> A .flex_col() .gap(px(space::XL)) .child(titled( - "Camera", + w().settings_page.camera, palette, rows_column(palette, camera_rows(yumush, entity, palette)), )) .child(titled( - "Screen share", + w().settings_page.screen_share, palette, rows_column(palette, screen_rows(yumush, entity, palette)), )) @@ -407,7 +433,7 @@ fn camera_rows(yumush: &Yumush, entity: &Entity, palette: Palette) -> Ve let (resolutions, fps) = share::options(&modes, top.resolution, max_height); vec![ row( - "Quality", + w().settings_page.quality, parts::options( "camera_quality", RESOLUTIONS @@ -419,7 +445,7 @@ fn camera_rows(yumush: &Yumush, entity: &Entity, palette: Palette) -> Ve ), ), row( - "Frame rate", + w().settings_page.frame_rate, parts::options( "camera_fps", FPS.into_iter().filter(|(value, _)| fps.contains(value)), @@ -441,7 +467,7 @@ fn screen_rows(yumush: &Yumush, entity: &Entity, palette: Palette) -> Ve let audio_entity = entity.clone(); vec![ row( - "Quality", + w().settings_page.quality, parts::options( "screen_quality", RESOLUTIONS @@ -453,7 +479,7 @@ fn screen_rows(yumush: &Yumush, entity: &Entity, palette: Palette) -> Ve ), ), row( - "Frame rate", + w().settings_page.frame_rate, parts::options( "screen_fps", FPS.into_iter().filter(|(value, _)| fps.contains(value)), @@ -463,10 +489,10 @@ fn screen_rows(yumush: &Yumush, entity: &Entity, palette: Palette) -> Ve ), ), row( - "Codec", + w().settings_page.codec, parts::options( "share_codec", - CODECS.into_iter().filter(|(codec, _)| match codec { + codecs().into_iter().filter(|(codec, _)| match codec { ShareCodec::Auto => true, ShareCodec::Only(codec) => capabilities().encode.contains(codec), }), @@ -476,7 +502,7 @@ fn screen_rows(yumush: &Yumush, entity: &Entity, palette: Palette) -> Ve ), ), row( - "Share audio", + w().settings_page.share_audio, parts::toggle( "share_audio_switch", audio_on, @@ -552,7 +578,7 @@ pub(super) fn header( clickable("settings_back_button", palette, move |window, cx| { entity.update(cx, |yumush, cx| yumush.show_view(View::Chat, window, cx)); }) - .tip("Back") + .tip(w().settings_page.back) .h(px(size::CONTROL_SM)) .px(px(space::SM)) .rounded(px(radius::MD)) @@ -645,7 +671,7 @@ pub(super) fn section(title: &'static str, palette: Palette, rows: Vec
) -> } pub(super) fn danger_section(palette: Palette, rows: Vec
) -> Section { - Section("Danger zone", rows_column(palette, rows)) + Section(w().settings_page.danger_zone, rows_column(palette, rows)) } fn titled(title: &'static str, palette: Palette, rows: impl IntoElement) -> Div { @@ -714,7 +740,7 @@ pub(super) fn text_row( .items_center() .rounded(px(radius::MD)) .font_weight(FontWeight::MEDIUM) - .child("Save"), + .child(w().settings_page.save), ) }), ) @@ -755,7 +781,7 @@ pub(super) fn picture_card(picture: Picture, entity: &Entity, palette: P .on_click(move |_, window, cx| { picture_entity.update(cx, |yumush, cx| upload(yumush, window, cx)); }) - .tip("Change picture") + .tip(w().settings_page.change_picture) .child(image), ) .child( @@ -794,7 +820,7 @@ pub(super) fn picture_card(picture: Picture, entity: &Entity, palette: P remove_entity.update(cx, |yumush, cx| remove(yumush, window, cx)); }, ) - .child("Remove") + .child(w().settings_page.remove) })) } @@ -832,7 +858,11 @@ pub(super) fn delete_control( .when(confirming, |this| { this.bg(palette.danger).text_color(palette.on_accent) }) - .child(if confirming { "Confirm" } else { "Delete" }) + .child(if confirming { + w().settings_page.confirm + } else { + w().settings_page.delete + }) } pub(super) fn row(label: &'static str, control: impl IntoElement) -> Div { diff --git a/crates/client/src/gui/share_view.rs b/crates/client/src/gui/share_view.rs index 6f50ea1..5336fa3 100644 --- a/crates/client/src/gui/share_view.rs +++ b/crates/client/src/gui/share_view.rs @@ -6,6 +6,7 @@ use std::{ use common::share::{Codec, Fps, Kind, Mode, Quality, Resolution, clamp, options}; +use crate::lang::w; use crate::share::Target; const FULL_VOLUME: f32 = 100.; @@ -81,12 +82,14 @@ pub(super) const RESOLUTIONS: [(Resolution, &str); 6] = [ ]; pub(super) const FPS: [(Fps, &str); 3] = [(Fps::F15, "15"), (Fps::F30, "30"), (Fps::F60, "60")]; -pub(super) const CODECS: [(ShareCodec, &str); 4] = [ - (ShareCodec::Auto, "Auto"), - (ShareCodec::Only(Codec::Av1), "AV1"), - (ShareCodec::Only(Codec::H265), "H265"), - (ShareCodec::Only(Codec::H264), "H264"), -]; +pub(super) fn codecs() -> [(ShareCodec, &'static str); 4] { + [ + (ShareCodec::Auto, w().share_view.auto), + (ShareCodec::Only(Codec::Av1), "AV1"), + (ShareCodec::Only(Codec::H265), "H265"), + (ShareCodec::Only(Codec::H264), "H264"), + ] +} #[derive(Clone, Copy, PartialEq, Eq)] pub(super) enum AudioMode { @@ -96,11 +99,13 @@ pub(super) enum AudioMode { } impl AudioMode { - const ALL: [(Self, &'static str); 3] = [ - (Self::Off, "Off"), - (Self::Everything, "All"), - (Self::App, "Pick"), - ]; + fn all() -> [(Self, &'static str); 3] { + [ + (Self::Off, w().share_view.off), + (Self::Everything, w().share_view.all), + (Self::App, w().share_view.pick), + ] + } fn of(audio: &ShareAudio) -> Self { match audio { @@ -194,7 +199,7 @@ impl Yumush { .rounded(px(radius::MD)) .child(div().flex_1().min_w_0().truncate().child(name.clone())) }); - dialog.title("Share").w(px(size::SHEET)).child( + dialog.title(w().share_view.share).w(px(size::SHEET)).child( div() .id("share_targets") .max_h(px(size::POPOVER)) @@ -556,12 +561,12 @@ impl Yumush { Kind::Screen => ( "screen_settings", "screen_settings_button", - "Screen settings", + w().share_view.screen_settings, ), Kind::Camera => ( "camera_settings", "camera_settings_button", - "Camera settings", + w().share_view.camera_settings, ), }; @@ -746,7 +751,7 @@ impl Yumush { .flex() .justify_center() .child(scrim(palette.tokens).child(parts::words( - "Esc to leave fullscreen", + w().share_view.esc_exit, parts::Text::Label, parts::Ink::Dim, palette.tokens, @@ -758,9 +763,9 @@ impl Yumush { fn viewer_pane(&self, viewer: &Viewer, entity: &Entity, palette: Palette) -> Div { let (fullscreen_icon, fullscreen_tip) = if viewer.fullscreen { - (IconName::Minimize, "Exit fullscreen") + (IconName::Minimize, w().share_view.exit_fullscreen) } else { - (IconName::Maximize, "Fullscreen") + (IconName::Maximize, w().share_view.fullscreen) }; let audio = viewer.kind == Kind::Screen; let t = palette.tokens; @@ -812,7 +817,7 @@ impl Yumush { parts::icon_button( "viewer_stats_button", IconName::ChartBar, - "Stream stats", + w().share_view.stream_stats, if viewer.stats { Tone::On } else { Tone::Idle }, t, move |_, cx| { @@ -865,7 +870,11 @@ impl Yumush { } else { IconName::Volume2 }, - if muted { "Unmute" } else { "Mute" }, + if muted { + w().share_view.unmute + } else { + w().share_view.mute + }, entity_action(entity, |yumush, window, cx| { yumush.toggle_share_mute(window, cx) }), @@ -887,7 +896,7 @@ impl Yumush { "share_close".to_string(), palette, IconName::X, - "Close", + w().share_view.close, entity_action(entity, |yumush, _, cx| yumush.close_viewer(cx)), )), ), @@ -903,7 +912,7 @@ fn settings_card(entity: &Entity, yumush: &Yumush, palette: Palette) -> Kind::Camera => card.child(camera_devices(entity, yumush, palette)), Kind::Screen => card .child(div().px(px(space::SM)).child(segmented( - AudioMode::ALL, + AudioMode::all(), AudioMode::of(&settings.audio), entity, palette, @@ -929,7 +938,7 @@ fn camera_devices(entity: &Entity, yumush: &Yumush, palette: Palette) -> return div() .px(px(space::SM)) .text_color(palette.muted) - .child("No camera"); + .child(w().share_view.no_camera); } div().flex().flex_col().gap(px(space::XXS)).children( yumush @@ -983,7 +992,7 @@ fn quality_toggle(entity: &Entity, yumush: &Yumush, palette: Palette) -> "{} · {} fps · {}", label(&RESOLUTIONS, top.resolution), label(&FPS, top.fps), - label(&CODECS, yumush.settings.share.codec), + label(&codecs(), yumush.settings.share.codec), ); let entity = entity.clone(); row_style(clickable("share_quality", palette, move |_, cx| { @@ -1014,7 +1023,7 @@ fn quality_rows(entity: &Entity, yumush: &Yumush, palette: Palette) -> [ let t = palette.tokens; [ super::parts::quick_row( - "Resolution", + w().share_view.resolution, segmented( RESOLUTIONS .into_iter() @@ -1038,9 +1047,9 @@ fn quality_rows(entity: &Entity, yumush: &Yumush, palette: Palette) -> [ t, ), super::parts::quick_row( - "Codec", + w().share_view.codec, segmented( - CODECS.into_iter().filter(|(codec, _)| match codec { + codecs().into_iter().filter(|(codec, _)| match codec { ShareCodec::Auto => true, ShareCodec::Only(codec) => capabilities().encode.contains(codec), }), @@ -1081,7 +1090,7 @@ fn audio_list(entity: &Entity, yumush: &Yumush, palette: Palette) -> Opt apps.into_iter() .map(|app| include_row(entity, settings, app, palette)), ); - field("Sound from", app_list(rows), palette).into_any_element() + field(w().share_view.sound_from, app_list(rows), palette).into_any_element() }) } audio => { @@ -1105,9 +1114,9 @@ fn pick_list( palette: Palette, ) -> Div { let groups = [ - (AudioKind::App, "Apps"), - (AudioKind::Output, "Outputs"), - (AudioKind::Input, "Inputs"), + (AudioKind::App, w().share_view.apps), + (AudioKind::Output, w().share_view.outputs), + (AudioKind::Input, w().share_view.inputs), ]; div() diff --git a/crates/client/src/gui/sidebar.rs b/crates/client/src/gui/sidebar.rs index 1c571a8..a7f9dc7 100644 --- a/crates/client/src/gui/sidebar.rs +++ b/crates/client/src/gui/sidebar.rs @@ -1,15 +1,17 @@ use super::text; +use crate::lang::w; use crate::marks::Mark; use common::model::Id; use common::{ - model::{Community, CommunityKind, Invitation, Role, Unread, User}, + model::{Community, CommunityKind, Invitation, Unread, User}, permission, share::Kind, validate::validate_community_name, }; use gpui_kit::{ - Anchor, AnimationExt, AnyElement, App, Context, Div, Entity, FontWeight, InteractiveElement, - IntoElement, ParentElement, StatefulInteractiveElement, Styled, Window, + Anchor, AnimationExt, AnyElement, App, Context, Div, Entity, FontWeight, Hsla, + InteractiveElement, IntoElement, ParentElement, PathBuilder, StatefulInteractiveElement, + Styled, Window, assets::IconName, component::{ Icon, @@ -40,30 +42,50 @@ fn slide() -> gpui_kit::Animation { impl Yumush { pub(super) fn sidebar(&self, entity: &Entity, palette: Palette) -> impl IntoElement { - let collapsed = self.chat.sidebar_collapsed; - let (from, to, id) = if collapsed { - (size::SIDEBAR, size::RAIL, "sidebar_collapsing") - } else { - (size::RAIL, size::SIDEBAR, "sidebar_expanding") - }; - let content = if collapsed { + let content = if self.chat.sidebar_collapsed && !self.sliding() { self.collapsed_sidebar(entity, palette).into_any_element() } else { self.expanded_sidebar(entity, palette) }; - let sidebar = div() - .h_full() - .flex_shrink_0() - .overflow_hidden() - .child(content); - match self.chat.sidebar_toggled { - Some(at) if at.elapsed() < SLIDE => sidebar - .with_animation(id, slide(), move |sidebar, delta| { - sidebar.w(px(from + (to - from) * delta)) + self.folding( + "sidebar", + div() + .h_full() + .flex_shrink_0() + .overflow_hidden() + .child(content), + |sidebar, f| sidebar.w(px(lerp(size::SIDEBAR, size::RAIL, f))), + ) + } + + pub(super) fn toggle_sidebar(&mut self) { + self.chat.sidebar_collapsed = !self.chat.sidebar_collapsed; + self.chat.sidebar_toggled = Some(std::time::Instant::now()); + } + + fn sliding(&self) -> bool { + self.chat + .sidebar_toggled + .is_some_and(|at| at.elapsed() < SLIDE) + } + + fn folding( + &self, + id: &'static str, + element: E, + style: impl Fn(E, f32) -> E + 'static, + ) -> AnyElement { + let collapsed = self.chat.sidebar_collapsed; + let fold = move |delta: f32| if collapsed { delta } else { 1. - delta }; + if self.sliding() { + element + .with_animation((id, collapsed as u64), slide(), move |element, delta| { + style(element, fold(delta)) }) - .into_any_element(), - _ => sidebar.w(px(to)).into_any_element(), + .into_any_element() + } else { + style(element, fold(1.)).into_any_element() } } @@ -71,6 +93,7 @@ impl Yumush { div() .h_full() .w(px(size::RAIL)) + .pl(px(RAIL_SHIFT)) .flex() .flex_col() .items_center() @@ -82,8 +105,11 @@ impl Yumush { .flex_col() .items_center() .gap(px(space::MD)) - .child(logo_mark(palette).size(px(size::CONTROL))) - .child(self.collapse_button(entity, palette)), + .child(self.logo_toggle( + entity, + palette, + logo_mark(palette).size(px(size::CONTROL)), + )), ) .child( div() @@ -118,52 +144,79 @@ impl Yumush { .h(px(size::CONTROL)) .flex() .items_center() - .gap(px(space::XXS)) + .gap(px(space::XS)) + .child(self.folding( + "logo", + div().relative().child(self.logo_toggle( + entity, + palette, + self.folding( + "logo_mark", + logo_mark(palette).when(towing(self.wordmark_flipped), |mark| { + mark.path(crate::logo::NEEDLE) + }), + |mark, f| mark.size(px(lerp(size::CHIP, size::CONTROL, f))), + ), + )), + |logo, f| { + logo.left(px( + f * (RAIL_CENTER - space::LG - size::CONTROL / 2. - space::XXS) + )) + .top(px(f * (space::MD + space::XXS - space::LG))) + }, + )) .child( - div() - .id("wordmark") - .flex_1() - .px(px(space::SM)) - .text_size(text(text::TITLE)) - .font_weight(FontWeight::SEMIBOLD) - .text_color(palette.text) - .cursor_pointer() - .on_click({ - let entity = entity.clone(); - move |_, _, cx| { - entity.update(cx, |yumush, cx| { - yumush.wordmark_flips += 1; - yumush.wordmark_flipped = Some(std::time::Instant::now()); - cx.notify(); - }) - } - }) - .flex() - .items_center() - .child(logo_mark(palette).mr(px(space::XXS))) - .child("yumu") - .child(wordmark_tail(self.wordmark_flips, self.wordmark_flipped)), + self.folding( + "wordmark_fold", + div() + .id("wordmark") + .flex_1() + .text_size(text(text::TITLE)) + .line_height(gpui_kit::relative(LEADING)) + .font_weight(FontWeight::SEMIBOLD) + .text_color(palette.text) + .cursor_pointer() + .on_click({ + let entity = entity.clone(); + move |_, window, cx| { + entity.update(cx, |yumush, cx| yumush.open_jump(window, cx)) + } + }) + .flex() + .items_center() + .child("yumu") + .child(wordmark_tail( + self.wordmark_flips, + self.wordmark_flipped, + palette, + )), + |word, f| { + word.relative() + .left(px(-space::XXL * f)) + .opacity((1. - 2. * f).max(0.)) + }, + ), ) - .child(self.collapse_button(entity, palette)) - .child(icon_button( - "new_community_button", - palette, - IconName::Plus, - "New community", - new_community(entity), - )) - .child(self.friends_button(entity, friends_alert, palette)), + .child(self.folding( + "friends_fold", + div().child(self.friends_button(entity, friends_alert, palette)), + fade, + )), ) .child( - div() - .id("sidebar_list") - .flex_1() - .min_h_0() - .overflow_y_scroll() - .flex() - .flex_col() - .gap(px(space::MD)) - .children(self.sections(entity, palette)), + self.folding( + "list_fold", + div() + .id("sidebar_list") + .flex_1() + .min_h_0() + .overflow_y_scroll() + .flex() + .flex_col() + .gap(px(space::MD)) + .children(self.sections(entity, palette)), + |list, f| fade(list, f).flex_1().min_h_0(), + ), ) .children(self.account_row(entity, palette)) .into_any_element() @@ -192,7 +245,7 @@ impl Yumush { let fold = entity.clone(); div() .id(format!("voice_chip_{community_id}")) - .tip("In call") + .tip(w().sidebar.in_call) .flex_1() .flex() .items_center() @@ -361,7 +414,7 @@ impl Yumush { palette, go_to_call(entity, community), ) - .tip("Go to call") + .tip(w().sidebar.go_to_call) .size(px(size::CONTROL_SM)) .flex() .items_center() @@ -388,28 +441,46 @@ impl Yumush { self.select_community(community_id, window, cx); } - fn collapse_button(&self, entity: &Entity, palette: Palette) -> AnyElement { - let (icon, tip) = if self.chat.sidebar_collapsed { - (IconName::PanelLeftOpen, "Expand") + pub(super) fn new_community(&mut self, window: &mut Window, cx: &mut Context) { + input_dialog( + w().sidebar.new_community, + w().sidebar.create, + w().sidebar.name_placeholder, + window, + cx, + |this, name, window, cx| { + let name = name.trim().to_string(); + if validate_community_name(&name).is_ok() { + create_community(this, name, window, cx); + } + }, + ); + } + + fn logo_toggle( + &self, + entity: &Entity, + palette: Palette, + mark: impl IntoElement, + ) -> AnyElement { + let tip = if self.chat.sidebar_collapsed { + w().sidebar.expand } else { - (IconName::PanelLeftClose, "Collapse") + w().sidebar.collapse }; - - icon_button( - if self.chat.sidebar_collapsed { - "sidebar_expand" - } else { - "sidebar_collapse" - }, + clickable( + "sidebar_toggle", palette, - icon, - tip, entity_action(entity, |yumush, _, cx| { - yumush.chat.sidebar_collapsed = !yumush.chat.sidebar_collapsed; - yumush.chat.sidebar_toggled = Some(std::time::Instant::now()); + yumush.toggle_sidebar(); cx.notify(); }), ) + .tip(tip) + .flex_none() + .p(px(space::XXS)) + .rounded(px(radius::MD)) + .child(mark) .into_any_element() } @@ -421,8 +492,9 @@ impl Yumush { cx.notify(); } - pub(super) fn close_friends(&mut self, cx: &mut Context) { + pub(super) fn close_friends(&mut self, window: &mut Window, cx: &mut Context) { self.chat.friends_open = false; + window.focus(&self.focus, cx); cx.notify(); } @@ -477,7 +549,7 @@ impl Yumush { if open { yumush.open_friends(window, cx) } else { - yumush.close_friends(cx) + yumush.close_friends(window, cx) } }) }) @@ -531,14 +603,14 @@ impl Yumush { ) .on_click(move |_, window, cx| { open.update(cx, |yumush, cx| { - yumush.close_friends(cx); + yumush.close_friends(window, cx); yumush.open_direct(user_id, window, cx) }) }) .context_menu(move |menu, _, _| { menu_action( menu, - "Remove friend", + w().sidebar.remove_friend, &remove, user_id, |yumush, id, window, cx| yumush.remove_friend(id, window, cx), @@ -599,7 +671,7 @@ impl Yumush { palette, active, Some(notes_tile(palette)), - "Notes".to_string(), + w().sidebar.notes.to_string(), unread_badge(palette, false, unread), ), palette, @@ -747,7 +819,7 @@ impl Yumush { ) .collect(); - group("Requests", palette, rows) + group(w().sidebar.requests, palette, rows) } fn unread_first<'a>(&self, rooms: impl Iterator) -> Vec<&'a Community> { @@ -797,9 +869,9 @@ impl Yumush { user.id, palette, IconName::MessageSquare, - "Message", + w().sidebar.message, |yumush, id, window, cx| { - yumush.close_friends(cx); + yumush.close_friends(window, cx); yumush.open_direct(id, window, cx) }, )); @@ -873,7 +945,7 @@ impl Yumush { user.id, palette, IconName::Check, - "Accept", + w().sidebar.accept, |yumush, id, window, cx| yumush.accept_friend(id, window, cx), ), row_button( @@ -882,7 +954,7 @@ impl Yumush { user.id, palette, IconName::X, - "Decline", + w().sidebar.decline, |yumush, id, window, cx| yumush.remove_friend(id, window, cx), ), ], @@ -900,7 +972,7 @@ impl Yumush { user.id, palette, IconName::X, - "Cancel", + w().sidebar.cancel, |yumush, id, window, cx| yumush.remove_friend(id, window, cx), )], ) @@ -918,7 +990,7 @@ impl Yumush { div() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child(format!("from {}", invitation.inviter.username)), + .child(w().sidebar.from_user(&invitation.inviter.username)), ); entry( @@ -939,7 +1011,7 @@ impl Yumush { community.id, palette, IconName::Check, - "Accept", + w().sidebar.accept, |yumush, id, window, cx| yumush.accept_invitation(id, window, cx), ), row_button( @@ -948,7 +1020,7 @@ impl Yumush { community.id, palette, IconName::X, - "Decline", + w().sidebar.decline, |yumush, id, window, cx| yumush.decline_invitation(id, window, cx), ), ], @@ -965,28 +1037,23 @@ impl Yumush { .items_center() .gap(px(space::XS)) .child(self.account_trigger(entity, user, true, palette)) - .children(self.is_builder().then(|| { - let ghost = self.chat.ghost; - icon_button( - "builder_button".to_string(), - palette, - if ghost { - IconName::Ghost - } else { - IconName::Shield - }, - if ghost { - "Ghost on" - } else { - Role::Builder.label() - }, - entity_action(entity, |yumush, window, cx| { - yumush.show_view(View::Builder, window, cx) - }), + .children((self.is_builder() && self.chat.ghost).then(|| { + self.folding( + "builder_fold", + div().child( + icon_button( + "builder_button".to_string(), + palette, + IconName::Ghost, + w().sidebar.ghost_on, + entity_action(entity, |yumush, window, cx| { + yumush.show_view(View::Builder, window, cx) + }), + ) + .text_color(palette.tokens.hue(super::style::my_hue())), + ), + fade, ) - .when(ghost, |button| { - button.text_color(palette.tokens.hue(super::style::my_hue())) - }) })), ) } @@ -999,6 +1066,32 @@ impl Yumush { palette: Palette, ) -> impl IntoElement { let face = if named { size::AVATAR } else { size::CONTROL }; + let picture = avatar( + palette, + user, + px(face), + text(text::CAPTION), + &self.chat.avatars, + ); + let picture = if named { + self.folding("avatar_face", picture, |picture, f| { + picture.size(px(lerp(size::AVATAR, size::CONTROL, f))) + }) + } else { + picture.into_any_element() + }; + let picture = presence_avatar(picture, self.presence_of(user.id), px(face), palette); + let picture = if named { + self.folding("avatar", picture, |picture, f| { + picture + .left(px( + f * (RAIL_CENTER - space::LG - space::SM - size::CONTROL / 2.) + )) + .top(px(f * (space::LG - space::MD - space::XXS))) + }) + } else { + picture.into_any_element() + }; profile_popover( "account_profile", Anchor::BottomLeft, @@ -1014,25 +1107,18 @@ impl Yumush { .p(px(if named { 0. } else { space::XXS })) .when(named, |trigger| trigger.px(px(space::SM))) .rounded(px(radius::MD)) - .child(presence_avatar( - avatar( - palette, - user, - px(face), - text(text::CAPTION), - &self.chat.avatars, - ), - self.presence_of(user.id), - px(face), - palette, - )) + .child(picture) .when(named, |trigger| { trigger.child( - div() - .min_w_0() - .truncate() - .text_color(palette.muted) - .child(user.username.clone()), + self.folding( + "username_fold", + div() + .min_w_0() + .truncate() + .text_color(palette.muted) + .child(user.username.clone()), + fade, + ), ) }), palette, @@ -1075,9 +1161,9 @@ fn watch_pill( Kind::Screen => IconName::ScreenShare, }; let tip = match (watching, kind) { - (true, _) => "Stop watching", - (false, Kind::Camera) => "Watch camera", - (false, Kind::Screen) => "Watch screen", + (true, _) => w().sidebar.stop_watching, + (false, Kind::Camera) => w().sidebar.watch_camera, + (false, Kind::Screen) => w().sidebar.watch_screen, }; clickable( format!("voice_watch_{user_id}_{kind:?}"), @@ -1153,14 +1239,14 @@ fn room_menu( let menu = if group { let menu = menu_action( menu, - "Invite", + w().sidebar.invite, &entity, community_id, |yumush, id, window, cx| yumush.open_invite(id, window, cx), ); menu_action( menu, - "Settings", + w().sidebar.settings, &entity, community_id, |yumush, id, window, cx| yumush.open_community_settings(id, window, cx), @@ -1169,8 +1255,8 @@ fn room_menu( menu }; let menu = [ - (Mark::Pin, pinned, "Pin", "Unpin"), - (Mark::Mute, muted, "Mute", "Unmute"), + (Mark::Pin, pinned, w().sidebar.pin, w().sidebar.unpin), + (Mark::Mute, muted, w().sidebar.mute, w().sidebar.unmute), ] .into_iter() .fold(menu, |menu, (mark, on, set, unset)| { @@ -1186,7 +1272,7 @@ fn room_menu( } menu_action( menu, - "Leave", + w().sidebar.leave, &entity, community_id, |yumush, id, window, cx| yumush.leave_community(id, window, cx), @@ -1198,27 +1284,6 @@ fn matches_query(name: &str, query: &str) -> bool { name.to_lowercase().contains(query) } -fn new_community(entity: &Entity) -> impl Fn(&mut Window, &mut App) + 'static { - let entity = entity.clone(); - move |window, cx| { - entity.update(cx, |_, cx| { - input_dialog( - "New community", - "Create", - "Name...", - window, - cx, - |this, name, window, cx| { - let name = name.trim().to_string(); - if validate_community_name(&name).is_ok() { - create_community(this, name, window, cx); - } - }, - ); - }) - } -} - pub(super) fn input_box(input: &Entity, palette: Palette) -> Div { compact_frame(palette) .gap(px(space::SM)) @@ -1351,10 +1416,24 @@ enum Doing { Offline, } -const S_WIDTH: f32 = 0.5; -const CEDILLA_DROP: f32 = 0.45; -const H_SHRINK: f32 = 0.6; -const MORPH: std::time::Duration = std::time::Duration::from_millis(420); +const RAIL_SHIFT: f32 = space::LG; +const RAIL_CENTER: f32 = (size::RAIL + RAIL_SHIFT) / 2.; +const S_ADVANCE: f32 = 0.511; +const LEADING: f32 = 1.4; +const BASELINE: f32 = (LEADING - 0.97 - 0.305) / 2. + 0.97; +const MARK_VIEW: f32 = 76.; +const WANDER: std::time::Duration = std::time::Duration::from_secs(10); +const LINGER: std::time::Duration = std::time::Duration::from_secs(6); +const TOW: std::time::Duration = std::time::Duration::from_millis(2300); + +fn lerp(from: f32, to: f32, f: f32) -> f32 { + from + (to - from) * f +} + +fn fade(element: E, f: f32) -> E { + let shown = 1. - f; + element.opacity(shown) +} fn logo_mark(palette: Palette) -> gpui_kit::Svg { gpui_kit::svg() @@ -1364,50 +1443,128 @@ fn logo_mark(palette: Palette) -> gpui_kit::Svg { .text_color(palette.text) } -fn wordmark_tail(flips: u32, flipped: Option) -> AnyElement { - let em = super::style::text::TITLE / super::style::text::UI; +pub(super) fn wander(cx: &mut Context) { + cx.spawn(async move |this, cx| { + for wait in [WANDER, LINGER].into_iter().cycle() { + cx.background_executor().timer(wait).await; + let flipped = this.update(cx, |yumush, cx| { + yumush.wordmark_flips += 1; + yumush.wordmark_flipped = Some(std::time::Instant::now()); + cx.notify(); + }); + cx.background_executor().timer(TOW).await; + if flipped.is_err() || this.update(cx, |_, cx| cx.notify()).is_err() { + break; + } + } + }) + .detach(); +} + +fn towing(flipped: Option) -> bool { + flipped.is_some_and(|at| at.elapsed() < TOW) +} + +fn wordmark_tail(flips: u32, flipped: Option, palette: Palette) -> AnyElement { let turkish = flips % 2 == 1; - let progress = move |delta: f32| if turkish { delta } else { 1. - delta }; - let fade = |p: f32| 1. - p; - let s = move |p: f32| div().opacity(fade(p)).child("s"); - let cedilla = move |p: f32| div().absolute().top_0().left_0().opacity(p).child("ş"); - let h = move |p: f32| { - div() - .absolute() - .top(gpui_kit::rems(p * CEDILLA_DROP * em)) - .left(gpui_kit::rems(S_WIDTH * em * (1. - p))) - .text_size(gpui_kit::rems(em * (1. - H_SHRINK * p))) - .opacity(fade(p)) - .child("h") - }; - let tail = div().relative(); - if !flipped.is_some_and(|at| at.elapsed() < MORPH) { - let p = if turkish { 1. } else { 0. }; - return tail - .child(s(p)) - .child(cedilla(p)) - .child(h(p)) - .into_any_element(); + let em = super::style::text::TITLE / super::style::text::UI; + if !towing(flipped) { + return if turkish { + div().child("ş") + } else { + div().relative().child("s").child( + div() + .absolute() + .top_0() + .left(gpui_kit::rems(S_ADVANCE * em)) + .child("h"), + ) + } + .into_any_element(); } - let animation = || gpui_kit::Animation::new(MORPH).with_easing(gpui_kit::ease_in_out); - tail.child( - s(0.).with_animation(("wordmark_s", flips), animation(), move |el, delta| { - el.opacity(fade(progress(delta))) - }), - ) - .child(cedilla(0.).with_animation( - ("wordmark_cedilla", flips), - animation(), - move |el, delta| el.opacity(progress(delta)), - )) - .child( - h(0.).with_animation(("wordmark_h", flips), animation(), move |el, delta| { - let p = progress(delta); - el.top(gpui_kit::rems(p * CEDILLA_DROP * em)) - .left(gpui_kit::rems(S_WIDTH * em * (1. - p))) - .text_size(gpui_kit::rems(em * (1. - H_SHRINK * p))) - .opacity(fade(p)) - }), + let (ink, ground) = (palette.text, palette.panel); + div() + .relative() + .child("s") + .with_animation( + ("wordmark", flips), + gpui_kit::Animation::new(TOW), + move |tail, progress| { + tail.child( + tow_canvas(progress, turkish, ink, ground) + .absolute() + .top_0() + .left_0() + .size_full(), + ) + }, + ) + .into_any_element() +} + +fn tow_canvas(progress: f32, turkish: bool, ink: Hsla, ground: Hsla) -> gpui_kit::Canvas<()> { + gpui_kit::canvas( + |_, _, _| {}, + move |bounds, _, window, _| { + let em = + f32::from(window.rem_size()) * super::style::text::TITLE / super::style::text::UI; + let unit = em / 1000.; + let left = f32::from(bounds.origin.x) - super::tow::S_X * unit; + let baseline = f32::from(bounds.origin.y) + BASELINE * em; + let rig = super::tow::Rig { + x: -(size::CHIP + space::XXS + space::XS) / unit, + y: ((LEADING * em - size::CHIP) / 2. - BASELINE * em) / unit, + scale: size::CHIP / MARK_VIEW / unit, + }; + let scene = super::tow::scene(&rig, progress, turkish, progress * TOW.as_secs_f32()); + let at = |[x, y]: super::tow::Point| { + gpui_kit::point(px(left + x * unit), px(baseline + y * unit)) + }; + trace( + window, + scene.gap.iter().map(|p| at(*p)), + scene.halo * unit, + ground, + ); + trace( + window, + scene.thread.iter().map(|p| at(*p)), + scene.width * unit, + ink, + ); + let mut glyph = PathBuilder::fill(); + let mut points = scene.glyph.iter().map(|p| at(*p)); + if let Some(first) = points.next() { + glyph.move_to(first); + points.for_each(|point| glyph.line_to(point)); + glyph.close(); + if let Ok(glyph) = glyph.build() { + window.paint_path(glyph, ink); + } + } + }, ) - .into_any_element() +} + +fn trace( + window: &mut Window, + mut points: impl Iterator>, + width: f32, + color: Hsla, +) { + let Some(first) = points.next() else { + return; + }; + let mut path = + PathBuilder::fill().with_style(gpui_kit::PathStyle::Stroke(gpui_kit::StrokeOptions { + line_width: width, + line_cap: gpui_kit::LineCap::Round, + line_join: gpui_kit::LineJoin::Round, + ..Default::default() + })); + path.move_to(first); + points.for_each(|point| path.line_to(point)); + if let Ok(path) = path.build() { + window.paint_path(path, color); + } } diff --git a/crates/client/src/gui/snippet.rs b/crates/client/src/gui/snippet.rs index d15aaff..f99ed8e 100644 --- a/crates/client/src/gui/snippet.rs +++ b/crates/client/src/gui/snippet.rs @@ -1,5 +1,6 @@ use super::style::{size, space, text}; use crate::gui::CLOCK; +use crate::lang::w; use common::model::{Message, Role, SnippetMessage, User}; use gpui_kit::{ Entity, FontWeight, IntoElement, ParentElement, Styled, div, prelude::FluentBuilder as _, px, @@ -19,8 +20,8 @@ pub fn snippet_card( ) -> Option { let snippet = message.snippet.as_ref()?; let header = match &snippet.origin { - Some(origin) => format!("Forwarded · {origin}"), - None => "Forwarded".to_string(), + Some(origin) => w().snippet.forwarded_from(origin), + None => w().snippet.forwarded.to_string(), }; Some( diff --git a/crates/client/src/gui/social.rs b/crates/client/src/gui/social.rs index 1ea93d8..4b99d37 100644 --- a/crates/client/src/gui/social.rs +++ b/crates/client/src/gui/social.rs @@ -1,3 +1,4 @@ +use crate::lang::{Label as _, w}; use common::model::Id; use std::{fmt::Display, future::Future}; @@ -49,10 +50,10 @@ impl Relation { pub fn action(self) -> Option<(&'static str, IconName)> { match self { Relation::Myself => None, - Relation::Friend => Some(("Remove friend", IconName::UserX)), - Relation::Outgoing => Some(("Cancel request", IconName::X)), - Relation::Incoming => Some(("Accept friend", IconName::UserCheck)), - Relation::Stranger => Some(("Add friend", IconName::UserPlus)), + Relation::Friend => Some((w().social.remove_friend, IconName::UserX)), + Relation::Outgoing => Some((w().social.cancel_request, IconName::X)), + Relation::Incoming => Some((w().social.accept_friend, IconName::UserCheck)), + Relation::Stranger => Some((w().social.add_friend, IconName::UserPlus)), } } } @@ -307,7 +308,7 @@ impl Yumush { cx: &mut Context, ) { self.chat.invite = InviteLookup::Idle; - let input = new_input("Username...", window, cx); + let input = new_input(w().social.username_placeholder, window, cx); let enter_id = community_id; let lookup_id = community_id; @@ -329,7 +330,7 @@ impl Yumush { let palette = super::palette(cx); let result = invite_result(&yumush.chat.invite, community_id, &entity, yumush, palette); - dialog.title("Invite").child( + dialog.title(w().social.invite).child( div() .flex() .flex_col() @@ -431,7 +432,7 @@ fn invite_result( div() .text_size(text(super::style::text::LABEL)) .text_color(palette.muted) - .child("No such user") + .child(w().social.no_such_user) .into_any_element(), ), InviteLookup::Member(user) => Some( @@ -460,7 +461,7 @@ fn invite_result( .flex() .items_center() .rounded(px(radius::MD)) - .child("Invite"), + .child(w().social.invite), ) .into_any_element(), ) diff --git a/crates/client/src/gui/stream_stats.rs b/crates/client/src/gui/stream_stats.rs index eb58c95..6a5cca4 100644 --- a/crates/client/src/gui/stream_stats.rs +++ b/crates/client/src/gui/stream_stats.rs @@ -1,3 +1,4 @@ +use crate::lang::w; use common::{model::Id, share::Kind}; use gpui_kit::{Div, FontWeight, ParentElement, Styled, div, px}; @@ -79,7 +80,7 @@ pub(super) fn stream_card(yumush: &Yumush, user_id: Id, kind: Kind, palette: Pal )) .child(number( field(loss.map(|loss| format!("{loss:.1}"))), - "loss %", + w().stream_stats.loss, bad, t, )) @@ -89,7 +90,7 @@ pub(super) fn stream_card(yumush: &Yumush, user_id: Id, kind: Kind, palette: Pal .and_then(|stats| stats.latency_ms) .map(|ms| ms.to_string()), ), - "latency ms", + w().stream_stats.latency, false, t, )), @@ -104,8 +105,8 @@ pub(super) fn stream_card(yumush: &Yumush, user_id: Id, kind: Kind, palette: Pal stats .map(|stats| { [ - format!("buffer {} ms", stats.buffer_ms), - format!("keyframes {}", stats.keyframes), + w().stream_stats.buffer(stats.buffer_ms), + w().stream_stats.keyframes(stats.keyframes), format!("NACKs {}", stats.nacks), ] .map(|text| words(text, Text::Caption, Ink::Faint, t)) diff --git a/crates/client/src/gui/tow.rs b/crates/client/src/gui/tow.rs new file mode 100644 index 0000000..9943ad5 --- /dev/null +++ b/crates/client/src/gui/tow.rs @@ -0,0 +1,502 @@ +use std::f32::consts::PI; + +pub type Point = [f32; 2]; +type Segment = [Point; 4]; + +pub const S_X: f32 = 2615.; +const H_X: f32 = S_X + 511.; +const STEM: f32 = 105.; +const H_TOP: f32 = -707.; +const WORD_RIGHT: f32 = S_X + 480.; +const WORD_TOP: f32 = -540.; +const SAMPLES: usize = 60; +const CROSSING: f32 = 30.5; +const GAP: f32 = 5.3; +const HALO: f32 = 8.4; +const THREAD: f32 = 5.; + +pub struct Rig { + pub x: f32, + pub y: f32, + pub scale: f32, +} + +pub struct Scene { + pub thread: Vec, + pub gap: Vec, + pub glyph: Vec, + pub width: f32, + pub halo: f32, +} + +impl Rig { + fn mark(&self, x: f32, y: f32) -> Point { + [ + self.x + (x - 14.) * self.scale, + self.y + (y - 12.) * self.scale, + ] + } + + fn shaft(&self, along: f32, off: f32) -> Point { + let length = 48f32.hypot(60.); + let (dx, dy) = (48. / length, -60. / length); + self.mark(26. + dx * along - dy * off, 80. + dy * along + dx * off) + } + + fn strand(&self) -> [Segment; 2] { + [ + [ + self.mark(68., 28.), + self.mark(80., 40.), + self.mark(76., 56.), + self.mark(60., 58.), + ], + [ + self.mark(60., 58.), + self.mark(44., 60.), + self.mark(40., 74.), + self.mark(52., 84.), + ], + ] + } + + fn lift(&self) -> (Point, Point) { + let lift = self.shaft(92., -4.); + let bend = self.shaft(80., -20.); + (lift, add(lift, scale(sub(lift, bend), 1.5))) + } + + fn taut(&self, to: Point) -> Vec { + let (lift, lead) = self.lift(); + let corners = [[WORD_RIGHT + 33., WORD_TOP - 38.], [WORD_RIGHT + 33., 48.]]; + let word = [[0., WORD_TOP, WORD_RIGHT - 5., 10.]]; + let mut points = vec![lift]; + for corner in corners { + if hits(&word, *points.last().unwrap_or(&lift), to) { + points.push(corner); + } + } + points.push(to); + joined(lift, lead, &points) + } + + fn below(&self, to: Point) -> Vec { + let tail = self.strand()[1][3]; + let boxes = [[0., WORD_TOP, WORD_RIGHT, 30.], [20., 15., 580., 250.]]; + let mut points = vec![tail]; + for corner in [[20., 283.], [580., 283.], [WORD_RIGHT + 33., 63.]] { + if hits(&boxes, *points.last().unwrap_or(&tail), to) { + points.push(corner); + } + } + points.push(to); + joined(tail, add(tail, [120., 100.]), &points) + } +} + +pub fn scene(rig: &Rig, progress: f32, turkish: bool, time: f32) -> Scene { + let beat = Beat::new(progress); + let (thread, glyph, gap) = if turkish { + under(rig, &beat, time) + } else { + over(rig, &beat, time) + }; + Scene { + thread, + gap, + glyph, + width: THREAD * rig.scale, + halo: HALO * rig.scale, + } +} + +struct Beat { + out: f32, + back: f32, + slack: f32, + lift: f32, + settle: f32, + ahead: f32, + pulling: bool, + reaching: bool, +} + +impl Beat { + fn new(progress: f32) -> Self { + let v = ease(0., 1., progress); + let pull = clamp(0.32, 0.78, v); + Beat { + out: ease(0., 0.3, v), + back: ease(0.78, 1., v), + slack: ease(0., 0.18, pull), + lift: heave(0.18, 0.82, pull), + settle: clamp(0.82, 1., pull), + ahead: heave(0.18, 0.82, pull + 0.02).min(1.), + pulling: (0.32..0.78).contains(&v), + reaching: v < 0.32, + } + } + + fn amp(&self, grown: f32) -> f32 { + if self.pulling { + 45. * (1. - self.slack) + } else { + 80. * (PI * grown).sin() + } + } + + fn swing(&self, strength: f32) -> f32 { + strength * (self.settle * PI * 3.).sin() * (1. - self.settle) + } +} + +fn over(rig: &Rig, beat: &Beat, time: f32) -> (Vec, Vec, Vec) { + let top = [H_X + STEM, H_TOP]; + let grab = [S_X + 380., 140.]; + let load = |t: f32| cubic(&[grab, [H_X + 54., 150.], [H_X + STEM, -200.], top], t); + let bounce = 0.06 * (beat.settle * PI * 2.).sin() * (1. - beat.settle); + let t = if beat.reaching { + 0. + } else if beat.pulling { + if beat.settle > 0. { + 1. - bounce + } else { + beat.lift + } + } else { + 1. + }; + let anchor = load(t); + let speed = if beat.pulling { + (load(beat.ahead)[0] - anchor[0]) / 0.02 / 3000. + } else { + 0. + }; + let (curl, grown) = if beat.reaching { + (ease(0., 0.45, beat.out), ease(0.35, 1., beat.out)) + } else if beat.pulling { + (1., 1.) + } else { + ( + 1. - ease(0.55, 1., beat.back), + 1. - ease(0., 0.6, beat.back), + ) + }; + let [first, low] = rig.strand(); + let looped = [ + low[0], + rig.mark(52., 59.), + rig.shaft(26., -4.), + rig.shaft(32., -14.), + ]; + let low: Segment = std::array::from_fn(|i| mix(low[i], looped[i], curl)); + let (lift, _) = rig.lift(); + let wrap = [ + rig.shaft(32., -14.), + rig.shaft(40., -22.), + rig.shaft(80., -20.), + lift, + ]; + let mut segments = vec![first, low, wrap]; + segments.extend(rig.taut(anchor)); + let route = Route::new(&segments); + let tip = route.marks[1] + (route.end() - route.marks[1]) * grown; + let thread = route.wave(tip, beat.amp(grown), time, route.marks[2]); + let crossing = rig.shaft(CROSSING, 0.); + let gap = thread + .iter() + .copied() + .filter(|point| distance(*point, crossing) < GAP * rig.scale) + .collect(); + let glyph = shape( + [STEM, H_TOP], + anchor, + -speed * 0.6 + beat.swing(0.22), + 0.45 + 0.55 * beat.lift, + 1. - ease(0.1, 0.75, beat.lift), + ); + (thread, glyph, gap) +} + +fn under(rig: &Rig, beat: &Beat, time: f32) -> (Vec, Vec, Vec) { + let foot = [H_X + STEM, 0.]; + let grab = [S_X + 380., 140.]; + let drop = |t: f32| cubic(&[foot, [H_X + STEM, 130.], [S_X + 495., 170.], grab], t); + let t = if beat.reaching { + 0. + } else if beat.pulling { + beat.lift + } else { + 1. + }; + let anchor = drop(t); + let speed = if beat.pulling { + (drop(beat.ahead)[0] - anchor[0]) / 0.02 / 3000. + } else { + 0. + }; + let mut segments = rig.strand().to_vec(); + segments.extend(rig.below(anchor)); + let route = Route::new(&segments); + let rest = route.marks[1]; + let grown = if beat.reaching { + beat.out + } else if beat.pulling { + 1. + } else { + 1. - beat.back + }; + let thread = route.wave( + rest + (route.end() - rest) * grown, + beat.amp(grown), + time, + rest * 0.6, + ); + let lean = (-speed * 0.5).clamp(-0.35, 0.35) * (1. - beat.lift); + let glyph = shape( + [STEM, 0.], + anchor, + lean + beat.swing(0.15), + 1. - 0.55 * ease(0., 0.7, beat.lift), + ease(0.25, 0.9, beat.lift), + ); + (thread, glyph, Vec::new()) +} + +fn shape(local: Point, at: Point, turn: f32, size: f32, melt: f32) -> Vec { + let (sin, cos) = turn.sin_cos(); + H.chunks(2) + .zip(CEDILLA.chunks(2)) + .map(|(h, c)| { + let x = (h[0] - local[0]) * size; + let y = (h[1] - local[1]) * size; + let placed = [at[0] + x * cos - y * sin, at[1] + x * sin + y * cos]; + mix(placed, [c[0] + S_X, c[1]], melt) + }) + .collect() +} + +struct Route { + points: Vec, + lengths: Vec, + marks: Vec, +} + +impl Route { + fn new(segments: &[Segment]) -> Self { + let mut points = vec![segments[0][0]]; + let mut lengths = vec![0.]; + let mut marks = Vec::new(); + for segment in segments { + for step in 1..=SAMPLES { + let point = cubic(segment, step as f32 / SAMPLES as f32); + let last = lengths.last().copied().unwrap_or(0.); + lengths.push(last + distance(*points.last().unwrap_or(&point), point)); + points.push(point); + } + marks.push(lengths.last().copied().unwrap_or(0.)); + } + Route { + points, + lengths, + marks, + } + } + + fn end(&self) -> f32 { + self.lengths.last().copied().unwrap_or(0.) + } + + fn at(&self, length: f32) -> Point { + let i = self + .lengths + .iter() + .position(|&l| l >= length) + .unwrap_or(self.lengths.len() - 1) + .max(1); + let span = self.lengths[i] - self.lengths[i - 1]; + let f = if span > 0. { + ((length - self.lengths[i - 1]) / span).clamp(0., 1.) + } else { + 0. + }; + mix(self.points[i - 1], self.points[i], f) + } + + fn wave(&self, to: f32, amp: f32, time: f32, calm: f32) -> Vec { + let push = |length: f32| { + let point = self.at(length); + let [dx, dy] = sub(self.at(length + 20.), self.at(length - 20.)); + let norm = dx.hypot(dy).max(f32::EPSILON); + let envelope = smooth(calm, calm + 500., length) * smooth(0., 600., to - length); + let w = amp * envelope * (length / 700. * 2. * PI - time * 9.).sin(); + [point[0] - dy / norm * w, point[1] + dx / norm * w] + }; + self.lengths + .iter() + .copied() + .take_while(|&length| length < to) + .chain(std::iter::once(to)) + .map(push) + .collect() + } +} + +fn joined(start: Point, lead: Point, points: &[Point]) -> Vec { + let first = [start, lead, mix(start, points[1], 2. / 3.), points[1]]; + std::iter::once(first) + .chain(points[1..].windows(2).map(|pair| line(pair[0], pair[1]))) + .collect() +} + +fn hits(boxes: &[[f32; 4]], from: Point, to: Point) -> bool { + (1..60).any(|step| { + let [x, y] = mix(from, to, step as f32 / 60.); + boxes + .iter() + .any(|b| x > b[0] && y > b[1] && x < b[2] && y < b[3]) + }) +} + +fn line(a: Point, b: Point) -> Segment { + [a, mix(a, b, 1. / 3.), mix(a, b, 2. / 3.), b] +} + +fn cubic(segment: &Segment, t: f32) -> Point { + let u = 1. - t; + let weights = [u * u * u, 3. * u * u * t, 3. * u * t * t, t * t * t]; + segment + .iter() + .zip(weights) + .fold([0., 0.], |sum, (point, weight)| { + add(sum, scale(*point, weight)) + }) +} + +fn mix(a: Point, b: Point, f: f32) -> Point { + add(a, scale(sub(b, a), f)) +} + +fn add(a: Point, b: Point) -> Point { + [a[0] + b[0], a[1] + b[1]] +} + +fn sub(a: Point, b: Point) -> Point { + [a[0] - b[0], a[1] - b[1]] +} + +fn scale(a: Point, f: f32) -> Point { + [a[0] * f, a[1] * f] +} + +fn distance(a: Point, b: Point) -> f32 { + (a[0] - b[0]).hypot(a[1] - b[1]) +} + +fn clamp(from: f32, to: f32, x: f32) -> f32 { + ((x - from) / (to - from)).clamp(0., 1.) +} + +fn ease(from: f32, to: f32, x: f32) -> f32 { + let v = clamp(from, to, x); + if v < 0.5 { + 2. * v * v + } else { + 1. - (2. - 2. * v).powi(2) / 2. + } +} + +fn smooth(from: f32, to: f32, x: f32) -> f32 { + let v = clamp(from, to, x); + v * v * (3. - 2. * v) +} + +fn heave(from: f32, to: f32, x: f32) -> f32 { + let v = clamp(from, to, x); + if v < 0.6 { + v * v * v / 0.216 * 0.6 + } else { + 1. - (1. - v).powi(2) / 0.16 * 0.4 + } +} + +const H: [f32; 480] = [ + 59.0, -0.0, 59.0, -13.1, 59.0, -26.2, 59.0, -39.3, 59.0, -52.4, 59.0, -65.5, 59.0, -78.6, 59.0, + -91.7, 59.0, -104.8, 59.0, -117.9, 59.0, -131.0, 59.0, -144.1, 59.0, -157.2, 59.0, -170.3, + 59.0, -183.4, 59.0, -196.5, 59.0, -209.6, 59.0, -222.7, 59.0, -235.8, 59.0, -248.9, 59.0, + -262.0, 59.0, -275.1, 59.0, -288.2, 59.0, -301.3, 59.0, -314.4, 59.0, -327.5, 59.0, -340.6, + 59.0, -353.7, 59.0, -366.8, 59.0, -379.9, 59.0, -393.0, 59.0, -406.1, 59.0, -419.2, 59.0, + -432.3, 59.0, -445.4, 59.0, -458.5, 59.0, -471.6, 59.0, -484.7, 59.0, -497.8, 59.0, -510.9, + 59.0, -524.1, 59.0, -537.2, 59.0, -550.3, 59.0, -563.4, 59.0, -576.5, 59.0, -589.6, 59.0, + -602.7, 59.0, -615.8, 59.0, -628.9, 59.0, -642.0, 59.0, -655.1, 59.0, -668.2, 59.0, -681.3, + 59.0, -694.4, 59.5, -707.0, 72.6, -707.0, 85.7, -707.0, 98.8, -707.0, 111.9, -707.0, 125.0, + -707.0, 138.1, -707.0, 151.2, -707.0, 164.3, -707.0, 177.4, -707.0, 181.0, -697.5, 181.0, + -684.4, 181.0, -671.3, 181.0, -658.2, 181.0, -645.1, 181.0, -632.0, 181.0, -618.9, 181.0, + -605.8, 181.0, -592.7, 181.0, -579.6, 181.0, -566.5, 181.0, -553.4, 181.0, -540.3, 181.0, + -527.2, 181.0, -514.1, 181.0, -501.0, 181.0, -487.9, 181.0, -474.8, 181.0, -461.7, 187.6, + -467.0, 196.5, -476.6, 206.1, -485.5, 216.3, -493.8, 227.1, -501.2, 238.4, -507.8, 250.1, + -513.8, 262.1, -518.9, 274.4, -523.4, 287.0, -527.0, 299.8, -529.9, 312.7, -532.2, 325.7, + -533.8, 338.8, -534.8, 351.9, -534.9, 364.9, -534.5, 378.0, -533.4, 391.0, -531.7, 403.9, + -529.4, 416.6, -526.2, 429.0, -522.2, 441.1, -517.0, 452.6, -510.9, 463.6, -503.7, 473.8, + -495.5, 483.4, -486.6, 492.2, -476.9, 500.3, -466.6, 507.5, -455.7, 513.9, -444.3, 519.5, + -432.4, 524.3, -420.2, 528.3, -407.8, 531.8, -395.2, 534.8, -382.4, 537.4, -369.6, 539.4, + -356.6, 541.1, -343.6, 542.3, -330.6, 543.2, -317.5, 543.8, -304.4, 544.0, -291.3, 544.0, + -278.2, 544.0, -265.1, 544.0, -252.0, 544.0, -238.9, 544.0, -225.8, 544.0, -212.7, 544.0, + -199.6, 544.0, -186.5, 544.0, -173.4, 544.0, -160.3, 544.0, -147.2, 544.0, -134.1, 544.0, + -121.0, 544.0, -107.9, 544.0, -94.8, 544.0, -81.7, 544.0, -68.6, 544.0, -55.5, 544.0, -42.4, + 544.0, -29.3, 544.0, -16.2, 544.0, -3.1, 534.0, -0.0, 520.9, -0.0, 507.8, -0.0, 494.7, -0.0, + 481.6, -0.0, 468.5, -0.0, 455.4, -0.0, 442.3, -0.0, 429.2, -0.0, 422.0, -5.9, 422.0, -19.0, + 422.0, -32.1, 422.0, -45.2, 422.0, -58.3, 422.0, -71.4, 422.0, -84.5, 422.0, -97.6, 422.0, + -110.7, 422.0, -123.8, 422.0, -136.9, 422.0, -150.0, 422.0, -163.1, 422.0, -176.2, 422.0, + -189.3, 422.0, -202.4, 422.0, -215.5, 422.0, -228.6, 422.0, -241.7, 422.0, -254.8, 422.0, + -267.9, 421.8, -281.0, 421.1, -294.1, 420.0, -307.2, 418.5, -320.2, 416.4, -333.1, 413.5, + -345.9, 409.5, -358.3, 404.5, -370.4, 398.2, -381.9, 390.4, -392.4, 381.1, -401.7, 370.7, + -409.6, 359.2, -415.8, 346.9, -420.3, 334.1, -423.1, 321.1, -424.5, 308.0, -425.0, 294.9, + -424.3, 282.0, -422.5, 269.3, -419.4, 257.0, -414.6, 245.6, -408.4, 234.9, -400.8, 225.3, + -391.9, 216.8, -381.9, 209.5, -371.0, 203.4, -359.5, 198.0, -347.5, 193.5, -335.2, 189.7, + -322.7, 186.7, -309.9, 184.3, -297.1, 182.6, -284.1, 181.4, -271.0, 181.0, -257.9, 181.0, + -244.8, 181.0, -231.7, 181.0, -218.6, 181.0, -205.5, 181.0, -192.4, 181.0, -179.3, 181.0, + -166.2, 181.0, -153.1, 181.0, -140.0, 181.0, -126.9, 181.0, -113.8, 181.0, -100.7, 181.0, + -87.6, 181.0, -74.5, 181.0, -61.4, 181.0, -48.3, 181.0, -35.2, 181.0, -22.1, 181.0, -9.0, + 176.9, -0.0, 163.8, -0.0, 150.7, -0.0, 137.6, -0.0, 124.5, -0.0, 111.4, -0.0, 98.3, -0.0, 85.2, + -0.0, 72.1, -0.0, +]; + +const CEDILLA: [f32; 480] = [ + 289.3, 130.0, 287.0, 126.2, 284.0, 122.9, 280.5, 120.0, 276.8, 117.6, 272.8, 115.5, 268.7, + 113.8, 264.4, 112.4, 260.1, 111.4, 255.7, 110.6, 251.2, 109.9, 246.8, 109.4, 242.3, 109.1, + 237.8, 109.0, 233.4, 109.1, 228.9, 109.3, 224.4, 109.6, 220.0, 110.0, 215.5, 110.6, 211.1, + 111.2, 206.7, 111.9, 202.2, 112.7, 197.9, 113.6, 193.5, 114.6, 189.2, 115.7, 184.9, 117.0, + 182.4, 116.6, 183.5, 112.3, 184.6, 107.9, 185.7, 103.6, 186.8, 99.3, 188.0, 94.9, 189.1, 90.6, + 190.2, 86.3, 191.3, 81.9, 192.5, 77.6, 193.6, 73.2, 194.7, 68.9, 195.8, 64.6, 196.9, 60.2, + 198.1, 55.9, 199.2, 51.6, 200.3, 47.2, 201.4, 42.9, 202.6, 38.6, 203.7, 34.2, 204.8, 29.9, + 205.9, 25.6, 207.0, 21.2, 208.2, 16.9, 209.3, 12.5, 210.4, 8.2, 211.5, 3.9, 212.7, -0.5, 213.8, + -4.8, 214.9, -9.1, 216.0, -13.5, 217.1, -17.8, 218.3, -22.1, 220.5, -25.0, 225.0, -25.0, 229.5, + -25.0, 234.0, -25.0, 238.4, -25.0, 242.9, -25.0, 247.4, -25.0, 251.9, -25.0, 256.4, -25.0, + 260.8, -25.0, 265.3, -25.0, 269.8, -25.0, 274.3, -25.0, 278.8, -25.0, 283.2, -25.0, 287.7, + -25.0, 292.2, -25.0, 296.7, -25.0, 301.0, -24.9, 300.0, -20.5, 298.9, -16.1, 297.9, -11.8, + 296.9, -7.4, 295.9, -3.0, 294.9, 1.3, 293.9, 5.7, 292.8, 10.0, 291.8, 14.4, 290.8, 18.8, 289.8, + 23.1, 288.8, 27.5, 287.8, 31.8, 286.7, 36.2, 285.7, 40.6, 284.7, 44.9, 285.3, 47.8, 289.8, + 47.3, 294.2, 47.0, 298.7, 47.1, 303.2, 47.4, 307.6, 48.1, 312.1, 48.5, 316.5, 49.0, 320.9, + 49.7, 325.3, 50.6, 329.6, 51.8, 333.9, 53.1, 338.1, 54.7, 342.2, 56.5, 346.2, 58.5, 350.0, + 60.8, 353.8, 63.2, 357.3, 66.0, 360.7, 68.9, 364.0, 72.0, 366.9, 75.3, 369.8, 78.8, 372.2, + 82.5, 374.6, 86.3, 376.6, 90.3, 378.4, 94.4, 380.0, 98.6, 381.4, 102.9, 382.6, 107.2, 383.5, + 111.6, 384.3, 116.0, 384.9, 120.4, 385.4, 124.9, 385.7, 129.3, 385.9, 133.8, 386.0, 138.3, + 385.9, 142.7, 385.7, 147.2, 385.4, 151.7, 384.9, 156.1, 384.3, 160.6, 383.6, 165.0, 382.7, + 169.4, 381.6, 173.7, 380.4, 178.0, 379.0, 182.3, 377.4, 186.5, 375.6, 190.6, 373.6, 194.6, + 371.5, 198.5, 369.1, 202.3, 366.6, 206.0, 363.9, 209.6, 361.1, 213.1, 358.1, 216.4, 355.0, + 219.6, 351.8, 222.8, 348.4, 225.7, 345.0, 228.6, 341.4, 231.3, 337.8, 233.9, 334.0, 236.3, + 330.2, 238.6, 326.2, 240.8, 322.3, 242.8, 318.2, 244.7, 314.1, 246.5, 309.9, 248.2, 305.7, + 249.7, 301.5, 251.2, 297.3, 252.6, 293.0, 253.9, 288.7, 255.1, 284.3, 256.3, 280.0, 257.2, + 275.6, 258.2, 271.2, 259.0, 266.8, 259.8, 262.3, 260.5, 257.9, 261.1, 253.5, 261.5, 249.0, + 262.0, 244.5, 262.2, 240.1, 262.4, 235.6, 262.5, 231.1, 262.6, 226.6, 262.7, 222.1, 262.7, + 217.7, 262.6, 213.2, 262.5, 208.7, 262.4, 204.2, 262.2, 199.8, 261.9, 195.3, 261.6, 190.8, + 261.2, 186.4, 260.7, 181.9, 260.2, 180.0, 257.5, 180.0, 253.0, 180.0, 248.5, 180.0, 244.0, + 180.0, 239.5, 180.0, 235.1, 180.0, 230.6, 180.0, 226.1, 180.0, 221.6, 180.0, 217.2, 180.0, + 212.7, 180.0, 208.2, 180.0, 203.7, 180.0, 199.2, 180.0, 194.8, 180.0, 190.3, 181.2, 187.1, + 185.7, 187.5, 190.1, 187.8, 194.6, 188.1, 199.1, 188.3, 203.5, 188.4, 208.0, 188.5, 212.5, + 188.6, 217.0, 188.6, 221.5, 188.5, 225.9, 188.4, 230.4, 188.1, 234.9, 187.7, 239.3, 187.2, + 243.7, 186.5, 248.2, 185.8, 252.5, 184.8, 256.9, 183.7, 261.1, 182.3, 265.3, 180.7, 269.4, + 178.8, 273.2, 176.5, 276.9, 174.0, 280.3, 171.1, 283.4, 167.9, 286.2, 164.3, 288.4, 160.5, + 290.0, 156.3, 291.1, 152.0, 291.8, 147.5, 292.0, 143.1, 291.7, 138.6, 290.9, 134.2, +]; diff --git a/crates/client/src/gui/voice_note.rs b/crates/client/src/gui/voice_note.rs index b131a59..f65981f 100644 --- a/crates/client/src/gui/voice_note.rs +++ b/crates/client/src/gui/voice_note.rs @@ -4,6 +4,7 @@ use std::{ time::{Duration, Instant}, }; +use crate::lang::w; use common::call::CreateMessage; use common::constant::VOICE_SAMPLE_RATE; use gpui_kit::{ @@ -136,7 +137,7 @@ pub fn recording_row( clickable("cancel_voice_note", palette, move |_, cx| { cancel.update(cx, |yumush, cx| yumush.cancel_voice_note(cx)) }) - .tip("Cancel") + .tip(w().voice_note.cancel) .size(px(size::CONTROL_SM)) .flex() .items_center() @@ -165,7 +166,7 @@ pub fn recording_row( primary_button("send_voice_note", palette, move |window, cx| { send.update(cx, |yumush, cx| yumush.send_voice_note(window, cx)) }) - .tip("Send") + .tip(w().voice_note.send) .size(px(size::CONTROL_SM)) .flex() .items_center() @@ -181,7 +182,7 @@ pub fn mic_button(entity: &Entity, palette: Palette) -> impl IntoElement clickable("voice_note_button", palette, move |window, cx| { entity.update(cx, |yumush, cx| yumush.start_voice_note(window, cx)) }) - .tip("Voice message") + .tip(w().voice_note.voice_message) .size(px(size::CONTROL_SM)) .flex() .items_center() @@ -194,7 +195,7 @@ pub fn mic_button(entity: &Entity, palette: Palette) -> impl IntoElement impl Yumush { fn start_voice_note(&mut self, window: &mut Window, cx: &mut Context) { if !matches!(self.chat.voice_state, VoiceState::Off) { - window.push_notification(Notification::error("Leave voice call first"), cx); + window.push_notification(Notification::error(w().voice_note.leave_call_first), cx); return; } let (producer, consumer) = RingBuffer::new(RING_SAMPLES); diff --git a/crates/client/src/gui/voice_settings.rs b/crates/client/src/gui/voice_settings.rs index b35ca4a..58708b6 100644 --- a/crates/client/src/gui/voice_settings.rs +++ b/crates/client/src/gui/voice_settings.rs @@ -22,16 +22,25 @@ use super::{ style::{radius, size, space}, }; use crate::{ + lang::w, settings::{Activation, Profile, SENSITIVITY_DB, VOLUME, VoiceSettings}, voice::audio::{self, Device, Devices}, }; const LEVEL_INTERVAL: Duration = Duration::from_millis(50); -const MODES: [(Activation, &str); 2] = [ - (Activation::VoiceActivity, "Voice activity"), - (Activation::PushToTalk, "Push to talk"), -]; -const PROFILES: [(Profile, &str); 2] = [(Profile::Voice, "Voice"), (Profile::Music, "Music")]; +fn modes() -> [(Activation, &'static str); 2] { + [ + (Activation::VoiceActivity, w().voice_settings.voice_activity), + (Activation::PushToTalk, w().voice_settings.push_to_talk), + ] +} + +fn profiles() -> [(Profile, &'static str); 2] { + [ + (Profile::Voice, w().voice_settings.voice), + (Profile::Music, w().voice_settings.music), + ] +} #[derive(Clone, Copy, PartialEq, Eq)] pub(super) enum Side { @@ -62,7 +71,7 @@ impl DeviceItem { fn default_choice() -> Self { Self { id: None, - name: "Default".into(), + name: w().voice_settings.default.into(), } } } @@ -229,7 +238,7 @@ impl Yumush { let mut rows = vec![ row( - "Input device", + w().voice_settings.input_device, div().child( Select::new(&controls.inputs) .appearance(false) @@ -237,7 +246,7 @@ impl Yumush { ), ), row( - "Output device", + w().voice_settings.output_device, div().child( Select::new(&controls.outputs) .appearance(false) @@ -245,17 +254,17 @@ impl Yumush { ), ), row( - "Input volume", + w().voice_settings.input_volume, volume_control(&controls.input_volume, voice.input_volume, palette), ), row( - "Output volume", + w().voice_settings.output_volume, volume_control(&controls.output_volume, voice.output_volume, palette), ), row( - "Mode", + w().voice_settings.mode, segmented( - MODES, + modes(), voice.activation, entity, palette, @@ -263,9 +272,9 @@ impl Yumush { ), ), row( - "Profile", + w().voice_settings.profile, segmented( - PROFILES, + profiles(), voice.profile, entity, palette, @@ -274,13 +283,17 @@ impl Yumush { ), ]; - rows.push(row("Test", self.test_control(entity, palette))); + rows.push(row( + w().voice_settings.test, + self.test_control(entity, palette), + )); match voice.activation { - Activation::VoiceActivity => { - rows.push(row("Sensitivity", self.sensitivity_control(palette))) - } + Activation::VoiceActivity => rows.push(row( + w().voice_settings.sensitivity, + self.sensitivity_control(palette), + )), Activation::PushToTalk => rows.push(row( - "Key", + w().voice_settings.key, self.key_control(&voice.push_to_talk_key, entity, palette, cx), )), } @@ -302,7 +315,11 @@ impl Yumush { mic.update(cx, |yumush, cx| yumush.toggle_mic_test(cx)); }) .child(Icon::new(IconName::Mic).size(px(size::ICON_SM))) - .child(if testing { "Stop" } else { "Hear yourself" }), + .child(if testing { + w().voice_settings.stop + } else { + w().voice_settings.hear_yourself + }), ) .child( test_button("speaker_test_button", palette, false, move |_, cx| { @@ -311,7 +328,7 @@ impl Yumush { }); }) .child(Icon::new(IconName::Volume2).size(px(size::ICON_SM))) - .child("Play sound"), + .child(w().voice_settings.play_sound), ) } @@ -345,10 +362,10 @@ impl Yumush { cx: &App, ) -> impl IntoElement { let content = match self.voice.key { - KeyCapture::Waiting => div().child("Press key").into_any_element(), + KeyCapture::Waiting => div().child(w().voice_settings.press_key).into_any_element(), KeyCapture::Idle => match Keystroke::parse_with_os(key, cx.platform_info().os) { Ok(stroke) if !key.is_empty() => Kbd::new(stroke).into_any_element(), - _ => div().child("Set key").into_any_element(), + _ => div().child(w().voice_settings.set_key).into_any_element(), }, }; let entity = entity.clone(); @@ -585,8 +602,16 @@ impl Yumush { cx: &App, ) -> impl IntoElement { let (id, button, tip) = match side { - Side::Input => ("mic_settings", "mic_settings_button", "Microphone"), - Side::Output => ("speaker_settings", "speaker_settings_button", "Speaker"), + Side::Input => ( + "mic_settings", + "mic_settings_button", + w().voice_settings.microphone, + ), + Side::Output => ( + "speaker_settings", + "speaker_settings_button", + w().voice_settings.speaker, + ), }; let refresh = entity.clone(); let content = entity.clone(); diff --git a/crates/client/src/gui/voice_stats.rs b/crates/client/src/gui/voice_stats.rs index f911066..2637d14 100644 --- a/crates/client/src/gui/voice_stats.rs +++ b/crates/client/src/gui/voice_stats.rs @@ -14,6 +14,7 @@ use super::{ parts::{Fill, Ink, Text, band, grow, spark, stack, track, words}, style::{Tokens, size, space}, }; +use crate::lang::w; use crate::media::decode::Engine; use crate::share::session::{LayerStats, WatchStats}; use crate::usage::Usage; @@ -68,9 +69,9 @@ impl Quality { fn word(self) -> &'static str { match self { - Self::Good => "good", - Self::Fair => "fair", - Self::Poor => "poor", + Self::Good => w().voice_stats.good, + Self::Fair => w().voice_stats.fair, + Self::Poor => w().voice_stats.poor, } } } @@ -191,7 +192,7 @@ fn connection(stats: &Stats, t: Tokens) -> Div { }); stack(space::MD) - .child(title("Connection", String::new(), word, t)) + .child(title(w().voice_stats.connection, String::new(), word, t)) .child( band(space::LG) .child(number( @@ -208,13 +209,13 @@ fn connection(stats: &Stats, t: Tokens) -> Div { )) .child(number( field(loss.map(|loss| format!("{loss:.1}"))), - "loss %", + w().voice_stats.loss, loss.is_some_and(|loss| loss > GOOD_LOSS), t, )) .child(number( field(latest.map(|sample| format!("{:.0}", sample.traffic.buffer_ms))), - "buffer ms", + w().voice_stats.buffer, false, t, )), @@ -249,16 +250,16 @@ fn traffic(stats: &Stats, t: Tokens) -> Div { let latest = |values: &[f32]| rate(values.last().copied().unwrap_or_default() as u32); stack(space::XS) - .child(title("Traffic", String::new(), None, t)) + .child(title(w().voice_stats.traffic, String::new(), None, t)) .child(line_row( - label("up", t), + label(w().voice_stats.up, t), line(&up, t.paper()), latest(&up), false, t, )) .child(line_row( - label("down", t), + label(w().voice_stats.down, t), line(&down, t.dim()), latest(&down), false, @@ -273,7 +274,7 @@ fn machine(usage: &Usage, t: Tokens) -> Div { let model = |name: &str| words(name.to_string(), Text::Caption, Ink::Faint, t).truncate(); stack(space::XS) - .child(title("This machine", String::new(), None, t)) + .child(title(w().voice_stats.this_machine, String::new(), None, t)) .child(model(&format!("{} · {}", usage.host, usage.os))) .child(model(&usage.cpu_model)) .child(line_row( @@ -286,10 +287,10 @@ fn machine(usage: &Usage, t: Tokens) -> Div { .children(usage.threads.map(|threads| { band(space::MD).children( [ - ("gui", threads.gui), - ("camera", threads.camera), - ("encode", threads.encode), - ("decode", threads.decode), + (w().voice_stats.thread_gui, threads.gui), + (w().voice_stats.thread_camera, threads.camera), + (w().voice_stats.thread_encode, threads.encode), + (w().voice_stats.thread_decode, threads.decode), ] .map(|(name, value)| { words(format!("{name} {value:.0} %"), Text::Caption, Ink::Faint, t) @@ -297,7 +298,7 @@ fn machine(usage: &Usage, t: Tokens) -> Div { ) })) .child(line_row( - label("memory", t), + label(w().voice_stats.memory, t), over( memory.own_mb as f32 / total_mb, memory.used_mb as f32 / total_mb, @@ -308,7 +309,7 @@ fn machine(usage: &Usage, t: Tokens) -> Div { )) .children(usage.storage.map(|storage| { line_row( - label("storage", t), + label(w().voice_stats.storage, t), track( Fill::Part(storage.used_mb as f32 / storage.total_mb.max(1) as f32), false, @@ -364,8 +365,8 @@ fn sending(sending: &[(Kind, LayerStats)], t: Tokens) -> Vec
{ let last = layers.last()?; let max = largest(layers.iter().map(|stats| stats.kbps)); let name = match kind { - Kind::Screen => "Sending screen", - Kind::Camera => "Sending camera", + Kind::Screen => w().voice_stats.sending_screen, + Kind::Camera => w().voice_stats.sending_camera, }; Some( stack(space::XS) @@ -424,8 +425,12 @@ fn watching( Some( stack(space::XS) .child(title( - "Watching", - format!("{count} {}", if count == 1 { "stream" } else { "streams" }), + w().voice_stats.watching, + if count == 1 { + w().voice_stats.streams_one(count) + } else { + w().voice_stats.streams_many(count) + }, None, t, )) @@ -459,7 +464,7 @@ fn watching( .child(words(detail, Text::Caption, Ink::Faint, t).flex_none()), ) .child(line_row( - label("rate", t), + label(w().voice_stats.rate, t), track(Fill::Part(stats.kbps as f32 / max), bad, t).into_any_element(), rate(stats.kbps), bad, @@ -469,16 +474,14 @@ fn watching( .child( band(space::MD) .child(words( - format!( - "latency {}", - latency.map_or("…".into(), |ms| format!("{ms} ms")) - ), + w().voice_stats + .latency(latency.map_or("…".into(), |ms| format!("{ms} ms"))), Text::Caption, Ink::Faint, t, )) .child(words( - format!("loss {loss:.1} %"), + w().voice_stats.loss_now(format!("{loss:.1}")), Text::Caption, if loss > GOOD_LOSS { Ink::Bad @@ -488,7 +491,7 @@ fn watching( t, )) .child(words( - format!("keyframes {keyframes}"), + w().voice_stats.keyframes(keyframes), Text::Caption, Ink::Faint, t, @@ -505,8 +508,8 @@ fn watching( pub(super) fn kind_word(kind: Kind) -> &'static str { match kind { - Kind::Camera => "camera", - Kind::Screen => "screen", + Kind::Camera => w().voice_stats.camera, + Kind::Screen => w().voice_stats.screen, } } @@ -531,8 +534,8 @@ pub fn rate(kbps: u32) -> String { pub(super) fn engine_label(engine: Engine) -> &'static str { match engine { - Engine::Hardware => "hardware", - Engine::Software => "software", + Engine::Hardware => w().voice_stats.hardware, + Engine::Software => w().voice_stats.software, } } diff --git a/crates/client/src/lang.rs b/crates/client/src/lang.rs new file mode 100644 index 0000000..34e2cbc --- /dev/null +++ b/crates/client/src/lang.rs @@ -0,0 +1,95 @@ +use std::sync::atomic::{AtomicU8, Ordering}; + +use common::{ + model::{Presence, Rank, ReportStatus, Role}, + string_enum, +}; + +include!(concat!(env!("OUT_DIR"), "/words.rs")); + +string_enum! { + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + Lang { + En => "en", + Tr => "tr", + } +} + +static CURRENT: AtomicU8 = AtomicU8::new(Lang::En as u8); + +impl Lang { + pub fn words(self) -> &'static Words { + match self { + Lang::En => &EN, + Lang::Tr => &TR, + } + } + + pub fn system() -> Self { + sys_locale::get_locale() + .and_then(|locale| Lang::parse(&locale.get(..2)?.to_lowercase())) + .unwrap_or(Lang::En) + } +} + +pub fn set(lang: Lang) { + CURRENT.store(lang as u8, Ordering::Relaxed); +} + +pub fn w() -> &'static Words { + let current = CURRENT.load(Ordering::Relaxed); + Lang::ALL + .into_iter() + .find(|lang| *lang as u8 == current) + .unwrap_or(Lang::En) + .words() +} + +pub trait Label { + fn label(self) -> &'static str; +} + +impl Label for Role { + fn label(self) -> &'static str { + let w = &w().common; + match self { + Role::User => w.role_user, + Role::Builder => w.role_builder, + } + } +} + +impl Label for Presence { + fn label(self) -> &'static str { + let w = &w().common; + match self { + Presence::Online => w.presence_online, + Presence::Busy => w.presence_busy, + Presence::Offline => w.presence_offline, + } + } +} + +impl Label for Rank { + fn label(self) -> &'static str { + let w = &w().common; + match self { + Rank::Member => w.rank_member, + Rank::Moderator => w.rank_moderator, + Rank::Admin => w.rank_admin, + Rank::Owner => w.rank_owner, + Rank::Builder => w.rank_builder, + } + } +} + +impl Label for ReportStatus { + fn label(self) -> &'static str { + let w = &w().common; + match self { + ReportStatus::Open => w.report_open, + ReportStatus::Resolved => w.report_resolved, + ReportStatus::Dismissed => w.report_dismissed, + } + } +} diff --git a/crates/client/src/lib.rs b/crates/client/src/lib.rs index 1da41a9..18a7d6a 100644 --- a/crates/client/src/lib.rs +++ b/crates/client/src/lib.rs @@ -8,6 +8,7 @@ pub mod avatar; pub mod embed; pub mod emoji; pub mod gui; +pub mod lang; pub mod logo; pub mod marks; pub mod media; diff --git a/crates/client/src/logo.rs b/crates/client/src/logo.rs index be2e763..bdd3354 100644 --- a/crates/client/src/logo.rs +++ b/crates/client/src/logo.rs @@ -3,11 +3,12 @@ use std::borrow::Cow; use gpui_kit::{AssetSource, SharedString, assets::AllAssets}; pub const PATH: &str = "yumush/logo.svg"; +pub const NEEDLE: &str = "yumush/needle.svg"; const WINDOW_ICON: u32 = 256; mod svg; -pub use svg::{NAME, icon, mark, rgba}; +pub use svg::{NAME, icon, mark, needle, rgba}; pub fn window_icon() -> std::sync::Arc { std::sync::Arc::new( @@ -54,6 +55,9 @@ impl AssetSource for Assets { if path == PATH { return Ok(Some(Cow::Owned(mark().into_bytes()))); } + if path == NEEDLE { + return Ok(Some(Cow::Owned(needle().into_bytes()))); + } AllAssets.load(path) } diff --git a/crates/client/src/logo/svg.rs b/crates/client/src/logo/svg.rs index a33dd68..92b9627 100644 --- a/crates/client/src/logo/svg.rs +++ b/crates/client/src/logo/svg.rs @@ -10,6 +10,10 @@ pub fn mark() -> String { svg("14 12 76 76", "", "#000", "#000") } +pub fn needle() -> String { + svg("14 12 76 76", "", "#000", "none") +} + pub fn icon() -> String { svg( "0 0 100 100", diff --git a/crates/client/src/main.rs b/crates/client/src/main.rs index 13de372..c51c74f 100644 --- a/crates/client/src/main.rs +++ b/crates/client/src/main.rs @@ -46,6 +46,7 @@ fn main() { tracing::warn!("desktop entry: {error}"); } let settings = settings::load(); + client::lang::set(settings.language); let (network_handle, network_event_receiver) = net::start(Server::load()); application() diff --git a/crates/client/src/media/mod.rs b/crates/client/src/media/mod.rs index 6ba6fb7..4147820 100644 --- a/crates/client/src/media/mod.rs +++ b/crates/client/src/media/mod.rs @@ -17,6 +17,7 @@ use ec_probe::{Reader, decoder::AudioDecoder}; use rtrb::RingBuffer; use tracing::warn; +use crate::lang::w; use crate::voice::{ Playback, audio::{self, Audio, Choice}, @@ -48,7 +49,7 @@ pub enum MediaError { impl fmt::Display for MediaError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - MediaError::Unsupported => write!(f, "no playable video or audio track"), + MediaError::Unsupported => write!(f, "{}", w().media_mod.no_track), MediaError::Io(error) => write!(f, "{error}"), MediaError::Decode(message) => write!(f, "{message}"), } diff --git a/crates/client/src/net/fail.rs b/crates/client/src/net/fail.rs index 973f454..b89d142 100644 --- a/crates/client/src/net/fail.rs +++ b/crates/client/src/net/fail.rs @@ -1,5 +1,7 @@ use common::{error::Error, frame::FrameError, transport::Close}; +use crate::lang::w; + const NO_APPLICATION_PROTOCOL: u64 = 0x100 + 120; const CRYPTO_ERRORS: std::ops::Range = 0x100..0x200; @@ -15,10 +17,10 @@ pub enum LinkError { impl std::fmt::Display for LinkError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::Unreachable => write!(f, "Server unreachable"), - Self::Tls => write!(f, "Certificate error"), - Self::Outdated => write!(f, "Client is outdated"), - Self::Reset => write!(f, "Connection lost"), + Self::Unreachable => write!(f, "{}", w().fail.unreachable), + Self::Tls => write!(f, "{}", w().fail.tls), + Self::Outdated => write!(f, "{}", w().fail.outdated), + Self::Reset => write!(f, "{}", w().fail.reset), Self::Closed(close) => write!(f, "{}", close.reason()), } } @@ -65,9 +67,9 @@ impl std::fmt::Display for Fail { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Server(error) => write!(f, "{error}"), - Self::Offline => write!(f, "Offline"), + Self::Offline => write!(f, "{}", w().fail.offline), Self::Link(error) => write!(f, "{error}"), - Self::Protocol => write!(f, "Protocol error"), + Self::Protocol => write!(f, "{}", w().fail.protocol), Self::Io(message) => write!(f, "{message}"), } } diff --git a/crates/client/src/settings.rs b/crates/client/src/settings.rs index efdcfb6..7a9cc05 100644 --- a/crates/client/src/settings.rs +++ b/crates/client/src/settings.rs @@ -14,6 +14,7 @@ use gpui_kit::{ use crate::{ gui::style::{Look, Theme}, + lang::{Lang, w}, read_config, share::{audio::AudioMode, encode::capabilities}, voice::audio::Choice, @@ -49,9 +50,9 @@ impl Global for Scale {} impl FontSize { pub fn label(self) -> &'static str { match self { - FontSize::Small => "Small", - FontSize::Medium => "Medium", - FontSize::Large => "Large", + FontSize::Small => w().settings.small, + FontSize::Medium => w().settings.medium, + FontSize::Large => w().settings.large, } } @@ -190,9 +191,12 @@ impl ShareSettings { pub struct Settings { pub theme: Theme, pub font_size: FontSize, + pub language: Lang, pub voice: VoiceSettings, pub share: ShareSettings, pub close_to_tray: bool, + pub jump_usage: BTreeMap, + pub last_chats: BTreeMap, } impl Default for Settings { @@ -200,9 +204,12 @@ impl Default for Settings { Self { theme: Theme::Gece, font_size: FontSize::Medium, + language: Lang::system(), voice: VoiceSettings::default(), share: ShareSettings::default(), close_to_tray: true, + jump_usage: BTreeMap::new(), + last_chats: BTreeMap::new(), } } } @@ -307,10 +314,31 @@ pub fn load() -> Settings { font_size: text("font_size") .and_then(|value| FontSize::parse(&value)) .unwrap_or(defaults.font_size), + language: text("language") + .and_then(|value| Lang::parse(&value)) + .unwrap_or(defaults.language), voice, share, close_to_tray: text("close_to_tray") .map_or(defaults.close_to_tray, |value| value != "false"), + jump_usage: text("jump.usage") + .map(|value| { + value + .split('\t') + .filter_map(|pair| pair.rsplit_once('=')) + .filter_map(|(place, count)| Some((place.to_string(), count.parse().ok()?))) + .collect() + }) + .unwrap_or_default(), + last_chats: text("last_chats") + .map(|value| { + value + .split(',') + .filter_map(|pair| pair.split_once('=')) + .filter_map(|(user, chat)| Some((user.parse().ok()?, chat.parse().ok()?))) + .collect() + }) + .unwrap_or_default(), } } @@ -330,6 +358,7 @@ pub fn save(settings: &Settings) { let content = [ line("theme", settings.theme.as_str()), line("font_size", settings.font_size.as_str()), + line("language", settings.language.as_str()), line("close_to_tray", settings.close_to_tray), line("voice.sensitivity", voice.sensitivity_db), line("voice.input_volume", voice.input_volume), @@ -380,6 +409,24 @@ pub fn save(settings: &Settings) { .join("\t"), ), line("share.volume", share.volume), + line( + "jump.usage", + settings + .jump_usage + .iter() + .map(|(place, count)| format!("{place}={count}")) + .collect::>() + .join("\t"), + ), + line( + "last_chats", + settings + .last_chats + .iter() + .map(|(user, chat)| format!("{user}={chat}")) + .collect::>() + .join(","), + ), ] .concat(); diff --git a/crates/client/src/share/audio_capture_windows.rs b/crates/client/src/share/audio_capture_windows.rs index a76ca8d..85194a6 100644 --- a/crates/client/src/share/audio_capture_windows.rs +++ b/crates/client/src/share/audio_capture_windows.rs @@ -15,6 +15,7 @@ use wasapi::{ }; use super::audio::{AudioApp, AudioKind, AudioMode, is_picked}; +use crate::lang::w; use crate::voice::audio::{Worker, supervise}; const STOP_CHECK: Duration = Duration::from_millis(100); @@ -130,10 +131,10 @@ fn run( .into_iter() .find(|app| is_picked((name, *pid), &app.name, app.pid)) .and_then(|app| app.pid) - .ok_or("share audio app is not running")?; + .ok_or(w().audio_capture_windows.app_not_running)?; AudioClient::new_application_loopback_client(target, true)? } - AudioMode::Device(_) => return Err("share audio device capture is not supported".into()), + AudioMode::Device(_) => return Err(w().audio_capture_windows.device_unsupported.into()), }; client.initialize_client( &wave_format(), diff --git a/crates/client/src/share/camera.rs b/crates/client/src/share/camera.rs index 26e7b7d..99a275d 100644 --- a/crates/client/src/share/camera.rs +++ b/crates/client/src/share/camera.rs @@ -8,6 +8,7 @@ use std::{ time::{Duration, Instant}, }; +use crate::lang::w; use common::share::{Mode, Quality, clamp}; use nokhwa::{ Buffer, Camera as Device, @@ -124,7 +125,7 @@ pub fn open(top: Quality, device: Option) -> Result { }); } if !available() { - return Err("Camera needs the Media Feature Pack".to_string()); + return Err(w().camera.needs_media_pack.to_string()); } let (negotiated_tx, negotiated_rx) = sync_channel::>(1); let (frames_tx, frames_rx) = sync_channel(FRAME_QUEUE); @@ -142,7 +143,7 @@ pub fn open(top: Quality, device: Option) -> Result { Ok(negotiated) => negotiated, Err(_) => { stop.store(true, Ordering::Relaxed); - return Err("Camera did not respond".to_string()); + return Err(w().camera.no_response.to_string()); } }; let (width, height, refresh, size, modes) = match negotiated { @@ -249,7 +250,7 @@ fn open_device(top: Quality, device: Option<&str>) -> Result<(Device, Vec tracing::warn!(%error, "camera open failed"), } } - Err("No camera found".to_string()) + Err(w().camera.not_found.to_string()) } fn run( diff --git a/crates/client/src/share/capture.rs b/crates/client/src/share/capture.rs index 50c70ca..8ed20c5 100644 --- a/crates/client/src/share/capture.rs +++ b/crates/client/src/share/capture.rs @@ -34,6 +34,8 @@ use spa::{ utils::{Choice, ChoiceEnum, ChoiceFlags, Direction, Fraction, Rectangle, SpaTypes}, }; +use crate::lang::w; + use super::{ fake, frame::{BYTES_PER_PIXEL, DEFAULT_REFRESH, FRAME_QUEUE, Frame, Gpu, Release, take_gpu_failed}, @@ -145,7 +147,7 @@ async fn pick( .map_err(text)? .response() .map_err(text)?; - let stream = streams.streams().first().ok_or("no screen stream")?; + let stream = streams.streams().first().ok_or(w().capture.no_stream)?; let node_id = stream.pipe_wire_node_id(); let fd = screencast .open_pipe_wire_remote(session, Default::default()) @@ -183,7 +185,7 @@ async fn launch( None => { stop.store(true, Ordering::Relaxed); let _ = thread.join(); - Err("screen capture did not start".into()) + Err(w().capture.did_not_start.into()) } } } diff --git a/crates/client/src/share/capture_windows.rs b/crates/client/src/share/capture_windows.rs index 7afb33a..72d5620 100644 --- a/crates/client/src/share/capture_windows.rs +++ b/crates/client/src/share/capture_windows.rs @@ -5,6 +5,8 @@ use std::{ use ec_hw::{D3d11Pool, RgbOrder}; +use crate::lang::w; + use windows_capture::{ capture::{CaptureControl, Context, GraphicsCaptureApiHandler}, frame::Frame as CaptureFrame, @@ -49,9 +51,9 @@ pub fn targets() -> Option> { .enumerate() .map(move |(index, monitor)| { let name = if count > 1 { - format!("Screen {}", index + 1) + w().capture_windows.screen_numbered(index + 1) } else { - "Screen".into() + w().capture_windows.screen.into() }; (Target::Screen(monitor.as_raw_hmonitor() as usize), name) }); @@ -86,7 +88,7 @@ pub async fn open(target: Option) -> Result { Some(Target::Window(handle)) => { let window = Window::from_raw_hwnd(handle as *mut std::ffi::c_void); if !window.is_valid() { - return Err("window is gone".into()); + return Err(w().capture_windows.window_gone.into()); } let width = u32::try_from(window.width().map_err(text)?).unwrap_or(1); let height = u32::try_from(window.height().map_err(text)?).unwrap_or(1); diff --git a/crates/client/src/share/session.rs b/crates/client/src/share/session.rs index 6c44101..b2caffd 100644 --- a/crates/client/src/share/session.rs +++ b/crates/client/src/share/session.rs @@ -37,6 +37,7 @@ use super::{ pacer::Pacer, reassembly::{Assembled, Nack, Reassembler}, }; +use crate::lang::w; use crate::media::{ self, decode::{Engine, VideoDecoder, lock}, @@ -229,7 +230,7 @@ impl Sharing { camera_device: Option, ) -> Result { if encode.is_empty() { - return Err("codec unavailable".into()); + return Err(w().session.codec_unavailable.into()); } let audio = audio.filter(|_| kind == Kind::Screen); warn_if_small(&connection); @@ -321,7 +322,7 @@ impl Sharing { audio: Option, ) -> Result { if encode.is_empty() { - return Err("codec unavailable".into()); + return Err(w().session.codec_unavailable.into()); } self.source.top = Self::clamp(top, &self.modes); self.source.encode = encode; diff --git a/crates/client/src/share/unsupported.rs b/crates/client/src/share/unsupported.rs index a753027..50b8e1e 100644 --- a/crates/client/src/share/unsupported.rs +++ b/crates/client/src/share/unsupported.rs @@ -1,12 +1,12 @@ use std::sync::mpsc::Receiver; +use crate::lang::w; + use super::{ audio::{AudioApp, AudioMode}, frame::Frame, }; -const UNSUPPORTED: &str = "screen share is not supported on this OS"; - pub mod capture { use super::*; @@ -22,7 +22,7 @@ pub mod capture { } pub async fn open(_: Option) -> Result { - Err(UNSUPPORTED.into()) + Err(w().unsupported.not_supported.into()) } } @@ -52,7 +52,7 @@ pub mod camera { } pub fn open(_: Quality, _: Option) -> Result { - Err(UNSUPPORTED.into()) + Err(w().unsupported.not_supported.into()) } pub fn list(_: Option<&str>) -> Vec { diff --git a/crates/client/src/tray.rs b/crates/client/src/tray.rs index 7b86a73..66a38de 100644 --- a/crates/client/src/tray.rs +++ b/crates/client/src/tray.rs @@ -1,3 +1,6 @@ +#[cfg(any(target_os = "linux", target_os = "windows"))] +use crate::lang::w; + pub const AVAILABLE: bool = cfg!(any(target_os = "linux", target_os = "windows")); #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -54,12 +57,7 @@ impl TrayState { fn tip(self) -> String { match self.badge() { Badge::None => crate::NAME.to_string(), - _ => format!( - "{} · {} unread · {} mentions", - crate::NAME, - self.messages, - self.mentions - ), + _ => w().tray.tip(self.mentions, self.messages, crate::NAME), } } } @@ -114,6 +112,7 @@ mod linux { use tracing::warn; use super::{Badge, ICON_SIZE, TrayAction, TrayHandle, TrayState, pixels}; + use crate::lang::w; pub fn start() -> (mpsc::UnboundedReceiver, TrayHandle) { let (sender, receiver) = mpsc::unbounded_channel(); @@ -198,7 +197,7 @@ mod linux { vec![ StandardItem { - label: "Show".to_string(), + label: w().tray.show.to_string(), activate: Box::new(|tray: &mut Self| { let _ = tray.sender.send(TrayAction::Show); }), @@ -206,7 +205,7 @@ mod linux { } .into(), StandardItem { - label: "Quit".to_string(), + label: w().tray.quit.to_string(), activate: Box::new(|tray: &mut Self| { let _ = tray.sender.send(TrayAction::Quit); }), @@ -238,6 +237,7 @@ mod windows { }; use super::{Badge, ICON_SIZE, TrayAction, TrayHandle, TrayState, pixels}; + use crate::lang::w; fn icon(badge: Badge) -> Option { let rgba = pixels(badge) @@ -248,8 +248,8 @@ mod windows { pub fn start() -> (mpsc::UnboundedReceiver, TrayHandle) { let (sender, receiver) = mpsc::unbounded_channel(); - let show = MenuItem::new("Show", true, None); - let quit = MenuItem::new("Quit", true, None); + let show = MenuItem::new(w().tray.show, true, None); + let quit = MenuItem::new(w().tray.quit, true, None); let menu = Menu::new(); if let Err(error) = menu.append_items(&[&show, &quit]) { warn!("tray menu: {error}"); diff --git a/crates/common/src/model.rs b/crates/common/src/model.rs index 3da84d4..ac03493 100644 --- a/crates/common/src/model.rs +++ b/crates/common/src/model.rs @@ -70,15 +70,6 @@ string_enum! { } } -impl Role { - pub fn label(self) -> &'static str { - match self { - Role::User => "User", - Role::Builder => "Builder", - } - } -} - string_enum! { #[derive(Debug, Clone, Copy, PartialEq, Eq, Encode, Decode)] Presence { @@ -88,16 +79,6 @@ string_enum! { } } -impl Presence { - pub fn label(self) -> &'static str { - match self { - Presence::Online => "Online", - Presence::Busy => "Busy", - Presence::Offline => "Offline", - } - } -} - string_enum! { #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Encode, Decode)] Rank { @@ -109,18 +90,6 @@ string_enum! { } } -impl Rank { - pub fn label(self) -> &'static str { - match self { - Rank::Member => "Member", - Rank::Moderator => "Moderator", - Rank::Admin => "Admin", - Rank::Owner => "Owner", - Rank::Builder => "Builder", - } - } -} - #[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] pub struct User { pub id: Id, @@ -384,16 +353,6 @@ string_enum! { } } -impl ReportStatus { - pub fn label(self) -> &'static str { - match self { - ReportStatus::Open => "Open", - ReportStatus::Resolved => "Resolved", - ReportStatus::Dismissed => "Dismissed", - } - } -} - #[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] pub struct Report { pub id: Id, diff --git a/crates/server/src/files.rs b/crates/server/src/files.rs index d94c964..f0c159b 100644 --- a/crates/server/src/files.rs +++ b/crates/server/src/files.rs @@ -423,11 +423,11 @@ mod tests { #[test] fn avatar_checks_jpeg_size() { - let small = check_avatar(&jpeg(AVATAR_SIZE / 2)); + let large = check_avatar(&jpeg(AVATAR_SIZE * 2)); let not_jpeg = check_avatar(b"not a jpeg"); assert!(matches!( - small, + large, Err(ServerError::Wire(CommonError::Invalid { field: Field::Avatar, .. @@ -441,6 +441,7 @@ mod tests { })) )); assert!(check_avatar(&jpeg(AVATAR_SIZE)).is_ok()); + assert!(check_avatar(&jpeg(AVATAR_SIZE / 2)).is_ok()); } #[tokio::test]