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
- func FormatDate(locale string, t time.Time, o DateOptions) string
- func LikelyRegion(lang, script string) string
- func LikelyScript(lang, region string) string
- func MatchCatalog(langs []string, locale string) string
- func ParentLocale(lang string) string
- func Pattern(locale string, o DateOptions) string
- func Pseudolocalize(tag, s string) string
- type DateOptions
- type Regional
- type Style
- type Tag
Constants ¶
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.
const ( ArgStart = "" ArgEnd = "" )
Marks around what an argument wrote in a message Pseudolocalize transforms: private use characters, which messages do not hold.
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 LikelyRegion ¶
LikelyRegion returns CLDR's likely region for lang and script.
func LikelyScript ¶
LikelyScript returns CLDR's likely script for lang and optional region.
func MatchCatalog ¶
MatchCatalog selects the best supported language in langs for locale, or langs[0] when no supported language matches with high confidence.
func ParentLocale ¶
ParentLocale returns the CLDR parent locale of lang, or "" after the base language (or a non-default script root such as zh-Hant).
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 ¶
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 ¶
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 ¶
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 Tag ¶
Tag is a parsed BCP 47 language tag (language, optional script and region, and optional -u- Unicode extension key-value pairs).
func ParseTag ¶
ParseTag parses a BCP 47 tag (accepting '_' or '-' separators). It returns ok=false for empty or malformed tags.
func (Tag) CanonicalRegion ¶
CanonicalRegion returns t.Region if present, else CLDR's likely region for t.Lang and script.
func (Tag) CanonicalScript ¶
CanonicalScript returns t.Script if present, else CLDR's likely script for t.Lang and t.Region.
func (Tag) TypeForKey ¶
TypeForKey returns the value of Unicode extension key k (e.g. "hc", "fw").
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. |