8 "github.com/go-playground/locales"
9 "github.com/go-playground/locales/currency"
14 pluralsCardinal []locales.PluralRule
15 pluralsOrdinal []locales.PluralRule
16 pluralsRange []locales.PluralRule
25 currencies []string // idx = enum of currency code
26 currencyPositiveSuffix string
27 currencyNegativeSuffix string
28 monthsAbbreviated []string
31 daysAbbreviated []string
35 periodsAbbreviated []string
36 periodsNarrow []string
39 erasAbbreviated []string
42 timezones map[string]string
45 // New returns a new instance of translator for the 'da_GL' locale
46 func New() locales.Translator {
49 pluralsCardinal: []locales.PluralRule{2, 6},
50 pluralsOrdinal: []locales.PluralRule{6},
51 pluralsRange: []locales.PluralRule{2, 6},
59 currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
61 currencyPositiveSuffix: " ",
62 currencyNegativeSuffix: " ",
63 monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "maj", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec."},
64 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
65 monthsWide: []string{"", "januar", "februar", "marts", "april", "maj", "juni", "juli", "august", "september", "oktober", "november", "december"},
66 daysAbbreviated: []string{"søn.", "man.", "tir.", "ons.", "tor.", "fre.", "lør."},
67 daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"},
68 daysShort: []string{"sø", "ma", "ti", "on", "to", "fr", "lø"},
69 daysWide: []string{"søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag"},
70 periodsAbbreviated: []string{"AM", "PM"},
71 periodsNarrow: []string{"a", "p"},
72 periodsWide: []string{"AM", "PM"},
73 erasAbbreviated: []string{"f.Kr.", "e.Kr."},
74 erasNarrow: []string{"fKr", "eKr"},
75 erasWide: []string{"f.Kr.", "e.Kr."},
76 timezones: map[string]string{"PDT": "Pacific-sommertid", "BOT": "Boliviansk tid", "SRT": "Surinam-tid", "WEZ": "Vesteuropæisk normaltid", "HEPM": "Saint Pierre- og Miquelon-sommertid", "ART": "Argentinsk normaltid", "IST": "Indisk normaltid", "AEST": "Østaustralsk normaltid", "SAST": "Sydafrikansk tid", "HKT": "Hongkong-normaltid", "ACWST": "Vestlig centralaustralsk normaltid", "MYT": "Malaysisk tid", "UYT": "Uruguayansk normaltid", "HENOMX": "Nordvestmexicansk sommertid", "EST": "Eastern-normaltid", "AKST": "Alaska-normaltid", "ACDT": "Centralaustralsk sommertid", "ChST": "Chamorro-tid", "CDT": "Central-sommertid", "MDT": "Macao-sommertid", "ECT": "Ecuadoriansk tid", "HADT": "Hawaii-Aleutian-sommertid", "TMST": "Turkmensk sommertid", "SGT": "Singaporeansk normaltid", "∅∅∅": "Peruviansk sommertid", "WIB": "Vestindonesisk tid", "AWST": "Vestaustralsk normaltid", "WART": "Vestargentinsk normaltid", "AKDT": "Alaska-sommertid", "HAT": "Newfoundlandsk sommertid", "ACST": "Centralaustralsk normaltid", "CHADT": "Chatham-sommertid", "JDT": "Japansk sommertid", "AEDT": "Østaustralsk sommertid", "HNOG": "Vestgrønlandsk normaltid", "HNPMX": "Mexicansk Pacific-normaltid", "MEZ": "Centraleuropæisk normaltid", "OESZ": "Østeuropæisk sommertid", "ADT": "Atlantic-sommertid", "EAT": "Østafrikansk tid", "CLST": "Chilensk sommertid", "HECU": "Cubansk sommertid", "CST": "Central-normaltid", "MESZ": "Centraleuropæisk sommertid", "NZST": "Newzealandsk normaltid", "CHAST": "Chatham-normaltid", "NZDT": "Newzealandsk sommertid", "HNEG": "Østgrønlandsk normaltid", "CLT": "Chilensk normaltid", "GYT": "Guyana-tid", "WESZ": "Vesteuropæisk sommertid", "MST": "Macao-normaltid", "AST": "Atlantic-normaltid", "ARST": "Argentinsk sommertid", "TMT": "Turkmensk normaltid", "WAT": "Vestafrikansk normaltid", "HKST": "Hongkong-sommertid", "CAT": "Centralafrikansk tid", "HEPMX": "Mexicansk Pacific-sommertid", "HNPM": "Saint Pierre- og Miquelon-normaltid", "UYST": "Uruguayansk sommertid", "PST": "Pacific-normaltid", "HNCU": "Cubansk normaltid", "OEZ": "Østeuropæisk normaltid", "COST": "Colombiansk sommertid", "HEEG": "Østgrønlandsk sommertid", "COT": "Colombiansk normaltid", "AWDT": "Vestaustralsk sommertid", "ACWDT": "Vestlig centralaustralsk sommertid", "LHDT": "Lord Howe-sommertid", "VET": "Venezuelansk tid", "EDT": "Eastern-sommertid", "WIT": "Østindonesisk tid", "HAST": "Hawaii-Aleutian-normaltid", "WAST": "Vestafrikansk sommertid", "GFT": "Fransk Guyana-tid", "JST": "Japansk normaltid", "LHST": "Lord Howe-normaltid", "WARST": "Vestargentinsk sommertid", "HEOG": "Vestgrønlandsk sommertid", "GMT": "GMT", "BT": "Bhutanesisk tid", "HNNOMX": "Nordvestmexicansk normaltid", "WITA": "Centralindonesisk tid", "HNT": "Newfoundlandsk normaltid"},
80 // Locale returns the current translators string locale
81 func (da *da_GL) Locale() string {
85 // PluralsCardinal returns the list of cardinal plural rules associated with 'da_GL'
86 func (da *da_GL) PluralsCardinal() []locales.PluralRule {
87 return da.pluralsCardinal
90 // PluralsOrdinal returns the list of ordinal plural rules associated with 'da_GL'
91 func (da *da_GL) PluralsOrdinal() []locales.PluralRule {
92 return da.pluralsOrdinal
95 // PluralsRange returns the list of range plural rules associated with 'da_GL'
96 func (da *da_GL) PluralsRange() []locales.PluralRule {
97 return da.pluralsRange
100 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'da_GL'
101 func (da *da_GL) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
107 if (n == 1) || (t != 0 && (i == 0 || i == 1)) {
108 return locales.PluralRuleOne
111 return locales.PluralRuleOther
114 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'da_GL'
115 func (da *da_GL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
116 return locales.PluralRuleOther
119 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'da_GL'
120 func (da *da_GL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
122 start := da.CardinalPluralRule(num1, v1)
123 end := da.CardinalPluralRule(num2, v2)
125 if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
126 return locales.PluralRuleOne
127 } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
128 return locales.PluralRuleOther
129 } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
130 return locales.PluralRuleOne
133 return locales.PluralRuleOther
137 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
138 func (da *da_GL) MonthAbbreviated(month time.Month) string {
139 return da.monthsAbbreviated[month]
142 // MonthsAbbreviated returns the locales abbreviated months
143 func (da *da_GL) MonthsAbbreviated() []string {
144 return da.monthsAbbreviated[1:]
147 // MonthNarrow returns the locales narrow month given the 'month' provided
148 func (da *da_GL) MonthNarrow(month time.Month) string {
149 return da.monthsNarrow[month]
152 // MonthsNarrow returns the locales narrow months
153 func (da *da_GL) MonthsNarrow() []string {
154 return da.monthsNarrow[1:]
157 // MonthWide returns the locales wide month given the 'month' provided
158 func (da *da_GL) MonthWide(month time.Month) string {
159 return da.monthsWide[month]
162 // MonthsWide returns the locales wide months
163 func (da *da_GL) MonthsWide() []string {
164 return da.monthsWide[1:]
167 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
168 func (da *da_GL) WeekdayAbbreviated(weekday time.Weekday) string {
169 return da.daysAbbreviated[weekday]
172 // WeekdaysAbbreviated returns the locales abbreviated weekdays
173 func (da *da_GL) WeekdaysAbbreviated() []string {
174 return da.daysAbbreviated
177 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
178 func (da *da_GL) WeekdayNarrow(weekday time.Weekday) string {
179 return da.daysNarrow[weekday]
182 // WeekdaysNarrow returns the locales narrow weekdays
183 func (da *da_GL) WeekdaysNarrow() []string {
187 // WeekdayShort returns the locales short weekday given the 'weekday' provided
188 func (da *da_GL) WeekdayShort(weekday time.Weekday) string {
189 return da.daysShort[weekday]
192 // WeekdaysShort returns the locales short weekdays
193 func (da *da_GL) WeekdaysShort() []string {
197 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
198 func (da *da_GL) WeekdayWide(weekday time.Weekday) string {
199 return da.daysWide[weekday]
202 // WeekdaysWide returns the locales wide weekdays
203 func (da *da_GL) WeekdaysWide() []string {
207 // Decimal returns the decimal point of number
208 func (da *da_GL) Decimal() string {
212 // Group returns the group of number
213 func (da *da_GL) Group() string {
217 // Group returns the minus sign of number
218 func (da *da_GL) Minus() string {
222 // FmtNumber returns 'num' with digits/precision of 'v' for 'da_GL' and handles both Whole and Real numbers based on 'v'
223 func (da *da_GL) FmtNumber(num float64, v uint64) string {
225 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
226 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
229 b := make([]byte, 0, l)
231 for i := len(s) - 1; i >= 0; i-- {
234 b = append(b, da.decimal[0])
241 b = append(b, da.group[0])
252 b = append(b, da.minus[0])
256 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
257 b[i], b[j] = b[j], b[i]
263 // FmtPercent returns 'num' with digits/precision of 'v' for 'da_GL' and handles both Whole and Real numbers based on 'v'
264 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
265 func (da *da_GL) FmtPercent(num float64, v uint64) string {
266 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
268 b := make([]byte, 0, l)
270 for i := len(s) - 1; i >= 0; i-- {
273 b = append(b, da.decimal[0])
281 b = append(b, da.minus[0])
285 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
286 b[i], b[j] = b[j], b[i]
289 b = append(b, da.percentSuffix...)
291 b = append(b, da.percent...)
296 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'da_GL'
297 func (da *da_GL) FmtCurrency(num float64, v uint64, currency currency.Type) string {
299 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
300 symbol := da.currencies[currency]
301 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
304 b := make([]byte, 0, l)
306 for i := len(s) - 1; i >= 0; i-- {
309 b = append(b, da.decimal[0])
316 b = append(b, da.group[0])
327 b = append(b, da.minus[0])
331 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
332 b[i], b[j] = b[j], b[i]
338 b = append(b, da.decimal...)
341 for i := 0; i < 2-int(v); i++ {
346 b = append(b, da.currencyPositiveSuffix...)
348 b = append(b, symbol...)
353 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'da_GL'
354 // in accounting notation.
355 func (da *da_GL) FmtAccounting(num float64, v uint64, currency currency.Type) string {
357 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
358 symbol := da.currencies[currency]
359 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
362 b := make([]byte, 0, l)
364 for i := len(s) - 1; i >= 0; i-- {
367 b = append(b, da.decimal[0])
374 b = append(b, da.group[0])
386 b = append(b, da.minus[0])
391 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
392 b[i], b[j] = b[j], b[i]
398 b = append(b, da.decimal...)
401 for i := 0; i < 2-int(v); i++ {
407 b = append(b, da.currencyNegativeSuffix...)
408 b = append(b, symbol...)
411 b = append(b, da.currencyPositiveSuffix...)
412 b = append(b, symbol...)
418 // FmtDateShort returns the short date representation of 't' for 'da_GL'
419 func (da *da_GL) FmtDateShort(t time.Time) string {
421 b := make([]byte, 0, 32)
427 b = strconv.AppendInt(b, int64(t.Day()), 10)
428 b = append(b, []byte{0x2f}...)
434 b = strconv.AppendInt(b, int64(t.Month()), 10)
436 b = append(b, []byte{0x2f}...)
439 b = strconv.AppendInt(b, int64(t.Year()), 10)
441 b = strconv.AppendInt(b, int64(-t.Year()), 10)
447 // FmtDateMedium returns the medium date representation of 't' for 'da_GL'
448 func (da *da_GL) FmtDateMedium(t time.Time) string {
450 b := make([]byte, 0, 32)
452 b = strconv.AppendInt(b, int64(t.Day()), 10)
453 b = append(b, []byte{0x2e, 0x20}...)
454 b = append(b, da.monthsAbbreviated[t.Month()]...)
455 b = append(b, []byte{0x20}...)
458 b = strconv.AppendInt(b, int64(t.Year()), 10)
460 b = strconv.AppendInt(b, int64(-t.Year()), 10)
466 // FmtDateLong returns the long date representation of 't' for 'da_GL'
467 func (da *da_GL) FmtDateLong(t time.Time) string {
469 b := make([]byte, 0, 32)
471 b = strconv.AppendInt(b, int64(t.Day()), 10)
472 b = append(b, []byte{0x2e, 0x20}...)
473 b = append(b, da.monthsWide[t.Month()]...)
474 b = append(b, []byte{0x20}...)
477 b = strconv.AppendInt(b, int64(t.Year()), 10)
479 b = strconv.AppendInt(b, int64(-t.Year()), 10)
485 // FmtDateFull returns the full date representation of 't' for 'da_GL'
486 func (da *da_GL) FmtDateFull(t time.Time) string {
488 b := make([]byte, 0, 32)
490 b = append(b, da.daysWide[t.Weekday()]...)
491 b = append(b, []byte{0x20, 0x64, 0x65, 0x6e}...)
492 b = append(b, []byte{0x20}...)
493 b = strconv.AppendInt(b, int64(t.Day()), 10)
494 b = append(b, []byte{0x2e, 0x20}...)
495 b = append(b, da.monthsWide[t.Month()]...)
496 b = append(b, []byte{0x20}...)
499 b = strconv.AppendInt(b, int64(t.Year()), 10)
501 b = strconv.AppendInt(b, int64(-t.Year()), 10)
507 // FmtTimeShort returns the short time representation of 't' for 'da_GL'
508 func (da *da_GL) FmtTimeShort(t time.Time) string {
510 b := make([]byte, 0, 32)
518 b = strconv.AppendInt(b, int64(h), 10)
519 b = append(b, []byte{0x2e}...)
525 b = strconv.AppendInt(b, int64(t.Minute()), 10)
526 b = append(b, []byte{0x20}...)
529 b = append(b, da.periodsAbbreviated[0]...)
531 b = append(b, da.periodsAbbreviated[1]...)
537 // FmtTimeMedium returns the medium time representation of 't' for 'da_GL'
538 func (da *da_GL) FmtTimeMedium(t time.Time) string {
540 b := make([]byte, 0, 32)
548 b = strconv.AppendInt(b, int64(h), 10)
549 b = append(b, []byte{0x2e}...)
555 b = strconv.AppendInt(b, int64(t.Minute()), 10)
556 b = append(b, []byte{0x2e}...)
562 b = strconv.AppendInt(b, int64(t.Second()), 10)
563 b = append(b, []byte{0x20}...)
566 b = append(b, da.periodsAbbreviated[0]...)
568 b = append(b, da.periodsAbbreviated[1]...)
574 // FmtTimeLong returns the long time representation of 't' for 'da_GL'
575 func (da *da_GL) FmtTimeLong(t time.Time) string {
577 b := make([]byte, 0, 32)
585 b = strconv.AppendInt(b, int64(h), 10)
586 b = append(b, []byte{0x2e}...)
592 b = strconv.AppendInt(b, int64(t.Minute()), 10)
593 b = append(b, []byte{0x2e}...)
599 b = strconv.AppendInt(b, int64(t.Second()), 10)
600 b = append(b, []byte{0x20}...)
603 b = append(b, da.periodsAbbreviated[0]...)
605 b = append(b, da.periodsAbbreviated[1]...)
608 b = append(b, []byte{0x20}...)
616 // FmtTimeFull returns the full time representation of 't' for 'da_GL'
617 func (da *da_GL) FmtTimeFull(t time.Time) string {
619 b := make([]byte, 0, 32)
627 b = strconv.AppendInt(b, int64(h), 10)
628 b = append(b, []byte{0x2e}...)
634 b = strconv.AppendInt(b, int64(t.Minute()), 10)
635 b = append(b, []byte{0x2e}...)
641 b = strconv.AppendInt(b, int64(t.Second()), 10)
642 b = append(b, []byte{0x20}...)
645 b = append(b, da.periodsAbbreviated[0]...)
647 b = append(b, da.periodsAbbreviated[1]...)
650 b = append(b, []byte{0x20}...)
654 if btz, ok := da.timezones[tz]; ok {
655 b = append(b, btz...)