locale

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package locale is the table of spreadsheet locales, as Sheets' File > Settings > Locale offers them: how numbers, dates and currency are typed and shown, and how formulas separate their arguments. It holds only the conventions, with no dependencies (no CLDR data): the packages that parse and render use them at their edges, while cells, formulas and files stay in the canonical form of en-US.

Index

Constants

This section is empty.

Variables

View Source
var Canonical = &table[0]

Canonical is en-US: what cells, formulas and files store, whatever the locale shown.

View Source
var English = &Names{
	Months: [12]string{"January", "February", "March", "April", "May", "June", "July",
		"August", "September", "October", "November", "December"},
	Short:     [12]string{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"},
	Days:      [7]string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"},
	DaysShort: [7]string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"},
}

English are en-US's names, which every English locale shares.

Functions

func FromPOSIX

func FromPOSIX(v string) string

FromPOSIX reads a POSIX locale, as LANG and LC_ALL hold it ("de_DE.UTF-8", "fr_FR@euro"), returning the tag of the locale in the table it names. C, POSIX and locales outside the table give "".

func Tags

func Tags() []string

Tags are the tags of every locale, in the table's order.

Types

type DateOrder

type DateOrder uint8

DateOrder is the order of day, month and year in a date typed or shown with numbers only.

const (
	MDY DateOrder = iota // 9/26/2026
	DMY                  // 26.09.2026
	YMD                  // 2026-09-26
)

func (DateOrder) String

func (o DateOrder) String() string

type Locale

type Locale struct {
	Tag  string // BCP 47, as written in files and the config: "de-DE"
	Name string // as the picker lists it: "German (Germany)"
	// LCID is Windows' number for the locale, which Excel's format
	// codes name it by: [$€-407], [$-407]d.m.yyyy.
	LCID uint16

	Decimal byte   // the decimal separator: '.' or ','
	Group   string // the thousands separator shown: ",", ".", a no-break space, an apostrophe

	Order   DateOrder
	DateSep byte   // between the numbers of a date: '/', '.' or '-'
	Date    string // the Date format's pattern: "dd.mm.yyyy"
	Time    string // the Time format's pattern: "hh:mm:ss"

	Currency string // the currency symbol: "€"
	After    bool   // the symbol follows the number: "1.234,56 €"
	Space    bool   // a space between the symbol and the number: "R$ 1.234,56"
	// contains filtered or unexported fields
}

Locale is one locale's conventions.

func All

func All() []*Locale

All returns every locale, en-US first, then as the table lists them.

func ByLCID

func ByLCID(id uint16) (*Locale, bool)

ByLCID finds a locale by its Windows number, as Excel's format codes write it.

func Lookup

func Lookup(tag string) (*Locale, bool)

Lookup finds a locale by its tag, ignoring case and taking _ for -, so "de-DE", "de_de" and "DE-de" are the same. A language alone ("de") means its first locale in the table.

func (*Locale) ArgSep

func (l *Locale) ArgSep() byte

ArgSep separates a formula's arguments: ; where the decimal separator is a comma, as in Sheets, so 1,5 stays a number.

func (*Locale) ColSep

func (l *Locale) ColSep() byte

ColSep separates the values of a row in an array literal: \ where the argument separator is ;, which also separates an array's rows.

func (*Locale) DateTime

func (l *Locale) DateTime() string

DateTime is the Date time format's pattern: the date, then the time on the 24-hour clock, as Sheets shows it in every locale.

func (*Locale) IsCanonical

func (l *Locale) IsCanonical() bool

IsCanonical reports whether l types and shows everything as stored: en-US, or nil.

func (*Locale) IsGroup

func (l *Locale) IsGroup(r rune) bool

IsGroup reports whether r separates thousands in l as typed: its own separator, any space where it groups with a space, and ' for ’.

func (*Locale) Names

func (l *Locale) Names() *Names

Names are the locale's names of months and days, in its language; English for a nil locale.

func (*Locale) Or

func (l *Locale) Or() *Locale

Or returns l, or the canonical locale when l is nil.

type Names

type Names struct {
	// Months are the months' full names as a date writes them, January
	// first: "września" in "26 września 2026".
	Months [12]string
	// Alone are the full names where a month stands without its day
	// ("wrzesień 2026"), in languages whose form differs; empty where
	// it's Months.
	Alone [12]string
	// Short are the abbreviations mmm shows: "Sep", "sept.", "9月".
	Short [12]string
	// Days are the days' full names, Sunday first; DaysShort their
	// abbreviations, as ddd shows them.
	Days, DaysShort [7]string
	// AM and PM are what AM/PM shows, where the language has words of
	// its own; empty keeps AM and PM.
	AM, PM string
}

Names are a language's names of months and days, as date formats show them (mmm, mmmm, ddd, dddd) and typed dates may spell them, and its words for the two halves of a 12-hour clock.

func (*Names) Month

func (n *Names) Month(m int, alone bool) string

Month is month m's (1 to 12) full name, standing alone or in a date with its day.

Jump to

Keyboard shortcuts

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