[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Windows Language

André

2/12/2007 3:30:00 PM

Hello,

Is it possible to find the Windows natural language (ex. English,
French, Russian, etc...) from Ruby?

Thank you in advance,

André

3 Answers

Jano Svitok

2/12/2007 6:09:00 PM

0

On 2/12/07, Jason Mayer <slamboy@gmail.com> wrote:
> On 2/12/07, André <andre.nho@gmail.com> wrote:
> >
> > Hello,
> >
> > Is it possible to find the Windows natural language (ex. English,
> > French, Russian, etc...) from Ruby?
> >
> > Thank you in advance,
> >
> > André
>
> If you don't mind using some good old fashioned command line tools, here's a
> solution.
>
> variables = `set`
> lang_used = variables.scan(%r{LANG=.})
> puts lang_used
>
> Hope that helps.
>

I have no such variable set (XP SP2).

André

2/12/2007 6:36:00 PM

0

> Is it possible to find the Windows natural language (ex. English,
> French, Russian, etc...) from Ruby?

It's ok, I found already. Here's the code:


require 'Win32API'
language = Win32API.new("kernel32.dll", "GetLocaleInfoA", ['L', 'L',
'P', 'L'], 'L')
x = " " * 255
language.Call(1024, 4097, x, 255)
puts x.strip


Regards!

André

Jano Svitok

2/12/2007 6:38:00 PM

0

On 2/12/07, Jan Svitok <jan.svitok@gmail.com> wrote:
> On 2/12/07, Jason Mayer <slamboy@gmail.com> wrote:
> > On 2/12/07, André <andre.nho@gmail.com> wrote:
> > >
> > > Hello,
> > >
> > > Is it possible to find the Windows natural language (ex. English,
> > > French, Russian, etc...) from Ruby?
> > >
> > > Thank you in advance,
> > >
> > > André
> >
> > If you don't mind using some good old fashioned command line tools, here's a
> > solution.
> >
> > variables = `set`
> > lang_used = variables.scan(%r{LANG=.})
> > puts lang_used
> >
> > Hope that helps.
> >
>
> I have no such variable set (XP SP2).

The list of languages is here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nl...
(The table is inwin32utils/windows-pr as well).

The function to retrieve is here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nl...

or here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nl...

depending on whether you want the system language or the user one
(multiple users can specify different languages)

Use WIN32API to glue them together (I don't have time now to write the
function, sorry)