cldr

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 9 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 cldr formats dates and times by the Unicode CLDR's data, as ICU and Intl write them, and transforms messages for the pseudo locales, for package i18n. tables.go holds the data of the locales of CLDR's modern coverage, generated from a pinned release of cldr-json by go generate (internal/gen).

Index

Constants

View Source
const (
	PseudoAccents = "en-XA"
	PseudoBidi    = "ar-XB"
)

The pseudo locales, after Android's: en-XA accents and lengthens the source language's messages, ar-XB shows them right to left.

View Source
const (
	ArgStart = ""
	ArgEnd   = ""
)

Marks around what an argument wrote in a message Pseudolocalize transforms: private use characters, which messages do not hold.

View Source
const Version = "48.2.0"

Version is the release of the Unicode CLDR the tables come from.

Variables

This section is empty.

Functions

func FormatDate

func FormatDate(locale string, t time.Time, o DateOptions) string

FormatDate writes t, in its location, in the Gregorian calendar, in the way of locale: its patterns, names and digits. Time zones are written as offsets from GMT in the locale's format.

func Pattern

func Pattern(locale string, o DateOptions) string

Pattern returns the CLDR pattern FormatDate writes for locale and o, as "MMM d, y".

func Pseudolocalize

func Pseudolocalize(tag, s string) string

Pseudolocalize transforms s, a message in the source language whose arguments' text is between ArgStart and ArgEnd, as the pseudo locale tag shows it, keeping what the arguments wrote. Any other tag only drops the marks.

Types

type DateOptions

type DateOptions struct {
	Date, Time Style
	Skeleton   string
}

DateOptions are how FormatDate writes a time: its date, its time or both by style, or else the fields of Skeleton, CLDR's letters in any order ("yMMMd", "jm"), in the order and form the locale writes them. Neither is "yMd".

type Regional

type Regional struct {
	FirstDayOfWeek    int
	HourCycle         string
	MeasurementSystem string
	TemperatureUnit   string
}

Regional is how a locale's region reads weeks, times and measures, as CLDR 48's supplemental data has it, Intl's names for its values: FirstDayOfWeek 1 for Monday to 7 for Sunday (ISO 8601), HourCycle "h11", "h12", "h23" or "h24", MeasurementSystem "metric", "us" or "uk", TemperatureUnit "celsius" or "fahrenheit".

func RegionalOf

func RegionalOf(locale string) Regional

RegionalOf is locale's regional preferences: what its Unicode extension sets (-u-fw-, -u-hc-, -u-ms-, -u-mu-), else its region's, likely or given, else its language's hours.

type Style

type Style uint8

Style is the length of a date or a time as CLDR's patterns write it.

const (
	NoStyle Style = iota
	ShortStyle
	MediumStyle
	LongStyle
	FullStyle
)

Directories

Path Synopsis
internal
gen command
Command gen writes tables.go, the data of the Unicode CLDR package cldr formats dates with, from a pinned release of cldr-json: go generate ./internal/cldr runs it.
Command gen writes tables.go, the data of the Unicode CLDR package cldr formats dates with, from a pinned release of cldr-json: go generate ./internal/cldr runs it.

Jump to

Keyboard shortcuts

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