cldrlocale

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Source: CLDR v48.1.0 / ICU 78 / tzdata 2025b (input hashes in internal/cldr/locale/manifest.go) Generated: reproducible from tools/gen-cldr with pinned inputs; no timestamps or machine-local paths Schema: SPECS/50-cldr-data.md#cldr-data-package-convention

Package cldrlocale exposes generated CLDR locale metadata.

It keeps likely subtags, locale preferences, numbering systems, collation names, and time-zone preferences behind typed accessors.

Only internal CLDR and locale negotiation code should use this package; public callers use locale and formatter APIs.

Source: CLDR v48.1.0 / ICU 78 / tzdata 2025b (input hashes in internal/cldr/locale/manifest.go) Generated: reproducible from tools/gen-cldr with pinned inputs; no timestamps or machine-local paths Schema: SPECS/50-cldr-data.md#cldr-data-package-convention

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableLocales

func AvailableLocales() []string

AvailableLocales returns the kernel's available locale tags in sorted order (Locale index = position, "und" pinned at 0).

func CalendarPreference

func CalendarPreference(region string) []string

CalendarPreference returns the region's calendar preference list, falling back to the world ("001") default.

func FirstDayOfWeek

func FirstDayOfWeek(region string) time.Weekday

FirstDayOfWeek returns the region's first day of the week.

func HasCalendarPreference

func HasCalendarPreference(region string) bool

HasCalendarPreference reports whether the region has an explicit calendar preference.

func HasHourCyclePreference

func HasHourCyclePreference(region string) bool

HasHourCyclePreference reports whether the region has an explicit hour-cycle preference.

func HasWeekPreference

func HasWeekPreference(region string) bool

HasWeekPreference reports whether the region has explicit week data.

func HourCyclePreference

func HourCyclePreference(region string) []string

HourCyclePreference returns the region's hour-cycle preference list, falling back to the world ("001") default.

func IntersectSupportedLocales added in v0.2.9

func IntersectSupportedLocales(primary []string, required ...[]string) []string

IntersectSupportedLocales returns primary locales supported by every required locale list. It preserves primary order and returns a new slice.

func Maximize

func Maximize(tag string) string

Maximize adds likely subtags to tag using the kernel maximize data.

func MaximizeSubtags

func MaximizeSubtags(language, script, region string) (lang, scr, reg string, ok bool)

MaximizeSubtags applies the CLDR Add Likely Subtags fallback order and preserves subtags already supplied by the caller.

func MinimalDaysInFirstWeek

func MinimalDaysInFirstWeek(region string) int

MinimalDaysInFirstWeek returns the region's minimal-days-in-first-week value.

func MinimizeSubtags

func MinimizeSubtags(language, script, region string) (lang, scr, reg string, ok bool)

MinimizeSubtags returns the minimized tag for the input subtags, or ok=false when the (language, script, region) triple is absent from the minimize table.

func TextDirection added in v0.2.16

func TextDirection(script string) (direction string, ok bool)

TextDirection returns the CLDR direction for script. Unknown or missing script metadata returns ok=false.

func Weekend

func Weekend(region string) (start, end time.Weekday)

Weekend returns the region's weekend start and end days.

Types

type DataManifest added in v0.2.7

type DataManifest struct {
	Generator     string
	CLDR          string
	ICU           string
	TZData        string
	LocaleProfile []string
	InputHashes   []InputHash
}

func Manifest added in v0.2.7

func Manifest() DataManifest

type InputHash added in v0.2.7

type InputHash struct {
	Name   string
	SHA256 string
}

type Locale

type Locale uint16

Locale is an opaque handle into the generated CLDR locale data.

const Undefined Locale = 0

Undefined is the "und" sentinel locale.

func ResolveLocale

func ResolveLocale(tag string) (Locale, bool)

ResolveLocale resolves a tag to its kernel Locale handle, falling back to the base language subtag, or (Undefined, false) when neither is known.

func (Locale) DefaultNumberingSystem

func (l Locale) DefaultNumberingSystem() string

DefaultNumberingSystem returns the default numbering system for the locale, defaulting to "latn" for any locale without a non-latn override.

type VersionInfo added in v0.2.7

type VersionInfo struct {
	CLDR   string
	ICU    string
	TZData string
}

VersionInfo carries the CLDR / ICU / tzdata versions pinned in internal/cldr/VERSION at codegen time.

func Version added in v0.2.7

func Version() VersionInfo

Version returns the pinned data versions, sourced from the generated manifest.

Jump to

Keyboard shortcuts

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