Skip to content

Library to make GNU C Library Locales accessible in go.

License

Notifications You must be signed in to change notification settings

nyaruka/go-locales

Repository files navigation

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"]
    },
    ...
}

About

Library to make GNU C Library Locales accessible in go.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages