Hello,
Is it possible to find the Windows natural language (ex. English,
French, Russian, etc…) from Ruby?
Thank you in advance,
Andr
Hello,
Is it possible to find the Windows natural language (ex. English,
French, Russian, etc…) from Ruby?
Thank you in advance,
Andr
On 2/12/07, André [email protected] 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.
On 2/12/07, Jason M. [email protected] wrote:
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_usedHope that helps.
I have no such variable set (XP SP2).
On 2/12/07, Jan S. [email protected] wrote:
André
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/nls_61df.asp
(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/nls_2ip1.asp
or here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_5c85.asp
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)
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
On 2/12/07, André [email protected] wrote:
x = " " * 255
language.Call(1024, 4097, x, 255)
puts x.strip
Here’s another way to do it that might work.
variables = systeminfo
lang_used = variables.scan(%r{System Locale:.*})
puts lang_used
I like that way though.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs