Home
Softono

Go Locale

Open source Apache-2.0 Go
117
Stars
9
Forks
2
Issues
2
Watchers
5 months
Last Commit

 About Go Locale

Cross platform locale detection for Golang

Platforms

Web Self-hosted

Languages

Go

Links

Need Help Installing Go Locale?

We provide expert installation service for this software. Our team will install, configure, and secure Go Locale on your server. plans start at just $30.

go-locale

Build Status Go Doc Go Ver License Discord

go-locale is a Golang lib for cross-platform locale detection.

OS Support

Support all OS that Golang supported, except android:

POSIX Compatible Systems

  • Lookup env LANGUAGE
  • Lookup env LC_ALL
  • Lookup env LC_MESSAGES
  • Lookup env LANG
  • Read file $XDG_CONFIG_HOME/locale.conf
  • Read file $HOME/.config/locale.conf
  • Read file /etc/locale.conf

Js

  • Lookup env LANGUAGE
  • Lookup env LC_ALL

Windows

  • Lookup env LANGUAGE
  • Lookup env LC_ALL
  • Lookup env LC_MESSAGES
  • Lookup env LANG
  • Windows Registry

macOS X (darwin)

  • Lookup env LANGUAGE
  • Lookup env LC_ALL
  • Lookup env LC_MESSAGES
  • Lookup env LANG
  • macOS X User Defaults System
    • Lookup user AppleLocale
    • Lookup user AppleLanguages
    • Lookup global AppleLocale
    • Lookup global AppleLanguages

Usage

import (
    "github.com/Xuanwo/go-locale"
)

func main() {
    tag, err := locale.Detect()
    if err != nil {
        log.Fatal(err)
    }
    // Have fun with language.Tag!

    tags, err := locale.DetectAll()
    if err != nil {
        log.Fatal(err)
    }
    // Get all available tags
}

Acknowledgments

Inspired by jibber_jabber