friedrith / node-wifi

📶 NodeJS tool to manage wifi (connections, scans)
MIT License
396 stars 160 forks source link

Problem with locale with getCurrentConnection #143

Open Nevyn75 opened 3 years ago

Nevyn75 commented 3 years ago

Hi.

I'm using an Ubuntu 18.04 installed in Italian language. I expected that getCurrentConnection returned me the current connection but it returned empty array every time. While debugging I found that inside your code there's:

if (fields[0] == 'yes') {
          networks.push({

The problem is that on my system, fields[0] == 'sì' (yes in Italian), that's why the returning array is empty. I think this would be a problem also for other installation languages.

Maybe a possible solution could be to set the env var LANGUAGE=en when executing nmcli, on my system that worked and I saw 'yes' instead of 'sì'.

Steps to Reproduce (for bugs)

To reproduce you only need to have installed a different locale than 'en' and set the env variable LANGUAGE=it (for example) when calling to nmcli:

LANGUAGE=it nmcli --terse --fields active,ssid,bssid,mode,chan,freq,signal,security,wpa-flags,rsn-flags,device device wifi

output:

sì:WIFI_EXT:AC\:84\:C6\:98\:24\:6A.....

The first field will change from 'yes' to 'si' (in case of Italian locale)

Your Environment

Regards