Documentation
¶
Overview ¶
Package glibclocale reads glibc's compiled locale data in pure Go: the locale-archive and the per-locale directories localedef writes, laid out as glibc's locarchive.h and loadlocale.c read them. It lists the locales a system has, as locale -a does, and reads a locale's LC_NUMERIC, LC_MONETARY and LC_TIME, the last with a strftime over its names and formats.
A locale is found as glibc finds it: with LOCPATH set, only in its directories; otherwise in the archive and then in /usr/lib/locale. A name's codeset is normalized first, so en_US.UTF-8 finds en_US.utf8. Unlike glibc, a name that is not there is an error naming every place searched, never the C locale or a shorter name such as en_US or en. glibc's locale.alias names are not resolved.
musl ships no compiled locale data: there Source.List finds only C and POSIX, and loading any other locale is that error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoLocale = errors.New("glibclocale: no locale")
ErrNoLocale is the error a source gives for a locale it does not hold.
Functions ¶
Types ¶
type Monetary ¶
type Monetary struct {
// contains filtered or unexported fields
}
Monetary is a locale's LC_MONETARY: how it writes an amount of money.
func (Monetary) Format ¶
Format writes an amount of money as Numeric.Format writes a number, with the locale's monetary separators and grouping and its currency symbol before, after or in place of the decimal point. An empty monetary decimal point is numeric's, as glibc's strfmon takes it.
type Numeric ¶
type Numeric struct {
// contains filtered or unexported fields
}
Numeric is a locale's LC_NUMERIC: how it writes a number.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source is where locale data is read from: a locale-archive, and directories holding a directory per locale.
func NewSource ¶
NewSource reads the locale-archive at archive, "" for none, and then the locale directories under dirs, in order.
func System ¶
System is where glibc reads locale data in env: the directories in LOCPATH when it is set; otherwise the archive at $LOCALE_ARCHIVE_2_27 or $LOCALE_ARCHIVE, the variables NixOS's glibc reads, or /usr/lib/locale/locale-archive, and then /usr/lib/locale.
func (Source) Installed ¶
Installed reports what glibc's newlocale(LC_CTYPE_MASK, name) would: whether the source holds name's LC_CTYPE. C and POSIX are always installed. A locale that is there but unreadable, or lacks an LC_CTYPE, is an error.
func (Source) List ¶
List is the locales the source has, sorted, as locale -a names them: C and POSIX, the archive's names and every directory that holds an LC_IDENTIFICATION. A missing archive or directory adds nothing; one that cannot be read is an error.
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
Time is a locale's LC_TIME: its names of days and months and its date and time formats, which Time.Format writes.
func (*Time) Format ¶
Format writes at as glibc's strftime writes format in this locale. It implements the conversions glibc's locales use in their own formats: %a %A %b %B %c %C %d %e %F %H %I %k %l %m %M %p %P %r %R %S %T %x %X %y %Y %z %Z and %%, the - flag, %Ey for the era's year and the O modifier for the locale's alternative digits. %P lowercases ASCII letters only, as glibc does in a UTF-8 locale. A conversion glibc does not know is copied as it stands, as glibc copies it; one glibc knows but Format does not implement, another flag or a field width is an error naming it.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package glibclocaletest holds glibc compiled locale data for tests, as glibc 2.44's localedef wrote it: the LC_IDENTIFICATION, LC_MONETARY, LC_NUMERIC and LC_TIME of de_DE.utf8, en_GB.utf8, en_US.utf8, fa_IR.utf8 and th_TH.utf8, as locale directories and as a locale-archive holding the same five locales.
|
Package glibclocaletest holds glibc compiled locale data for tests, as glibc 2.44's localedef wrote it: the LC_IDENTIFICATION, LC_MONETARY, LC_NUMERIC and LC_TIME of de_DE.utf8, en_GB.utf8, en_US.utf8, fa_IR.utf8 and th_TH.utf8, as locale directories and as a locale-archive holding the same five locales. |