wifi-rs icon indicating copy to clipboard operation
wifi-rs copied to clipboard

Bug: need support for other lang

Open ttxs25830 opened this issue 2 years ago • 1 comments

Failed to check if the command is success when system is set to use other languages. For example, in Linux we use this code to disconnect WiFi:

/// Attempts to disconnect from a wireless network currently connected to.
    fn disconnect(&self) -> Result<bool, WifiConnectionError> {
        let output = Command::new("nmcli")
            .args(&["d", "disconnect", "ifname", &self.interface])
            .output()
            .map_err(|err| WifiConnectionError::FailedToDisconnect(format!("{}", err)))?;

        Ok(String::from_utf8_lossy(&output.stdout)
            .as_ref()
            .contains("disconnect"))
    }

But when locale is set to other language, this command's output is look like this: 成功断开设备 "wlan0"(For LANG=zh_CN.UTF-8) As result, this command always returns Ok(false) even if it did disconnect the WiFi.

ttxs25830 avatar Feb 11 '23 09:02 ttxs25830

Thanks for raising this issue @ttxs25830. I never considered that case, and apologies for that.

If you'll like to work on a fix that'll be awesome; we can have a discussion on how to approach it so that it can also extend to other languages.

Else, I'll try to circle back to it when I've got some free time.

toksdotdev avatar Feb 16 '23 09:02 toksdotdev