sysloc

package module
v0.0.0-...-f54bff9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2019 License: MIT Imports: 7 Imported by: 0

README

Sysloc

GoDoc

Sysloc is a Go package for getting OS locale. It's inspired by jmshal/go-locale, which in turn inspired by sindresorhus/os-locale. The differences are :

  • Uses go module.
  • No more underscore in package name.
  • For Mac OS we simply use $LANG environment variable.

Usage Examples

Says we want to get the locale that used by system :

package main

import (
	"fmt"

	"github.com/RadhiFadlillah/sysloc"
	"golang.org/x/text/language/display"
)

func main() {
	locale, err := sysloc.GetLocale()
	if err != nil {
		panic(err)
	}

	fmt.Printf("System locale is %s (%s)\n",
		display.Self.Name(locale),
		locale,
	)
}

Which will give us following results :

System locale is American English (en-US)

License

Sysloc is distributed using MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocale

func GetLocale() (language.Tag, error)

GetLocale get current locale that used by system

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL