View previous topic :: View next topic |
Author |
Message |
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Wed Aug 25, 2010 2:08 pm Post subject: Language detection |
|
|
I am trying to identify from within a Fortran95 program the language that the user might prefer to use by default. While trying to find something clues from browsing the web I came across a Windows function called GetSystemDefaultUILanguage that may be what I need, although I'm not entirely sure, and I would not have the faintest idea how to call that routine from within Fortran anyway! Currently I use a fairly crude method: I make a call to getenv@ to query the APPDATA directory, and then detect the language from however "Application Data" is written. If anyone has some better ideas they would be most appreciated. |
|
Back to top |
|
|
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Fri Aug 27, 2010 9:18 pm Post subject: |
|
|
I'm guessing you need to do something like this. You can search for GetSystemDefaultLangID for more info. You need to link with the Kernel32.DLL using SLINK to access the function. However, you can do this easily by just adding kernel32.dll as a reference in PLATO. Right click on your project files and then click add reference. (find it in your windows\system32 directory).
Code: |
PROGRAM ANON
C_EXTERNAL GetSystemDefaultLangID "GetSystemDefaultLangID" : INTEGER*2
INTEGER*2 :: lang
! Get default language according to control panel
lang = GetSystemDefaultLangID()
! Process lang code
END ANON
|
Codes for different languages are at http://msdn.microsoft.com/en-us/library/dd318693%28v=VS.85%29.aspx and at http://www.science.co.il/Language/Locale-Codes.asp
The codes are in HEX. When I run this in the UK I get code 2057 which is hexadecimal 809 which agrees with the table at the second link above.
I would normally use KIND= to create 2 byte integers but I am unsure what value to use, so I have used INTEGER*2 in the code above.
Have fun
David. |
|
Back to top |
|
|
|