diff --git a/services/status/locales/i18n.json b/services/status/locales/i18n.json index 6a920d045..4da4277eb 100644 --- a/services/status/locales/i18n.json +++ b/services/status/locales/i18n.json @@ -487,6 +487,48 @@ "ja": "中断不可能な操作が保留中です。 数秒後にスリープ リクエストを再試行してください。", "zh": "不间断操作挂起。 请在几秒钟后重试睡眠请求。" }, + "prefs.autobacklight_enable": { + "en": "Autobacklight on/off", + "en-tts": "Autobacklight on/off", + "fr": "Rétroéclairage automatique *MT*", + "ja": "自動逆光のオン/オフ", + "zh": "自动背光开/关" + }, + "prefs.autobacklight_duration": { + "en": "Autobacklight duration", + "en-tts": "Autobacklight duration", + "fr": "Durée du rétroéclairage automatique *MT*", + "ja": "自動バックライトの持続時間", + "zh": "自动背光持续时间" + }, + "prefs.autobacklight_duration_in_secs": { + "en": "Autobacklight duration in seconds:", + "en-tts": "Autobacklight duration in seconds", + "fr": "Durée du rétroéclairage automatique en secondes: *MT*", + "ja": "自動バックライトの持続時間 (秒):", + "zh": "自动背光持续时间(以秒为单位):" + }, + "prefs.autobacklight_err": { + "en": "Duration must be positive!", + "en-tts": "Duration must be positive!", + "fr": "La durée doit être positive! *MT*", + "ja": "期間は正でなければなりません!", + "zh": "持续时间必须为正数!" + }, + "prefs.yes": { + "en": "Yes", + "en-tts": "Yes", + "fr": "Oui", + "ja": "はい", + "zh": "确定" + }, + "prefs.no": { + "en": "No", + "en-tts": "No", + "fr": "Non", + "ja": "いいえ", + "zh": "取消" + }, "wlan.cancel": { "en": "❌ Cancel request ❌", "en-tts": "Cancel the requested action", diff --git a/services/status/src/main.rs b/services/status/src/main.rs index 5ed4db2d3..b14989fda 100644 --- a/services/status/src/main.rs +++ b/services/status/src/main.rs @@ -401,11 +401,11 @@ fn wrapped_main() -> ! { }.unwrap_or_else(|error| { log::error!("cannot start connection manager: {:?}", error) }); - + // note inversion of preferences to cause it to be on by default match all_prefs.autobacklight_on_boot { - true => send_message(status_cid, Message::new_scalar( + false => send_message(status_cid, Message::new_scalar( StatusOpcode::EnableAutomaticBacklight.to_usize().unwrap(), 0,0,0,0)), - false => Ok(xous::Result::Ok), + true => Ok(xous::Result::Ok), }.unwrap_or_else(|error| { log::error!("cannot set autobacklight status: {:?}", error); xous::Result::Ok diff --git a/services/status/src/preferences.rs b/services/status/src/preferences.rs index 5605edd1f..928bc15ba 100644 --- a/services/status/src/preferences.rs +++ b/services/status/src/preferences.rs @@ -41,18 +41,18 @@ pub enum PrefsMenuUpdateOp { impl Display for DevicePrefsOp { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { - Self::AutobacklightOnBoot => write!(f, "Autobacklight enabled on boot"), - Self::AutobacklightTimeout => write!(f, "Autobacklight timeout"), - Self::ConnectKnownNetworksOnBoot => write!(f, "Connect to known networks on boot"), - Self::RadioOnOnBoot => write!(f, "Enable WiFi on boot"), + Self::AutobacklightOnBoot => write!(f, "{}", t!("prefs.autobacklight_enable", xous::LANG)), + Self::AutobacklightTimeout => write!(f, "{}", t!("prefs.autobacklight_duration", xous::LANG)), + Self::ConnectKnownNetworksOnBoot => write!(f, "Automatically connnect to networks"), + Self::RadioOnOnBoot => write!(f, "WiFi kill switch"), Self::KeyboardLayout => write!(f, "Keyboard layout"), - Self::WLANMenu => write!(f, "WLAN settings"), + Self::WLANMenu => write!(f, "WiFi settings"), Self::SetTime => write!(f, "{}", t!("mainmenu.set_rtc", xous::LANG)), Self::SetTimezone => write!(f, "{}", t!("mainmenu.set_tz", xous::LANG)), Self::AudioOn => write!(f, "{}", "Enable audio subsystem"), Self::AudioOff => write!(f, "{}", "Disable audio subsystem"), Self::HeadsetVolume => write!(f, "{}", "Headset volume"), - Self::EarpieceVolume => write!(f, "{}", "Earpiece volume"), + Self::EarpieceVolume => write!(f, "{}", "Speaker volume"), _ => unimplemented!("should not end up here!"), } @@ -237,11 +237,11 @@ impl DevicePrefs { impl DevicePrefs { fn autobacklight_on_boot(&mut self) -> Result<(), DevicePrefsError> { - let cv = self.up.autobacklight_on_boot_or_default()?; + let cv = !self.up.autobacklight_on_boot_or_default()?; // note inversion of storage sense to make it on when false - self.modals.add_list(vec!["Yes", "No"]).unwrap(); + self.modals.add_list(vec![t!("prefs.yes", xous::LANG), t!("prefs.no", xous::LANG)]).unwrap(); - let new_result = yes_no_to_bool( + let new_result = !yes_no_to_bool( // inversion of storage sense: false = on self.modals .get_radiobutton(&format!("Current status: {}", bool_to_yes_no(cv))) .unwrap() @@ -268,13 +268,13 @@ impl DevicePrefs { let raw_timeout = self .modals - .alert_builder("Autobacklight timeout in seconds:") + .alert_builder(t!("prefs.autobacklight_duration_in_secs", xous::LANG)) .field( Some(cv.to_string()), Some(|tf| match tf.as_str().parse::() { Ok(_) => None, Err(_) => Some(xous_ipc::String::from_str( - "Timeout must be a positive number!", + t!("prefs.autobacklight_err", xous::LANG), )), }), ) @@ -289,7 +289,7 @@ impl DevicePrefs { fn radio_on_on_boot(&mut self) -> Result<(), DevicePrefsError> { let cv = self.up.radio_on_on_boot_or_default()?; - self.modals.add_list(vec!["Yes", "No"]).unwrap(); + self.modals.add_list(vec![t!("prefs.yes", xous::LANG), t!("prefs.no", xous::LANG)]).unwrap(); let new_result = yes_no_to_bool( self.modals @@ -304,7 +304,7 @@ impl DevicePrefs { fn connect_known_networks_on_boot(&mut self) -> Result<(), DevicePrefsError> { let cv = self.up.connect_known_networks_on_boot_or_default()?; - self.modals.add_list(vec!["Yes", "No"]).unwrap(); + self.modals.add_list(vec![t!("prefs.yes", xous::LANG), t!("prefs.no", xous::LANG)]).unwrap(); let new_result = yes_no_to_bool( self.modals @@ -512,17 +512,19 @@ pub fn percentage_to_db(value: u32) -> i32 { } fn yes_no_to_bool(val: &str) -> bool { - match val.to_ascii_lowercase().as_str() { - "yes" => true, - "no" => false, - _ => unreachable!("cannot go here!"), + if val.to_ascii_lowercase().as_str() == t!("prefs.yes", xous::LANG) { + true + } else if val.to_ascii_lowercase().as_str() == t!("prefs.no", xous::LANG) { + false + } else { + unreachable!("cannot go here!"); } } fn bool_to_yes_no(val: bool) -> String { match val { - true => "yes".to_owned(), - false => "no".to_owned(), + true => t!("prefs.yes", xous::LANG).to_owned(), + false => t!("prefs.no", xous::LANG).to_owned(), } }