diff --git a/crates/iz-core/src/detail.rs b/crates/iz-core/src/detail.rs index b9580ea..8f6feb9 100644 --- a/crates/iz-core/src/detail.rs +++ b/crates/iz-core/src/detail.rs @@ -41,24 +41,6 @@ impl DependencyEdge { self.cleared_at.is_some() || self.done_at.is_some() } - /// The right-hand note on a `BLOCKED BY` row: `cleared Aug 16`, or what is - /// still in the way. - pub fn blocked_by_label(&self) -> String { - match (self.cleared_at, self.done_at) { - (Some(at), _) => format!("cleared {}", day_label(at.date())), - (None, Some(at)) => format!("done {}", day_label(at.date())), - (None, None) => "blocking this task".to_string(), - } - } - - /// The same note on a `BLOCKS` row. - pub fn blocks_label(&self) -> String { - if self.is_cleared() { - "no longer waiting".to_string() - } else { - "waiting on this task".to_string() - } - } } /// One file hung off a task, as the detail screen prints it. diff --git a/crates/iz-core/tests/store.rs b/crates/iz-core/tests/store.rs index b8dde0e..b870b24 100644 --- a/crates/iz-core/tests/store.rs +++ b/crates/iz-core/tests/store.rs @@ -1926,11 +1926,6 @@ async fn a_task_detail_carries_both_directions_of_its_dependencies() { assert_eq!(blocked_by, ["before"]); assert_eq!(blocks, ["after"]); assert!(detail.is_blocked()); - assert_eq!( - detail.blocked_by[0].blocked_by_label(), - "blocking this task" - ); - assert_eq!(detail.blocks[0].blocks_label(), "waiting on this task"); } #[tokio::test] diff --git a/crates/iz-web/src/detail.rs b/crates/iz-web/src/detail.rs index 7a7b1ef..4fcf789 100644 --- a/crates/iz-web/src/detail.rs +++ b/crates/iz-web/src/detail.rs @@ -1818,8 +1818,19 @@ async fn dep_row<'a>( ) -> Result { let cleared = edge.is_cleared(); let note = match direction { - Direction::BlockedBy => edge.blocked_by_label(), - Direction::Blocks => edge.blocks_label(), + Direction::BlockedBy => match (edge.cleared_at, edge.done_at) { + (Some(at), _) => crate::i18n::cleared_dep_label( + lang, + &iz_core::board::day_label(at.date()), + ), + (None, Some(at)) => crate::i18n::done_dep_label( + lang, + &iz_core::board::day_label(at.date()), + ), + (None, None) => t(lang, Key::BlocksThisTask).to_string(), + }, + Direction::Blocks if cleared => t(lang, Key::NoLongerWaiting).to_string(), + Direction::Blocks => t(lang, Key::WaitsOnThisTask).to_string(), }; let waiting = matches!(direction, Direction::BlockedBy) && !cleared; let wire = match direction { diff --git a/crates/iz-web/src/files.rs b/crates/iz-web/src/files.rs index 6f817b5..f945627 100644 --- a/crates/iz-web/src/files.rs +++ b/crates/iz-web/src/files.rs @@ -226,12 +226,13 @@ fn not_found() -> (StatusCode, HeaderMap, Vec) { } /// The 503 a stored attachment serves when the Files service cannot be -/// reached — one plain line, and never the 404, because the row exists. -fn service_unavailable() -> (StatusCode, HeaderMap, Vec) { +/// reached — one plain line in the reader's language, and never the 404, +/// because the row exists. +fn service_unavailable(lang: crate::i18n::Lang) -> (StatusCode, HeaderMap, Vec) { ( StatusCode::SERVICE_UNAVAILABLE, HeaderMap::new(), - b"the Files service is unreachable\n".to_vec(), + format!("{}\n", Refusal::StorageUnavailable.message_in(lang)).into_bytes(), ) } @@ -539,13 +540,13 @@ async fn download(cx: &Cx) -> topcoat::Result<(StatusCode, HeaderMap, Vec)> }, AttachmentWhere::Stored => { let Some((_, url)) = crate::storage::in_of(store.as_ref()).await else { - return Ok(service_unavailable()); + return Ok(service_unavailable(crate::i18n::Lang::from_code(&user.language))); }; match crate::storage::client(cx).fetch(&url, id).await { Ok(bytes) => bytes, Err(problem) => { eprintln!("storage fetch: {problem:?}"); - return Ok(service_unavailable()); + return Ok(service_unavailable(crate::i18n::Lang::from_code(&user.language))); } } } diff --git a/crates/iz-web/src/i18n.rs b/crates/iz-web/src/i18n.rs index 6faab75..dbb8693 100644 --- a/crates/iz-web/src/i18n.rs +++ b/crates/iz-web/src/i18n.rs @@ -99,6 +99,7 @@ pub enum Key { BlockedBy, Overdue, Blocked, + NoLongerWaiting, // Topbar nav / chrome shared by board.rs, rules.rs, logs.rs, settings.rs. NavBoard, @@ -208,6 +209,9 @@ pub enum Key { PublicAddressLabel, PublicAddressNote, SenderNotConfiguredYet, + ProblemUnreachable, + ProblemQuota, + Ago, // pages.rs @@ -522,6 +526,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (Overdue, Tr) => "gecikmiş", (Blocked, En) => "blocked", (Blocked, Tr) => "engelli", + (NoLongerWaiting, En) => "no longer waiting", + (NoLongerWaiting, Tr) => "artık beklemiyor", (NavBoard, En) => "Board", (NavBoard, Tr) => "Pano", @@ -738,6 +744,12 @@ pub fn t(lang: Lang, key: Key) -> &'static str { } (SenderNotConfiguredYet, En) => "No sender to test.", (SenderNotConfiguredYet, Tr) => "Test edilecek gönderen yok.", + (Ago, En) => "ago", + (Ago, Tr) => "önce", + (ProblemUnreachable, En) => "unreachable", + (ProblemUnreachable, Tr) => "erişilemiyor", + (ProblemQuota, En) => "quota", + (ProblemQuota, Tr) => "kota", (MailRules, En) => "Mail rules", (MailRules, Tr) => "Posta kuralları", @@ -1217,6 +1229,31 @@ pub fn unblocked_label(lang: Lang, detail: &str) -> String { } } +/// A dependency's note once it no longer holds: the day it went away. +pub fn cleared_dep_label(lang: Lang, day: &str) -> String { + match lang { + Lang::En => format!("cleared {day}"), + Lang::Tr => format!("{day} kalktı"), + } +} + +/// A dependency's note when the task in front of this one finished. +pub fn done_dep_label(lang: Lang, day: &str) -> String { + match lang { + Lang::En => format!("done {day}"), + Lang::Tr => format!("{day} tamamlandı"), + } +} + +/// A used amount against its total — a storage limit, a migration's +/// progress. Turkish writes the pair with a slash, not a word. +pub fn share_of_total(lang: Lang, used: &str, total: &str) -> String { + match lang { + Lang::En => format!("{used} of {total}"), + Lang::Tr => format!("{used} / {total}"), + } +} + pub fn role_changed_label(lang: Lang, detail: &str) -> String { match lang { Lang::En => format!("made {detail}"), diff --git a/crates/iz-web/src/settings.rs b/crates/iz-web/src/settings.rs index 9370f61..2eea19f 100644 --- a/crates/iz-web/src/settings.rs +++ b/crates/iz-web/src/settings.rs @@ -971,12 +971,12 @@ async fn connection_card<'a>(cx: &'a Cx, lang: Lang) -> Result { let event_line = if event_age.is_empty() { never.clone() } else { - format!("{event_age} ago") + format!("{} {}", event_age, t(lang, Key::Ago)) }; let pass_line = if pass_age.is_empty() { never } else { - format!("{pass_age} ago") + format!("{} {}", pass_age, t(lang, Key::Ago)) }; Ok(view! { cx => @@ -1031,20 +1031,28 @@ async fn storage_card<'a>( (t(lang, Key::StorageUnreachable), "connection-wait") }; let limit_line = match (snap.used, snap.quota) { - (Some(used), Some(quota)) => format!( - "{} of {}", - crate::storage::human_bytes(used), - crate::storage::human_bytes(quota) + (Some(used), Some(quota)) => crate::i18n::share_of_total( + lang, + &crate::storage::human_bytes(used), + &crate::storage::human_bytes(quota), ), _ => "—".to_string(), }; - let problem_line = match &snap.problem_word { - Some(word) => format!( - "{} ago · {}", + let problem_word = match snap.problem_word.as_deref() { + Some("unreachable") => t(lang, Key::ProblemUnreachable).to_string(), + Some("quota") => t(lang, Key::ProblemQuota).to_string(), + Some(other) => other.to_string(), + None => String::new(), + }; + let problem_line = if problem_word.is_empty() { + t(lang, Key::ConnectionNever).to_string() + } else { + format!( + "{} {} · {}", crate::directory::age_text(snap.problem_age), - word - ), - None => t(lang, Key::ConnectionNever).to_string(), + t(lang, Key::Ago), + problem_word + ) }; let migrating = snap.migrating; Ok(view! { @@ -1062,7 +1070,7 @@ async fn storage_card<'a>( if backend == StorageBackend::In && let Some((moved, total)) = migrating {
(t(lang, Key::StorageMigration))
- (format!("{moved} of {total}")) + (crate::i18n::share_of_total(lang, &moved.to_string(), &total.to_string()))