forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Language detection

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
simon



Joined: 05 Jul 2006
Posts: 268

PostPosted: Wed Aug 25, 2010 2:08 pm    Post subject: Language detection Reply with quote

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
View user's profile Send private message
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Fri Aug 27, 2010 9:18 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group