display

package
v1.4.10-alpha2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2016 License: GPL-3.0, BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package display provides display names for languages, scripts and regions in a requested language.

The data is based on CLDR's localeDisplayNames. It includes the names of the draft level "contributed" or "approved". The resulting tables are quite large. The display package is designed so that users can reduce the linked-in table sizes by cherry picking the languages one wishes to support. There is a Dictionary defined for a selected set of common languages for this purpose.

Index

Constants

View Source
const CLDRVersion = "28"

CLDRVersion is the CLDR version from which the tables in this package are derived.

View Source
const Version = "28"

Version is deprecated. Use CLDRVersion.

Variables

View Source
var (
	// Supported lists the languages for which names are defined.
	Supported language.Coverage

	// The set of all possible values for which names are defined. Note that not
	// all Namer implementations will cover all the values of a given type.
	// A Namer will return the empty string for unsupported values.
	Values language.Coverage
)

Functions

This section is empty.

Types

type Dictionary

type Dictionary struct {
	// contains filtered or unexported fields
}

A Dictionary holds a collection of Namers for a single language. One can reduce the amount of data linked in to a binary by only referencing Dictionaries for the languages one needs to support instead of using the generic Namer factories.

var (
	Afrikaans            *Dictionary = &af        // af
	Amharic              *Dictionary = &am        // am
	Arabic               *Dictionary = &ar        // ar
	ModernStandardArabic *Dictionary = Arabic     // ar-001
	Azerbaijani          *Dictionary = &az        // az
	Bulgarian            *Dictionary = &bg        // bg
	Bengali              *Dictionary = &bn        // bn
	Catalan              *Dictionary = &ca        // ca
	Czech                *Dictionary = &cs        // cs
	Danish               *Dictionary = &da        // da
	German               *Dictionary = &de        // de
	Greek                *Dictionary = &el        // el
	English              *Dictionary = &en        // en
	AmericanEnglish      *Dictionary = English    // en-US
	BritishEnglish       *Dictionary = English    // en-GB
	Spanish              *Dictionary = &es        // es
	EuropeanSpanish      *Dictionary = Spanish    // es-ES
	LatinAmericanSpanish *Dictionary = Spanish    // es-419
	Estonian             *Dictionary = &et        // et
	Persian              *Dictionary = &fa        // fa
	Finnish              *Dictionary = &fi        // fi
	Filipino             *Dictionary = &fil       // fil
	French               *Dictionary = &fr        // fr
	Gujarati             *Dictionary = &gu        // gu
	Hebrew               *Dictionary = &he        // he
	Hindi                *Dictionary = &hi        // hi
	Croatian             *Dictionary = &hr        // hr
	Hungarian            *Dictionary = &hu        // hu
	Armenian             *Dictionary = &hy        // hy
	Indonesian           *Dictionary = &id        // id
	Icelandic            *Dictionary = &is        // is
	Italian              *Dictionary = &it        // it
	Japanese             *Dictionary = &ja        // ja
	Georgian             *Dictionary = &ka        // ka
	Kazakh               *Dictionary = &kk        // kk
	Khmer                *Dictionary = &km        // km
	Kannada              *Dictionary = &kn        // kn
	Korean               *Dictionary = &ko        // ko
	Kirghiz              *Dictionary = &ky        // ky
	Lao                  *Dictionary = &lo        // lo
	Lithuanian           *Dictionary = &lt        // lt
	Latvian              *Dictionary = &lv        // lv
	Macedonian           *Dictionary = &mk        // mk
	Malayalam            *Dictionary = &ml        // ml
	Mongolian            *Dictionary = &mn        // mn
	Marathi              *Dictionary = &mr        // mr
	Malay                *Dictionary = &ms        // ms
	Burmese              *Dictionary = &my        // my
	Nepali               *Dictionary = &ne        // ne
	Dutch                *Dictionary = &nl        // nl
	Norwegian            *Dictionary = &no        // no
	Punjabi              *Dictionary = &pa        // pa
	Polish               *Dictionary = &pl        // pl
	Portuguese           *Dictionary = &pt        // pt
	BrazilianPortuguese  *Dictionary = Portuguese // pt-BR
	EuropeanPortuguese   *Dictionary = &ptPT      // pt-PT
	Romanian             *Dictionary = &ro        // ro
	Russian              *Dictionary = &ru        // ru
	Sinhala              *Dictionary = &si        // si
	Slovak               *Dictionary = &sk        // sk
	Slovenian            *Dictionary = &sl        // sl
	Albanian             *Dictionary = &sq        // sq
	Serbian              *Dictionary = &sr        // sr
	SerbianLatin         *Dictionary = &srLatn    // sr
	Swedish              *Dictionary = &sv        // sv
	Swahili              *Dictionary = &sw        // sw
	Tamil                *Dictionary = &ta        // ta
	Telugu               *Dictionary = &te        // te
	Thai                 *Dictionary = &th        // th
	Turkish              *Dictionary = &tr        // tr
	Ukrainian            *Dictionary = &uk        // uk
	Urdu                 *Dictionary = &ur        // ur
	Uzbek                *Dictionary = &uz        // uz
	Vietnamese           *Dictionary = &vi        // vi
	Chinese              *Dictionary = &zh        // zh
	SimplifiedChinese    *Dictionary = Chinese    // zh-Hans
	TraditionalChinese   *Dictionary = &zhHant    // zh-Hant
	Zulu                 *Dictionary = &zu        // zu
)

