summaryrefslogtreecommitdiff
path: root/vendor/github.com/jmshal/go-locale/detect_locale_windows.go
blob: 849928d0d50f1c6db7611f1a66786623f318f9da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package go_locale

import (
    "strings"
    "strconv"
)

func DetectLocale() (string, error) {
    out, err := getCommandOutput("wmic", "os", "get", "locale")
    if err != nil {
        return "", err
    }

    out = strings.Replace(out, "Locale", "", -1)
    out = strings.TrimSpace(out)

    id, err := strconv.ParseInt(out, 16, 64)
    if err != nil {
        return "", err
    }

    lcid := LCID()
    locale, err := lcid.ById(int(id))
    if err != nil {
        return "", err
    }

    return locale, nil
}