Command line client for Write.as https://write.as/apps/cli
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Jibber Jabber [![Build Status](https://travis-ci.org/cloudfoundry/jibber_jabber.svg?branch=master)](https://travis-ci.org/cloudfoundry/jibber_jabber)
  2. Jibber Jabber is a GoLang Library that can be used to detect an operating system's current language.
  3. ### OS Support
  4. 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.
  5. Windows via [GetUserDefaultLocaleName](http://msdn.microsoft.com/en-us/library/windows/desktop/dd318136.aspx) and [GetSystemDefaultLocaleName](http://msdn.microsoft.com/en-us/library/windows/desktop/dd318122.aspx) system calls. These calls are supported in Windows Vista and up.
  6. # Usage
  7. Add the following line to your go `import`:
  8. ```
  9. "github.com/cloudfoundry/jibber_jabber"
  10. ```
  11. ### DetectIETF
  12. `DetectIETF` will return the current locale as a string. The format of the locale will be the [ISO 639](http://en.wikipedia.org/wiki/ISO_639) two-letter language code, a DASH, then an [ISO 3166](http://en.wikipedia.org/wiki/ISO_3166-1) two-letter country code.
  13. ```
  14. userLocale, err := jibber_jabber.DetectIETF()
  15. println("Locale:", userLocale)
  16. ```
  17. ### DetectLanguage
  18. `DetectLanguage` will return the current languge as a string. The format will be the [ISO 639](http://en.wikipedia.org/wiki/ISO_639) two-letter language code.
  19. ```
  20. userLanguage, err := jibber_jabber.DetectLanguage()
  21. println("Language:", userLanguage)
  22. ```
  23. ### DetectTerritory
  24. `DetectTerritory` will return the current locale territory as a string. The format will be the [ISO 3166](http://en.wikipedia.org/wiki/ISO_3166-1) two-letter country code.
  25. ```
  26. localeTerritory, err := jibber_jabber.DetectTerritory()
  27. println("Territory:", localeTerritory)
  28. ```
  29. ### Errors
  30. All the Detect commands will return an error if they are unable to read the Locale from the system.
  31. For Windows, additional error information is provided due to the nature of the system call being used.