Skip to content

Latest commit

 

History

History
44 lines (34 loc) · 1.53 KB

README.md

File metadata and controls

44 lines (34 loc) · 1.53 KB

go-locales

Build Status codecov Go Report Card

Library to make GNU C Library Locales accessible in go.

go get github.com/nyaruka/go-locales

then

locales.Query("es_EC", locales.LC_TIME, "abday")                       // []string{"dom", ..., "sáb"}
locales.QueryString("fr_CA", locales.LC_NAME, "name_fmt")              // "%d%t%g%t%m%t%f"
locales.QueryInteger("zh_CN", locales.LC_MONETARY, "int_frac_digits")  // 2

locales.Codes()  // []string{"POSIX", "aa_DJ", "aa_ER", ... }

localesdump

This command line tool can be used to create JSON dumps of select locale data, e.g.

localesdump --pretty days=LC_TIME.day short_days=LC_TIME.abday

Extracts the given keywords from each locale and produces JSON like:

{
    "aa_DJ": {
        "days": ["Acaada", "Etleeni", "Talaata", "Arbaqa", "Kamiisi", "Gumqata", "Sabti"],
        "short_days": ["Aca", "Etl", "Tal", "Arb", "Kam", "Gum", "Sab"]
    },
    "aa_ER": {
        "days": ["Acaada", "Etleeni", "Talaata", "Arbaqa", "Kamiisi", "Gumqata", "Sabti"],
        "short_days": ["Aca", "Etl", "Tal", "Arb", "Kam", "Gum", "Sab"]
    },
    ...
}