func (*Dictionary) Languages

func (d *Dictionary) Languages() Namer

Languages returns a Namer for naming languages. It returns nil if there is no data for the given tag. The type passed to Name must be either language.Base or language.Tag. Note that the result may differ between passing a tag or its base language. For example, for English, passing "nl-BE" would return Flemish whereas passing "nl" returns "Dutch".

func (*Dictionary) Regions

func (d *Dictionary) Regions() Namer

Regions returns a Namer for naming regions. It returns nil if there is no data for the given tag. The type passed to Name must be either a language.Region or a language.Tag. It will not attempt to infer a region for tags with an unspecified region.

func (*Dictionary) Scripts

func (d *Dictionary) Scripts() Namer

Scripts returns a Namer for naming scripts. It returns nil if there is no data for the given tag. The type passed to Name must be either a language.Script or a language.Tag. It will not attempt to infer a script for tags with an unspecified script.

func (*Dictionary) Tags

func (d *Dictionary) Tags() Namer

Tags returns a Namer for giving a full description of a tag. The names of scripts and regions that are not already implied by the language name will in appended within parentheses. It returns nil if there is not data for the given tag. The type passed to Name must be a tag.

type Namer

type Namer interface {
	// Name returns a display string for the given value. A Namer returns an
	// empty string for values it does not support. A Namer may support naming
	// an unspecified value. For example, when getting the name for a region for
	// a tag that does not have a defined Region, it may return the name for an
	// unknown region. It is up to the user to filter calls to Name for values
	// for which one does not want to have a name string.
	Name(x interface{}) string
}

A Namer is used to get the name for a given value, such as a Tag, Language, Script or Region.

func Languages

func Languages(t language.Tag) Namer

Languages returns a Namer for naming languages. It returns nil if there is no data for the given tag. The type passed to Name must be either language.Base or language.Tag. Note that the result may differ between passing a tag or its base language. For example, for English, passing "nl-BE" would return Flemish whereas passing "nl" returns "Dutch".

func Regions

func Regions(t language.Tag) Namer

Regions returns a Namer for naming regions. It returns nil if there is no data for the given tag. The type passed to Name must be either a language.Region or a language.Tag. It will not attempt to infer a region for tags with an unspecified region.

func Scripts

func Scripts(t language.Tag) Namer

Scripts returns a Namer for naming scripts. It returns nil if there is no data for the given tag. The type passed to Name must be either a language.Script or a language.Tag. It will not attempt to infer a script for tags with an unspecified script.

func Tags

func Tags(t language.Tag) Namer

Tags returns a Namer for giving a full description of a tag. The names of scripts and regions that are not already implied by the language name will in appended within parentheses. It returns nil if there is not data for the given tag. The type passed to Name must be a tag.

type SelfNamer

type SelfNamer struct {
	// Supported defines the values supported by this Namer.
	Supported language.Coverage
}

A SelfNamer implements a Namer that returns the name of language in this same language. It provides a very compact mechanism to provide a comprehensive list of languages to users in their native language.

var (
	// Self is a shared instance of a SelfNamer.
	Self *SelfNamer = &self
)

func (SelfNamer) Name

func (n SelfNamer) Name(x interface{}) string

Name returns the name of a given language tag in the language identified by this tag. It supports both the language.Base and language.Tag types.

Jump to

Keyboard shortcuts

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