aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes/ui/node.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-04-20 17:29:43 +0200
committermetamuffin <metamuffin@disroot.org>2025-04-20 17:29:43 +0200
commit457aeb41ef9c17215fcc7151b765a19785593096 (patch)
tree14c52ea28bddab43373559bf3901cd5c2f4742ed /server/src/routes/ui/node.rs
parent096b96f7b00188aa9eda864d53605c6fe73eb63c (diff)
downloadjellything-457aeb41ef9c17215fcc7151b765a19785593096.tar
jellything-457aeb41ef9c17215fcc7151b765a19785593096.tar.bz2
jellything-457aeb41ef9c17215fcc7151b765a19785593096.tar.zst
even more translation
Diffstat (limited to 'server/src/routes/ui/node.rs')
-rw-r--r--server/src/routes/ui/node.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs
index e94547c..e6f0605 100644
--- a/server/src/routes/ui/node.rs
+++ b/server/src/routes/ui/node.rs
@@ -9,7 +9,7 @@ use super::{
rocket_uri_macro_r_node_thumbnail,
},
error::MyResult,
- layout::{trs, trsa},
+ layout::trs,
sort::{filter_and_sort_nodes, NodeFilterSort, NodeFilterSortForm, SortOrder, SortProperty},
};
use crate::{
@@ -32,7 +32,7 @@ use crate::{
};
use anyhow::{anyhow, Result};
use chrono::DateTime;
-use jellybase::locale::Language;
+use jellybase::locale::{tr, Language};
use jellycommon::{
api::ApiNodeResponse,
user::{NodeUserData, WatchedState},
@@ -214,7 +214,7 @@ markup::define! {
ul.parents { @for (node, _) in *parents { li {
a.component[href=uri!(r_library_node(&node.slug))] { @node.title }
}}}
- @if node.media.is_some() {
+ @if node.media.is_some() {
a.play[href=&uri!(r_player(&node.slug, PlayerConfig::default()))] { @trs(lang, "node.player_link") }
}
@if !matches!(node.kind, NodeKind::Collection | NodeKind::Channel) {
@@ -373,7 +373,7 @@ markup::define! {
@match udata.watched {
WatchedState::None => {}
WatchedState::Pending => { p.pending { @trs(lang, "prop.watched.pending") } }
- WatchedState::Progress(x) => { p.progress { @trsa(lang, "prop.watched.progress", &[("time", &format_duration(x))]) } }
+ WatchedState::Progress(x) => { p.progress { @tr(**lang, "prop.watched.progress").replace("{time}", &format_duration(x)) } }
WatchedState::Watched => { p.watched { @trs(lang, "prop.watched.watched") } }
}
}
@@ -391,31 +391,31 @@ pub fn aspect_class(kind: NodeKind) -> &'static str {
}
pub fn format_duration(d: f64) -> String {
- format_duration_mode(d, false)
+ format_duration_mode(d, false, Language::English)
}
-pub fn format_duration_long(d: f64) -> String {
- format_duration_mode(d, true)
+pub fn format_duration_long(d: f64, lang: Language) -> String {
+ format_duration_mode(d, true, lang)
}
-fn format_duration_mode(mut d: f64, long_units: bool) -> String {
+fn format_duration_mode(mut d: f64, long_units: bool, lang: Language) -> String {
let mut s = String::new();
let sign = if d > 0. { "" } else { "-" };
d = d.abs();
- for (short, long, k) in [
- ("d", "day", 60. * 60. * 24.),
- ("h", "hour", 60. * 60.),
- ("m", "minute", 60.),
- ("s", "second", 1.),
+ for (short, long, long_pl, k) in [
+ ("d", "time.day", "time.days", 60. * 60. * 24.),
+ ("h", "time.hour", "time.hours", 60. * 60.),
+ ("m", "time.minute", "time.minutes", 60.),
+ ("s", "time.second", "time.seconds", 1.),
] {
let h = (d / k).floor();
d -= h * k;
if h > 0. {
if long_units {
+ let long = tr(lang, if h != 1. { long_pl } else { long });
// TODO breaks if seconds is zero
write!(
s,
- "{}{h} {long}{}{}",
+ "{}{h} {long}{}",
if k != 1. { "" } else { " and " },
- if h != 1. { "s" } else { "" },
if k > 60. { ", " } else { "" },
)
.unwrap();