forge
Explore
Log in

Don't you dare go Hollow

im-web: translate device-label fallback and 'on' connector (BrowserWord, device_summary)

Browse files at this commit

f465b366125fa96bfe6675072858e457ae2537edAhmet Kaan GümüşParent: 7ff5986
crates/im-web/src/i18n.rsmodified+14 -0
@@ -156,6 +156,7 @@ pub enum Key {
156156 ViewPhotoAria,
157157 ThisSessionChip,
158158 UnknownDevice,
159+ BrowserWord,
159160 DeviceLabel,
160161 AddressLabel,
161162 SignedInLabel,
@@ -552,6 +553,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
552553 (ThisSessionChip, Tr) => "Bu oturum",
553554 (UnknownDevice, En) => "Unknown device",
554555 (UnknownDevice, Tr) => "Bilinmeyen cihaz",
556+ (BrowserWord, En) => "Browser",
557+ (BrowserWord, Tr) => "Tarayıcı",
555558 (DeviceLabel, En) => "Device",
556559 (DeviceLabel, Tr) => "Cihaz",
557560 (AddressLabel, En) => "Address",
@@ -929,6 +932,17 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
929932 }
930933 }
931934
935+/// A session's device summary — "Chrome on Linux". The browser and system
936+/// names are proper nouns and stay as the agent spelled them; only the
937+/// connector between them follows the viewer's language, and Turkish reads
938+/// it as a location: "Linux üzerinde Chrome".
939+pub fn device_summary(lang: Lang, browser: &str, system: &str) -> String {
940+ match lang {
941+ Lang::En => format!("{browser} on {system}"),
942+ Lang::Tr => format!("{system} üzerinde {browser}"),
943+ }
944+}
945+
932946 /// A user row's "Sessions (N)" disclosure summary, in the viewer's language.
933947 pub fn sessions_summary(lang: Lang, n: usize) -> String {
934948 match lang {
crates/im-web/src/pages.rsmodified+5 -4
@@ -493,8 +493,9 @@ pub(crate) fn escape(raw: &str) -> String {
493493 /// header. The full string stays one click away in the session's detail.
494494 /// Substring matching in precedence order (Edge before Chrome before Safari:
495495 /// each carries the later one's token too); shared with the admin panel.
496-/// Browser and system names are proper nouns and stay untranslated; only the
497-/// unknown-device fallback follows the viewer's language.
496+/// Browser and system names are proper nouns and stay as the agent spelled
497+/// them; the connector and the generic fallback follow the viewer's language
498+/// (`i18n::device_summary`, `Key::BrowserWord`).
498499 pub(crate) fn device_label(agent: Option<&str>, lang: Lang) -> String {
499500 let Some(agent) = agent.filter(|agent| !agent.is_empty()) else {
500501 return t(lang, Key::UnknownDevice).to_string();
@@ -508,7 +509,7 @@ pub(crate) fn device_label(agent: Option<&str>, lang: Lang) -> String {
508509 } else if agent.contains("Safari/") {
509510 "Safari"
510511 } else {
511- "Browser"
512+ return t(lang, Key::BrowserWord).to_string();
512513 };
513514 let system = if agent.contains("iPhone") {
514515 "iPhone"
@@ -527,7 +528,7 @@ pub(crate) fn device_label(agent: Option<&str>, lang: Lang) -> String {
527528 } else {
528529 return browser.to_string();
529530 };
530- format!("{browser} on {system}")
531+ crate::i18n::device_summary(lang, browser, system)
531532 }
532533
533534 /// `2026-09-04 10:22`: the last-seen stamp. An unrenderable stamp falls back