Forum Discussion

SlickRick's avatar
SlickRick
Frequent Contributor
2 years ago

Change the OS region format all at once

Hi all,

 

is there a way to change the regional setting so that we change the format based on a given format such as French-France ('fr-FR') :

 

I saw that i can use the script to change the SetLocaleInfo to change each properties one by one, but i would prefer to use the Format pre-set settings to tests.

Thank you.

 

  • Here is the scripts I have wrote to do this.
    Hoping this can help someone someday :)

    Basically I have tools to change only the decimal separator and some to change the settings to a predefined OS one.

    In order to change the OS Region, i had to run using a powerscript command to have the effect i wanted. 

    /**
     * Sets the decimal symbol for the user's locale settings.
     *
     *  {string} separator - The character to be used as the decimal separator. Default is '.'.
     */
    function Locale_SetDecimalSymbol(separator = ".") {
        // Sets the system's decimal separator to the specified character.
        // LOCALE_SDECIMAL: Constant representing the setting for the decimal separator.
        SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, separator);
    }
    
    /**
     * Sets the thousands separator for the user's locale settings.
     *
     *  {string} separator - The character to be used as the thousands separator. Default is ','.
     */
    function Locale_SetThousandSeparator(separator = ",") {
        // Sets the system's thousand separator to the specified character.
        // LOCALE_STHOUSAND: Constant representing the setting for the thousand separator.
        SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, separator);
    }
    
    /**
     * Sets the list separator for the user's locale settings.
     *
     *  {string} separator - The character to be used as the list separator. Default is ','.
     */
    function Locale_SetListSeparator(separator = ",") {
        // Sets the system's list separator to the specified character.
        // LOCALE_SLIST: Constant representing the setting for the list separator.
        SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, separator);
    }
    
    /**
     * Sets the locale settings to a given culture.
     * Culture must be in a format such as 'fr-FR', 'en-US', etc.
     *
     *  {string} cultureString - The culture to set the locale settings to.
     */
    function Locale_SetSettings(cultureString) {
        WshShell.Run("powershell -command Set-Culture " + cultureString, 1, true);
        Log.Message("Setting culture to " + cultureString);
    }
    
    /**
     * Sets the locale settings to the French culture (fr-FR).
     */
    function Locale_SetFrenchSettings() {
        Locale_SetSettings("fr-FR");
    }
    
    /**
     * Sets the locale settings to the English US culture (en-US).
     */
    function Locale_SetEnglishUSSettings() {
        Locale_SetSettings("en-US");
    }

     

  • SlickRick's avatar
    SlickRick
    Frequent Contributor

    Here is the scripts I have wrote to do this.
    Hoping this can help someone someday :)

    Basically I have tools to change only the decimal separator and some to change the settings to a predefined OS one.

    In order to change the OS Region, i had to run using a powerscript command to have the effect i wanted. 

    /**
     * Sets the decimal symbol for the user's locale settings.
     *
     *  {string} separator - The character to be used as the decimal separator. Default is '.'.
     */
    function Locale_SetDecimalSymbol(separator = ".") {
        // Sets the system's decimal separator to the specified character.
        // LOCALE_SDECIMAL: Constant representing the setting for the decimal separator.
        SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, separator);
    }
    
    /**
     * Sets the thousands separator for the user's locale settings.
     *
     *  {string} separator - The character to be used as the thousands separator. Default is ','.
     */
    function Locale_SetThousandSeparator(separator = ",") {
        // Sets the system's thousand separator to the specified character.
        // LOCALE_STHOUSAND: Constant representing the setting for the thousand separator.
        SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, separator);
    }
    
    /**
     * Sets the list separator for the user's locale settings.
     *
     *  {string} separator - The character to be used as the list separator. Default is ','.
     */
    function Locale_SetListSeparator(separator = ",") {
        // Sets the system's list separator to the specified character.
        // LOCALE_SLIST: Constant representing the setting for the list separator.
        SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, separator);
    }
    
    /**
     * Sets the locale settings to a given culture.
     * Culture must be in a format such as 'fr-FR', 'en-US', etc.
     *
     *  {string} cultureString - The culture to set the locale settings to.
     */
    function Locale_SetSettings(cultureString) {
        WshShell.Run("powershell -command Set-Culture " + cultureString, 1, true);
        Log.Message("Setting culture to " + cultureString);
    }
    
    /**
     * Sets the locale settings to the French culture (fr-FR).
     */
    function Locale_SetFrenchSettings() {
        Locale_SetSettings("fr-FR");
    }
    
    /**
     * Sets the locale settings to the English US culture (en-US).
     */
    function Locale_SetEnglishUSSettings() {
        Locale_SetSettings("en-US");
    }