CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2008
    Posts
    8

    Can we set locale with a single API call

    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

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Can we set locale with a single API call

    So you want to change Control "Panel > Regional Settings" programmatically? Why?

    gg

  3. #3
    Join Date
    Apr 2008
    Posts
    8

    Re: Can we set locale with a single API call

    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.

  4. #4
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Can we set locale with a single API call

    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

  5. #5
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Can we set locale with a single API call

    Quote Originally Posted by codekomlete View Post
    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

  6. #6
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Can we set locale with a single API call

    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.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  7. #7
    Join Date
    Apr 2008
    Posts
    8

    Re: Can we set locale with a single API call

    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

  8. #8
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Can we set locale with a single API call

    >> 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/archiv...23/411074.aspx
    http://blogs.msdn.com/michkap/archiv...22/454360.aspx
    http://msdn.microsoft.com/en-us/libr...06(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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured