GetLocale Function

Returns the current locale ID value.

GetLocale()

Remarks

A locale is a set of user preference information related to the user's language, country/region, and cultural conventions. The locale determines such things as keyboard layout, alphabetical sort order, and date, time, number, and currency formats.

The return value can be any of the 32-bit values shown in the Locale ID chart:

Example

The following example illustrates the use of the GetLocale function. To use this code, paste the example into an HTML page.

<html>
<head>
    <title>Locale Converter</title>
</head>

<body>
    <table cellpadding="2">
        <tr>
            <td>Convert</td>
            <td>
               <input type="text" id="inputText" size="10" value="12/15/2009" />
            </td>
        </tr>

        <tr>
            <td></td>
            <td>
                <input type="radio" name="radioGroup" checked="checked" />Date
                <input type="radio" name="radioGroup" />Currency
            </td>
        </tr>

        <tr>
            <td>From Locale ID</td>
            <td>
               <input type="text" id="fromLocaleID" size="7" value="en-us" />
            </td>
        </tr>

        <tr>
            <td>To Locale ID</td>
            <td>
               <input type="text" id="toLocaleID" size="7" value="fr-fr" />
            </td>
        </tr>

        <tr>
            <td>
                <input type="button" value="Convert" id="convertButton" />
            </td>
            <td>
               <input type="text" readonly="readonly" id="outputText" size="10" />
            </td>
        </tr>
    </table>
    

    <script language="vbscript" type="text/vbscript">
    
    Option Explicit

    Sub convertButton_onclick
        Dim currentLocale, theDate, theCurr
        
        currentLocale = GetLocale
        
        if radioGroup(0).checked Then
            SetLocale(fromLocaleID.value)
            theDate = CDate(inputText.value)
            SetLocale(toLocaleID.value)
            outputText.value = FormatDateTime(theDate, vbShortDate)    
        Else
            SetLocale(fromLocaleID.value)
            theCurr = CCur(inputText.value)
            SetLocale(toLocaleID.value)
            outputText.value = FormatCurrency(theCurr)
        End If

        SetLocale (currentLocale)
    End Sub

    </script> 

</body>
</html>

See Also

Reference

SetLocale Function

Locale ID (LCID) Chart

Change History

Date

History

Reason

January 2010

Modified example.

Information enhancement.