i18n on the web - deepseek translations

This commit is contained in:
Priec
2026-08-14 20:35:37 +02:00
parent 2dc0d94ba0
commit 8f1bfdbe0c
91 changed files with 4679 additions and 1237 deletions

View File

@@ -1,4 +1,8 @@
use crate::{pages::permissions::common::state::Tabs, ui::Nav};
use crate::{
{i18n::Locale, tr},
pages::permissions::common::state::Tabs,
ui::Nav,
};
#[derive(Clone, Debug, Default, serde::Deserialize)]
pub(crate) struct Selection {
@@ -50,15 +54,15 @@ impl RoleRow {
/// Why the delete button is missing, so an undeletable role says so instead
/// of showing nothing.
pub(crate) fn keeps_reason(&self) -> &'static str {
pub(crate) fn keeps_reason(&self, locale: &Locale) -> String {
if !self.editable {
"outranks you"
tr!(*locale, "perm-role-reason-outranks-you")
} else if self.built_in {
"built in"
tr!(*locale, "perm-role-reason-built-in")
} else if self.users.is_some_and(|count| count > 0) {
"still assigned"
tr!(*locale, "perm-role-reason-still-assigned")
} else {
""
String::new()
}
}
}
@@ -69,7 +73,10 @@ impl RoleRow {
/// tables added later, which is what "everything" has to mean for a role
/// created before the data exists. ECB rates are written by the server, so they
/// are readable and nothing more.
pub(crate) fn starter_grants(access: &str) -> Result<Vec<(&'static str, &'static str)>, String> {
pub(crate) fn starter_grants(
locale: Locale,
access: &str,
) -> Result<Vec<(&'static str, &'static str)>, String> {
match access {
"" | "none" => Ok(Vec::new()),
"read" => Ok(vec![
@@ -86,7 +93,11 @@ pub(crate) fn starter_grants(access: &str) -> Result<Vec<(&'static str, &'static
}
Ok(grants)
}
other => Err(format!("'{other}' is not a starter access level.")),
other => Err(tr!(
locale,
"perm-err-bad-starter-access",
"value" => other.to_string(),
)),
}
}
@@ -96,11 +107,12 @@ mod tests {
#[test]
fn starter_access_never_hands_out_a_write_on_ecb_rates() {
assert!(starter_grants("none").unwrap().is_empty());
assert!(starter_grants("nonsense").is_err());
let locale = Locale::default();
assert!(starter_grants(locale, "none").unwrap().is_empty());
assert!(starter_grants(locale, "nonsense").is_err());
for level in ["read", "full"] {
let grants = starter_grants(level).unwrap();
let grants = starter_grants(locale, level).unwrap();
assert!(
grants
.iter()
@@ -109,8 +121,8 @@ mod tests {
);
}
assert_eq!(starter_grants("read").unwrap().len(), 3);
assert_eq!(starter_grants("full").unwrap().len(), 9);
assert_eq!(starter_grants(locale, "read").unwrap().len(), 3);
assert_eq!(starter_grants(locale, "full").unwrap().len(), 9);
}
#[test]
@@ -128,6 +140,9 @@ mod tests {
assert!(!row(false, Some(2), true).removable());
assert!(!row(true, Some(0), true).removable());
assert!(!row(false, Some(0), false).removable());
assert_eq!(row(false, Some(2), true).keeps_reason(), "still assigned");
assert_eq!(
row(false, Some(2), true).keeps_reason(&Locale::default()),
"still assigned"
);
}
}