GithubHelp home page GithubHelp logo

isabella232 / jibber_jabber Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cloudfoundry-attic/jibber_jabber

0.0 0.0 0.0 23 KB

Cross Platform locale detection for Golang

License: Apache License 2.0

Go 98.53% Batchfile 1.47%

jibber_jabber's Introduction

Jibber Jabber Build Status

Jibber Jabber is a GoLang Library that can be used to detect an operating system's current language.

OS Support

OSX and Linux via the LC_ALL and LANG environment variables. These are standard variables that are used in ALL versions of UNIX for language detection.

Windows via GetUserDefaultLocaleName and GetSystemDefaultLocaleName system calls. These calls are supported in Windows Vista and up.

Usage

Add the following line to your go import:

	"github.com/cloudfoundry/jibber_jabber"

DetectIETF

DetectIETF will return the current locale as a string. The format of the locale will be the ISO 639 two-letter language code, a DASH, then an ISO 3166 two-letter country code.

	userLocale, err := jibber_jabber.DetectIETF()
	println("Locale:", userLocale)

DetectLanguage

DetectLanguage will return the current languge as a string. The format will be the ISO 639 two-letter language code.

	userLanguage, err := jibber_jabber.DetectLanguage()
	println("Language:", userLanguage)

DetectTerritory

DetectTerritory will return the current locale territory as a string. The format will be the ISO 3166 two-letter country code.

	localeTerritory, err := jibber_jabber.DetectTerritory()
	println("Territory:", localeTerritory)

Errors

All the Detect commands will return an error if they are unable to read the Locale from the system.

For Windows, additional error information is provided due to the nature of the system call being used.

jibber_jabber's People

Contributors

lvarvel avatar tjarratt avatar drich10 avatar squeedee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.