Skip to content

Xuanwo/go-locale

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

go-locale

Build Status Go Doc License go locale

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