aboutsummaryrefslogtreecommitdiff
path: root/ui/src/format.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/format.rs')
-rw-r--r--ui/src/format.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/ui/src/format.rs b/ui/src/format.rs
index 01982af..4eb8f84 100644
--- a/ui/src/format.rs
+++ b/ui/src/format.rs
@@ -8,17 +8,16 @@ use jellycommon::{
jellyobject::{Object, Tag},
*,
};
-
-use crate::locale::tr;
-use std::fmt::Write;
+use jellyui_locale::tr;
+use std::{borrow::Cow, fmt::Write};
pub fn format_duration(d: f64) -> String {
- format_duration_mode(LANG_ENG.0, d, false)
+ format_duration_mode("en", d, false)
}
-pub fn format_duration_long(lang: Language, d: f64) -> String {
+pub fn format_duration_long(lang: &str, d: f64) -> String {
format_duration_mode(lang, d, true)
}
-fn format_duration_mode(lang: Language, mut d: f64, long_units: bool) -> String {
+fn format_duration_mode(lang: &str, mut d: f64, long_units: bool) -> String {
let mut s = String::new();
let sign = if d > 0. { "" } else { "-" };
d = d.abs();
@@ -58,15 +57,15 @@ fn test_duration_short() {
#[test]
fn test_duration_long() {
assert_eq!(
- format_duration_long(LANG_ENG.0, 61.).as_str(),
+ format_duration_long("en", 61.).as_str(),
"1 minute and 1 second"
);
assert_eq!(
- format_duration_long(LANG_ENG.0, 121.).as_str(),
+ format_duration_long("en", 121.).as_str(),
"2 minutes and 1 second"
);
assert_eq!(
- format_duration_long(LANG_ENG.0, 3661.).as_str(),
+ format_duration_long("en", 3661.).as_str(),
"1 hour, 1 minute and 1 second"
);
}
@@ -74,7 +73,7 @@ fn test_duration_long() {
pub fn format_size(size: u64) -> String {
humansize::format_size(size, humansize::DECIMAL)
}
-pub fn format_kind(lang: Language, kind: Tag) -> &'static str {
+pub fn format_kind(lang: &str, kind: Tag) -> Cow<'static, str> {
tr(
lang,
match kind {