forked from theplant/cldr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
locale.go
137 lines (114 loc) · 3.75 KB
/
locale.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//go:generate go run ./cmd/make_resources
package cldr
import "golang.org/x/text/feature/plural"
//Languages maps a language code to the localized name of that language
type Languages map[string]string
//Territories maps a territory code to the localized name of the territory
type Territories map[string]string
//Locale has all the relevant information from the CLDR for a locale
type Locale struct {
Locale string
Number Number
Calendar Calendar
Plural Plural
Languages Languages
Territories Territories
Display LocaleDisplayPattern
}
//LocaleDisplayPattern indicates how to display locales, e.g. Language (Region), using placeholders {0} ({1})
type LocaleDisplayPattern struct {
Pattern string
Separator string
KeyTypePattern string
}
//Plural contains both cardinal and ordinal plural data from the CLDR
type Plural struct {
Cardinal PluralData
Ordinal PluralData
}
//PluralData contains information about the plural forms for the locale and how to get plural operators
type PluralData struct {
Forms []plural.Form
Func func(ops *PluralOperands) plural.Form
}
//Currencies maps a currency code (e.g. "USD") to a Currency
type Currencies map[string]Currency
//Number contains information required for locale-specific number formatting
type Number struct {
Symbols Symbols
Formats NumberFormats
Currencies Currencies
}
//Symbols has the various CLDR symbols for the locale
type Symbols struct {
Decimal string
Group string
Negative string
Percent string
PerMille string
}
//NumberFormats contains the different format strings from the CLDR
type NumberFormats struct {
Decimal string
Currency string
CurrencyAccounting string
Percent string
}
//Currency has the basic currency information
type Currency struct {
DisplayName string
Symbol string
}
//Calendar is populated with the CLDR calendar data
type Calendar struct {
Formats CalendarFormats
FormatNames CalendarFormatNames
}
//CalendarFormats is populated with the CLDR calendar data
type CalendarFormats struct {
Date CalendarDateFormat
Time CalendarDateFormat
DateTime CalendarDateFormat
GMT string
}
//CalendarDateFormat holds different date format strings
type CalendarDateFormat struct{ Full, Long, Medium, Short string }
//CalendarFormatNames contains various data related to localized names for calendar items
type CalendarFormatNames struct {
Months CalendarMonthFormatNames
Days CalendarDayFormatNames
Periods CalendarPeriodFormatNames
}
//CalendarMonthFormatNames is the different forms of months
type CalendarMonthFormatNames struct {
Abbreviated CalendarMonthFormatNameValue
Narrow CalendarMonthFormatNameValue
Short CalendarMonthFormatNameValue
Wide CalendarMonthFormatNameValue
}
//CalendarMonthFormatNameValue has a localized string for each month
type CalendarMonthFormatNameValue struct {
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec string
}
//CalendarDayFormatNames is the different forms of days
type CalendarDayFormatNames struct {
Abbreviated CalendarDayFormatNameValue
Narrow CalendarDayFormatNameValue
Short CalendarDayFormatNameValue
Wide CalendarDayFormatNameValue
}
//CalendarDayFormatNameValue has a localized string for each day of the week
type CalendarDayFormatNameValue struct {
Sun, Mon, Tue, Wed, Thu, Fri, Sat string
}
//CalendarPeriodFormatNames are the different forms of time periods
type CalendarPeriodFormatNames struct {
Abbreviated CalendarPeriodFormatNameValue
Narrow CalendarPeriodFormatNameValue
Short CalendarPeriodFormatNameValue
Wide CalendarPeriodFormatNameValue
}
//CalendarPeriodFormatNameValue has a localized string for each time period
type CalendarPeriodFormatNameValue struct {
AM, PM string
}