Click to See Complete Forum and Search --> : Can we set locale with a single API call
codekomlete
December 30th, 2008, 08:11 AM
Hi,
I am interested in setting the locale of a system. I want that the last locale set should remain same even after system reboot.
I came to know about a Winapi SetLocaleInfo but it only sets in the user locale (i think it will go off after reboot)
I also noticed that SetLocaleInfo works on only one item of the locale at a time (e.g. date, time, currency etc.) which is not what I would like to do.
Is there some way to set the whole locale to, say French on a single API call and everything in the system changes to French locale?
There is also a SetLocale function in VC++ library, but I dont see the changes reflected in the Control Panel > Regional Settings > after this function is called.
Please help.
Best regards
Codeplug
December 30th, 2008, 08:23 AM
So you want to change Control "Panel > Regional Settings" programmatically? Why?
gg
codekomlete
December 30th, 2008, 11:28 PM
I have provided a UI where I give the user an option to change the application language at runtime. Then I want to update the UI as per the new language and also update the locale of the system to get it in sync with the UI language.
Codeplug
December 31st, 2008, 12:22 AM
There are many applications that support multiple languages. I don't know of any that change system settings. Why do you feel the need to change the system setting?
gg
Paul McKenzie
December 31st, 2008, 12:42 AM
IThen I want to update the UI as per the new language and also update the locale of the system to get it in sync with the UI language.You never change system settings on the user like that. That is nothing more than malware, whether you mean for it to be malware or not. As CodePlug stated, there are many apps where the UI changes language on the fly without changing system settings.
All you'll get is nasty complaints, and maybe even a few outraged customers that your application just willy-nilly changes a system setting on a user. What if the user is running another program that relies on the original regional settings to not change? All you'll do is potentially screw up the other program, and cause other problems (maybe even data loss for the customer because you changed system settings while an important program is running!).
Regards,
Paul McKenzie
Ajay Vijay
December 31st, 2008, 01:18 AM
Regional setting are specific to users, and not to system (and SetLocaleInfo mentions it).
Also, as mentioned in documentation, you need to send WM_SETTINGCHANGE message to notify this change.
codekomlete
December 31st, 2008, 06:49 AM
Thanks for the replies. What I want to achieve is a way to change the locale for the user when he does a language change from the UI.
From the app, it can be achieved through a call to SetLocaleInfo but it lets me change one item at a time. I am looking for a way to change everything related to locale in a single function call. I don't want to call SetLocaleInfo repeatedly for setting different items.
Also, it would be great that that when the user logs in, my app restarts in the same language which was last set by the user.
Best regards
Codeplug
December 31st, 2008, 08:34 AM
>> From the app, it can be achieved through a call to SetLocaleInfo
No. You shouldn't even use SetThreadLocale. Some reading:
http://blogs.msdn.com/michkap/archive/2005/04/23/411074.aspx
http://blogs.msdn.com/michkap/archive/2005/08/22/454360.aspx
http://msdn.microsoft.com/en-us/library/aa366906(VS.85).aspx
>> when he does a language change from the UI
What are you trying to achieve? Are you trying to add "hot-swappable" language support in your application?
gg
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.