node-hotspot icon indicating copy to clipboard operation
node-hotspot copied to clipboard

Locale problem

Open tobeorla opened this issue 8 years ago • 4 comments

The package checks for hardcoded english string values like status.split('Hosted network settings')[1], matches[1] === 'Yes' , etc.. if you have the O.S (windows) set in another language, the returned messages are translated, so it fails to match any result.

I think there are 2 approaches to fix this.

  • The best one (if possible to do): Change the UICulture when executing commands in powershell, so output will be always in english. Bad thing is that user may not have english as available locale. (if hasn't set the o.s in english, he usually doesn't have it)

  • The normal one: Make a locale array to place the translated output of each language, ex:

var locales = {
    'es' : {
        'Hosted network supported' : 'Red hospedada admitida',
        'Hosted network status' : 'Estado de la red hospedada',
        'Hosted network settings' : 'Configuración de red hospedada',
        'SSID name' : 'Nombre de SSID',
        'Yes' : 'Sí',
    }
}, currentLocale = 'es'; // find a package like https://github.com/sindresorhus/os-locale to detect os locale and set this var

function getPhrase (phrase) {
    return locales[currentLocale][phrase];
}

By the way, the returned output has encoding problems, for example is returned as S�

tobeorla avatar Jun 26 '17 09:06 tobeorla

Hey @tobeorla, Thanks for bringing this to my attention... Are you aware of a windows api that allows one to check if a locale is installed on the system? If there is one we could potentially use the best of both solutions: switch the lang to en if we can and use it; if not attempt to use the translations...

luigiplr avatar Jun 26 '17 20:06 luigiplr

I'm not really sure as until now i didn't even realize that my powershell wasn't in english.

If i run [System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]::AllCultures) in powershell, it prints the list, but i'm not sure if that means that all of them are available or it's just a reference. And [System.Globalization.Cultureinfo]::GetCultureInfo(CULTURE_ID) returns an error if the given id it's not (listed|exists?)

English (en) it's [System.Globalization.Cultureinfo]::GetCultureInfo(9) American (en-US) it's [System.Globalization.Cultureinfo]::GetCultureInfo(1033)

tobeorla avatar Jun 27 '17 06:06 tobeorla

Interesting.. I'll set up a french windows VM tonight and try out a few of these commands

luigiplr avatar Jun 27 '17 17:06 luigiplr

I think i've found something interesting. Maybe we could migrate to full powershell commands. As they are returned in english / can use -locale 1033 to force en-US. Example: Get-NetAdapter replacing netsh wlan show hostednetwork

Get-NetAdapter -InterfaceDescription "Microsoft Hosted Network Virtual Adapter" | ft SystemName, Status But i can't find the max clients/ current connected amount. https://technet.microsoft.com/en-us/library/jj130867(v=wps.630).aspx https://msdn.microsoft.com/en-us/library/hh968170(v=vs.85).aspx

Running Get-NetAdapter -InterfaceDescription "Microsoft Hosted Network Virtual Adapter" | ft -property * should return all properties.

There's also a Get-NetAdapterAdvancedProperty https://technet.microsoft.com/en-us/library/jj130901(v=wps.630).aspx https://msdn.microsoft.com/en-us/library/hh872341(v=vs.85).aspx

kingio avatar Jul 31 '17 13:07 kingio