i18n(rust): misc strings
cc
This commit is contained in:
5 files changed
+28
-23
No files matched your search
@@ -121,15 +121,15 @@ pub fn toggle_enabled(w: &AppWindow) {
|
||||
Ok(()) => {
|
||||
push(w);
|
||||
let msg = if new_state {
|
||||
"Blacklist enabled"
|
||||
qbz_i18n::t("Blacklist enabled")
|
||||
} else {
|
||||
"Blacklist disabled"
|
||||
qbz_i18n::t("Blacklist disabled")
|
||||
};
|
||||
crate::toast::info(w, msg);
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("[qbz-slint] blacklist toggle-enabled failed: {e}");
|
||||
crate::toast::error(w, "Failed to toggle blacklist");
|
||||
crate::toast::error(w, qbz_i18n::t("Failed to toggle blacklist"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,15 +141,15 @@ pub fn remove(w: &AppWindow, artist_id: i32) {
|
||||
.into_iter()
|
||||
.find(|a| a.artist_id == artist_id as u64)
|
||||
.map(|a| a.artist_name)
|
||||
.unwrap_or_else(|| "Artist".to_string());
|
||||
.unwrap_or_else(|| qbz_i18n::t("Artist"));
|
||||
match crate::artist_blacklist::remove(artist_id as u64) {
|
||||
Ok(()) => {
|
||||
push(w);
|
||||
crate::toast::success(w, format!("{name} removed from blacklist"));
|
||||
crate::toast::success(w, qbz_i18n::t_args("{} removed from blacklist", &[&name]));
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("[qbz-slint] blacklist remove failed: {e}");
|
||||
crate::toast::error(w, "Failed to remove artist");
|
||||
crate::toast::error(w, qbz_i18n::t("Failed to remove artist"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,11 +160,11 @@ pub fn clear_all(w: &AppWindow) {
|
||||
match crate::artist_blacklist::clear_all() {
|
||||
Ok(()) => {
|
||||
push(w);
|
||||
crate::toast::success(w, format!("Removed {count} artists from blacklist"));
|
||||
crate::toast::success(w, qbz_i18n::tf("Removed {} artist from blacklist", "Removed {} artists from blacklist", count as i64, &[&count.to_string()]));
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("[qbz-slint] blacklist clear-all failed: {e}");
|
||||
crate::toast::error(w, "Failed to clear blacklist");
|
||||
crate::toast::error(w, qbz_i18n::t("Failed to clear blacklist"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,28 +167,28 @@ async fn download_and_open(url: &str) -> Result<(PathBuf, u32), String> {
|
||||
.get(url)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to fetch booklet: {e}"))?;
|
||||
.map_err(|e| qbz_i18n::t_args("Failed to fetch booklet: {}", &[&e.to_string()]))?;
|
||||
if !response.status().is_success() {
|
||||
return Err(format!("HTTP {}", response.status()));
|
||||
}
|
||||
let bytes = response
|
||||
.bytes()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to read booklet: {e}"))?;
|
||||
.map_err(|e| qbz_i18n::t_args("Failed to read booklet: {}", &[&e.to_string()]))?;
|
||||
|
||||
let temp_dir = booklet_temp_dir();
|
||||
tokio::fs::create_dir_all(&temp_dir)
|
||||
.await
|
||||
.map_err(|e| format!("Failed to create temp dir: {e}"))?;
|
||||
.map_err(|e| qbz_i18n::t_args("Failed to create temp dir: {}", &[&e.to_string()]))?;
|
||||
let path = temp_dir.join(format!("{}.pdf", uuid::Uuid::new_v4()));
|
||||
tokio::fs::write(&path, &bytes)
|
||||
.await
|
||||
.map_err(|e| format!("Failed to write booklet: {e}"))?;
|
||||
.map_err(|e| qbz_i18n::t_args("Failed to write booklet: {}", &[&e.to_string()]))?;
|
||||
|
||||
let info_path = path.clone();
|
||||
let info = tokio::task::spawn_blocking(move || qbz_booklet::open_info(&info_path))
|
||||
.await
|
||||
.map_err(|e| format!("Booklet open task failed: {e}"))??;
|
||||
.map_err(|e| qbz_i18n::t_args("Booklet open task failed: {}", &[&e.to_string()]))??;
|
||||
Ok((path, info.num_pages))
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ fn render_page_rgba(
|
||||
) -> Result<(Vec<u8>, u32, u32), String> {
|
||||
let rendered = qbz_booklet::render_page_png(path, page, dpi, rotation)?;
|
||||
let rgba = image::load_from_memory(&rendered.png)
|
||||
.map_err(|e| format!("Failed to decode booklet page: {e}"))?
|
||||
.map_err(|e| qbz_i18n::t_args("Failed to decode booklet page: {}", &[&e.to_string()]))?
|
||||
.to_rgba8();
|
||||
let (width, height) = rgba.dimensions();
|
||||
Ok((rgba.into_raw(), width, height))
|
||||
|
||||
@@ -104,9 +104,9 @@ fn album_duration(secs: u32) -> String {
|
||||
let hours = secs / 3600;
|
||||
let minutes = (secs % 3600) / 60;
|
||||
if hours > 0 {
|
||||
format!("{hours}h {minutes}m")
|
||||
qbz_i18n::t_args("{} h {} min", &[&hours.to_string(), &minutes.to_string()])
|
||||
} else {
|
||||
format!("{minutes}m")
|
||||
qbz_i18n::t_args("{} min", &[&minutes.to_string()])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ fn map_album_credits(album: Album) -> AlbumCreditsData {
|
||||
// so an absent duration shows "· 0m" rather than dropping it.
|
||||
let parts = vec![
|
||||
g.name.clone(),
|
||||
format!("{track_count} tracks"),
|
||||
qbz_i18n::tf("{} track", "{} tracks", track_count as i64, &[&track_count.to_string()]),
|
||||
album_duration(album.duration.unwrap_or(0)),
|
||||
];
|
||||
parts.join(" · ")
|
||||
@@ -280,7 +280,7 @@ fn map_album_credits(album: Album) -> AlbumCreditsData {
|
||||
.roles
|
||||
.first()
|
||||
.cloned()
|
||||
.unwrap_or_else(|| "Performer".to_string()),
|
||||
.unwrap_or_else(|| qbz_i18n::t("Performer")),
|
||||
name: p.name,
|
||||
})
|
||||
.collect();
|
||||
@@ -297,7 +297,7 @@ fn map_album_credits(album: Album) -> AlbumCreditsData {
|
||||
.filter(|n| !n.is_empty())
|
||||
.unwrap_or_else(|| {
|
||||
if album_artist.is_empty() {
|
||||
"Unknown Artist".to_string()
|
||||
qbz_i18n::t("Unknown Artist")
|
||||
} else {
|
||||
album_artist.clone()
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ pub fn copy_current_lyrics(weak: &slint::Weak<AppWindow>) {
|
||||
return;
|
||||
}
|
||||
crate::share::copy_to_clipboard(text);
|
||||
crate::toast::success_weak(weak, "Lyrics copied");
|
||||
crate::toast::success_weak(weak, qbz_i18n::t("Lyrics copied"));
|
||||
}
|
||||
|
||||
/// Refresh the Settings cache row from the REAL per-user lyrics.db (F1
|
||||
@@ -231,12 +231,12 @@ pub fn clear_cache(handle: &tokio::runtime::Handle, weak: slint::Weak<AppWindow>
|
||||
handle.spawn(async move {
|
||||
match service.clear_cache().await {
|
||||
Ok(()) => {
|
||||
crate::toast::success_weak(&weak, "Lyrics cache cleared");
|
||||
crate::toast::success_weak(&weak, qbz_i18n::t("Lyrics cache cleared"));
|
||||
refresh_cache_stats(&handle_for_refresh, weak);
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("[qbz-slint] lyrics cache clear failed: {e}");
|
||||
crate::toast::error_weak(&weak, "Failed to clear lyrics cache");
|
||||
crate::toast::error_weak(&weak, qbz_i18n::t("Failed to clear lyrics cache"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -300,7 +300,12 @@ where
|
||||
.get(&id)
|
||||
.cloned()
|
||||
.or_else(|| snapshot.map(|(name, _)| (name.clone(), String::new())))
|
||||
.unwrap_or_else(|| (format!("Playlist ({count} local)"), String::new()));
|
||||
.unwrap_or_else(|| {
|
||||
(
|
||||
qbz_i18n::t_args("Playlist ({} local)", &[&count.to_string()]),
|
||||
String::new(),
|
||||
)
|
||||
});
|
||||
// Track count: the snapshot's point-in-time Qobuz total when
|
||||
// known (the "# of tracks" sort key), else the local count.
|
||||
let tracks_count = snapshot.and_then(|(_, tc)| *tc).unwrap_or(count);
|
||||
|
||||
Reference in new issue
Block a user