From 3ba5f42d5bde2fa0b077cd44171f5886fcd295f4 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 9 Nov 2026 09:08:19 +0100 Subject: [PATCH] i18n: add missing passphrase on host translations Passphrase on host related translations were missing. Existing translation for "Please try again" was bypassed in unlock.rs, fixed as well. --- src/i18n/locales/de/firmware.json | 6 +++- src/i18n/locales/en/firmware.json | 6 +++- src/rust/bitbox02-rust/src/hww/api/unlock.rs | 31 +++++++++++++++----- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/i18n/locales/de/firmware.json b/src/i18n/locales/de/firmware.json index 1a2f0f7387..2ad7a3286e 100644 --- a/src/i18n/locales/de/firmware.json +++ b/src/i18n/locales/de/firmware.json @@ -328,9 +328,13 @@ "passphrase": { "confirm": "Bestätigen", "confirmEmpty": "Leere Passphrase\nverwenden?", + "confirmHost": "Passphrase auf\nHost eingeben?", "doubleCheck": "Bitte prüfe gleich\ndie angezeigte\nPassphrase erneut.", + "enterOnHost": "Passphrase auf\nHost eingeben", "title": "Optionale Passphrase", - "tryAgain": "Bitte erneut\nversuchen" + "tooLong": "Passphrase\nzu lang", + "tryAgain": "Bitte erneut\nversuchen", + "unsupportedCharacters": "Ungültige\nZeichen" }, "remainingAttempts": { "last": "LETZTER Versuch.\nBei falschem\nPasswort wird das\nGerät zurückgesetzt.", diff --git a/src/i18n/locales/en/firmware.json b/src/i18n/locales/en/firmware.json index 93d8a68d9f..099bc8363a 100644 --- a/src/i18n/locales/en/firmware.json +++ b/src/i18n/locales/en/firmware.json @@ -328,9 +328,13 @@ "passphrase": { "confirm": "Confirm", "confirmEmpty": "Use empty\npassphrase?", + "confirmHost": "Enter passphrase\non host?", "doubleCheck": "You will be asked to\nvisually confirm your\npassphrase now.", + "enterOnHost": "Enter passphrase\non host", "title": "Optional passphrase", - "tryAgain": "Please try again" + "tooLong": "Passphrase too\nlong", + "tryAgain": "Please try again", + "unsupportedCharacters": "Unsupported\ncharacters" }, "remainingAttempts": { "last": "This is your LAST\npassword attempt.\nDevice will reset\nif password is wrong.", diff --git a/src/rust/bitbox02-rust/src/hww/api/unlock.rs b/src/rust/bitbox02-rust/src/hww/api/unlock.rs index 7725a20806..5bde543d17 100644 --- a/src/rust/bitbox02-rust/src/hww/api/unlock.rs +++ b/src/rust/bitbox02-rust/src/hww/api/unlock.rs @@ -3,6 +3,7 @@ use super::error::Error; use crate::hal::ui::ConfirmParams; use crate::hal::{Memory, Ui}; +use crate::i18n::I18n as _; use crate::pb; use crate::pb::request::Request; use crate::pb::response::Response; @@ -64,16 +65,21 @@ async fn device_entry(hal: &mut impl crate::hal::Hal) -> Result Result<(), &'static str> { +enum HostPassphraseError { + TooLong, + UnsupportedCharacters, +} + +fn validate_host_passphrase(passphrase: &str) -> Result<(), HostPassphraseError> { // Restrict host input to values that can also be entered again on the device. if passphrase.len() > MAX_PASSPHRASE_LEN { - return Err("Passphrase too\nlong"); + return Err(HostPassphraseError::TooLong); } if !passphrase .bytes() .all(|c| c.is_ascii_alphanumeric() || SPECIAL.contains(&c)) { - return Err("Unsupported\ncharacters"); + return Err(HostPassphraseError::UnsupportedCharacters); } Ok(()) } @@ -94,11 +100,12 @@ async fn passphrase(hal: &mut impl crate::hal::Hal) -> Result, None => { // Entry was interrupted by the host button. Rejection/cancellation always starts a // fresh device-entry screen, without preserving a partially entered passphrase. + let body = crate::tr!(hal, "Enter passphrase\non host?"); if hal .ui() .confirm(&ConfirmParams { title: "", - body: "Enter passphrase\non host?", + body: &body, ..Default::default() }) .await @@ -109,7 +116,8 @@ async fn passphrase(hal: &mut impl crate::hal::Hal) -> Result, let request = { let waiting = async { - hal.ui().waiting("Enter passphrase\non host").await; + let message = crate::tr!(hal, "Enter passphrase\non host"); + hal.ui().waiting(&message).await; unreachable!() }; // Poll the waiting screen first so it is visible before HOST_ENTRY_READY. This @@ -126,10 +134,16 @@ async fn passphrase(hal: &mut impl crate::hal::Hal) -> Result, let Some(passphrase) = request.passphrase.take().map(Zeroizing::new) else { continue; }; - if let Err(message) = validate_host_passphrase(&passphrase) { + if let Err(error) = validate_host_passphrase(&passphrase) { // Invalid user input restarts entry just like rejection; malformed protocol // messages still fail in next_request. - hal.ui().status(message, false).await; + let message = match error { + HostPassphraseError::TooLong => crate::tr!(hal, "Passphrase too\nlong"), + HostPassphraseError::UnsupportedCharacters => { + crate::tr!(hal, "Unsupported\ncharacters") + } + }; + hal.ui().status(&message, false).await; continue; } (passphrase, true) @@ -141,7 +155,8 @@ async fn passphrase(hal: &mut impl crate::hal::Hal) -> Result, { return Ok(passphrase); } - hal.ui().status("Please try again", false).await; + let status = crate::tr!(hal, "Please try again"); + hal.ui().status(&status, false).await; } }