Re: [code] [textadept] Detecting the locale in Windows

From: Rena <hyperhacker.att.gmail.com>
Date: Fri, 4 Sep 2015 20:29:02 -0400

On Sep 4, 2015 2:47 PM, "Giovanni Salmeri" <g.salmeri.att.mondodomani.org>
wrote:
>
> Hello everybody.
>
> Presently core/locale.lua:14 detects the locale as follows:
>
> local lang = (os.getenv('LANG') or ''):match('^[^_.@]+')
>
> Unfortunately that cannot work in Windows, which makes no use of the
> environment variable LANG. After some experimenting I wrote the
> following code:
>
> if WIN32 then
> local conv_lang = {
> Arab = "ar",
> Dutch = "nl",
> English = "en",
> French = "fr",
> German = "de",
> Italian = "it",
> Portuguese = "pt",
> Russian = "ru",
> Spanish = "es",
> Swedish = "sv",
> }
> lang = (os.setlocale(nil, 'ctype') or ''):match('^[^_.@]+')
> lang = conv_lang[lang_os] or lang
> end
>
> That seems more or less to work (I learnt that detecting properly the
> UI language in Windows is a tricky affair). Perhaps a more robust
> approach would involve using something like
>
> f = package.loadlib("kernel32.dll", "GetUserDefaultUILanguage")
>
> but I don't know how one should proceed. Any comments or ideas? Thank
> you!
>
> --
> Giovanni Salmeri
> http://mondodomani.org/pers/salmeri/
> --
> You are subscribed to code.att.foicica.com.
> To change subscription settings, send an e-mail to code+help.att.foicica.com.
> To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
>

Unless TextAdept does something special, you won't be able to call Windows
API functions using package.loadlib. You'd need an FFI library such as
Alien (or TA would have to expose a wrapper in the C API).

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Fri 04 Sep 2015 - 20:29:02 EDT

This archive was generated by hypermail 2.2.0 : Sat 05 Sep 2015 - 06:50:57 EDT