locales

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Fields = map[FieldType]Field{
	Era: Field{
		CldrNode: "eras",
		Widths: map[Width]string{
			Wide:        "eraNames",
			Narrow:      "eraNarrow",
			Abbreviated: "eraAbbr",
		},
		Keys: []string{"0", "1"},
	},
	Quarter: Field{
		CldrNode: "quarters",
		Widths: map[Width]string{
			Wide:                  "format.wide",
			Narrow:                "format.narrow",
			Abbreviated:           "format.abbreviated",
			WideStandalone:        "stand-alone.wide",
			NarrowStandalone:      "stand-alone.narrow",
			AbbreviatedStandalone: "stand-alone.abbreviated",
		},
		Keys: []string{"1", "2", "3", "4"},
	},
	Month: Field{
		CldrNode: "months",
		Widths: map[Width]string{
			Wide:                  "format.wide",
			Narrow:                "format.narrow",
			Abbreviated:           "format.abbreviated",
			WideStandalone:        "stand-alone.wide",
			NarrowStandalone:      "stand-alone.narrow",
			AbbreviatedStandalone: "stand-alone.abbreviated",
		},
		Keys: []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"},
	},
	Day: Field{
		CldrNode: "days",
		Widths: map[Width]string{
			Wide:                  "format.wide",
			Narrow:                "format.narrow",
			Abbreviated:           "format.abbreviated",
			Short:                 "format.short",
			WideStandalone:        "stand-alone.wide",
			NarrowStandalone:      "stand-alone.narrow",
			AbbreviatedStandalone: "stand-alone.abbreviated",
			ShortStandalone:       "stand-alone.short",
		},
		Keys: []string{"sun", "mon", "tue", "wed", "thu", "fri", "sat"},
	},
	DayPeriod: Field{
		CldrNode: "dayPeriods",
		Widths: map[Width]string{
			Wide:                  "format.wide",
			Narrow:                "format.narrow",
			Abbreviated:           "format.abbreviated",
			WideStandalone:        "stand-alone.wide",
			NarrowStandalone:      "stand-alone.narrow",
			AbbreviatedStandalone: "stand-alone.abbreviated",
		},
		Keys: []string{"am", "pm", "morning1", "noon", "afternoon1", "evening1", "midnight", "night1"},
	},
}

Fields gets all fields with infos

Functions

func Localize

func Localize(lang string, field FieldType, width Width, value int) string

Localize a field value

Types

type Field

type Field struct {
	CldrNode string
	Widths   map[Width]string
	Keys     []string
}

Field describe a date field in cldr https://github.com/unicode-cldr/cldr-dates-full/tree/master/main

func (Field) Key

func (f Field) Key(width Width, value int) (string, bool)

type FieldType

type FieldType uint8

FieldType describes a type of field

const (
	Era FieldType = iota
	Quarter
	Month
	Day
	DayPeriod
)

type Width

type Width uint8

Width

const (
	Abbreviated Width = iota // Len = 3
	AbbreviatedStandalone
	Wide // Len = 4
	WideStandalone
	Narrow // Len = 5
	NarrowStandalone
	Short // Len = 6
	ShortStandalone
)

Jump to

Keyboard shortcuts

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