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' 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", "AU$", "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", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "kr.", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "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", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "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", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "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{"MESZ": "Centraleuropæisk sommertid", "JST": "Japansk normaltid", "AEDT": "Østaustralsk sommertid", "∅∅∅": "Amazonas-sommertid", "CHAST": "Chatham-normaltid", "HKST": "Hongkong-sommertid", "LHDT": "Lord Howe-sommertid", "HNEG": "Østgrønlandsk normaltid", "PDT": "Pacific-sommertid", "BOT": "Boliviansk tid", "UYT": "Uruguayansk normaltid", "HAST": "Hawaii-Aleutian-normaltid", "GMT": "GMT", "ChST": "Chamorro-tid", "LHST": "Lord Howe-normaltid", "AEST": "Østaustralsk normaltid", "SAST": "Sydafrikansk tid", "HAT": "Newfoundlandsk sommertid", "CAT": "Centralafrikansk tid", "HNNOMX": "Nordvestmexicansk normaltid", "ACST": "Centralaustralsk normaltid", "HEPMX": "Mexicansk Pacific-sommertid", "HEEG": "Østgrønlandsk sommertid", "EDT": "Eastern-sommertid", "AKDT": "Alaska-sommertid", "PST": "Pacific-normaltid", "AST": "Atlantic-normaltid", "SRT": "Surinam-tid", "MDT": "Macao-sommertid", "VET": "Venezuelansk tid", "HNOG": "Vestgrønlandsk normaltid", "ADT": "Atlantic-sommertid", "CLST": "Chilensk sommertid", "WIB": "Vestindonesisk tid", "HECU": "Cubansk sommertid", "CDT": "Central-sommertid", "IST": "Indisk normaltid", "CLT": "Chilensk normaltid", "HNPMX": "Mexicansk Pacific-normaltid", "CHADT": "Chatham-sommertid", "HNPM": "Saint Pierre- og Miquelon-normaltid", "MYT": "Malaysisk tid", "MEZ": "Centraleuropæisk normaltid", "GFT": "Fransk Guyana-tid", "HKT": "Hongkong-normaltid", "ACDT": "Centralaustralsk sommertid", "SGT": "Singaporeansk normaltid", "NZST": "Newzealandsk normaltid", "TMST": "Turkmensk sommertid", "OESZ": "Østeuropæisk sommertid", "WAT": "Vestafrikansk normaltid", "EST": "Eastern-normaltid", "WEZ": "Vesteuropæisk normaltid", "WESZ": "Vesteuropæisk sommertid", "AWST": "Vestaustralsk normaltid", "ACWDT": "Vestlig centralaustralsk sommertid", "WART": "Vestargentinsk normaltid", "WARST": "Vestargentinsk sommertid", "EAT": "Østafrikansk tid", "GYT": "Guyana-tid", "ECT": "Ecuadoriansk tid", "OEZ": "Østeuropæisk normaltid", "COST": "Colombiansk sommertid", "HNT": "Newfoundlandsk normaltid", "NZDT": "Newzealandsk sommertid", "HEOG": "Vestgrønlandsk sommertid", "ACWST": "Vestlig centralaustralsk normaltid", "TMT": "Turkmensk normaltid", "HADT": "Hawaii-Aleutian-sommertid", "HENOMX": "Nordvestmexicansk sommertid", "ART": "Argentinsk normaltid", "ARST": "Argentinsk sommertid", "BT": "Bhutanesisk tid", "CST": "Central-normaltid", "WAST": "Vestafrikansk sommertid", "MST": "Macao-normaltid", "WIT": "Østindonesisk tid", "WITA": "Centralindonesisk tid", "JDT": "Japansk sommertid", "COT": "Colombiansk normaltid", "AKST": "Alaska-normaltid", "HNCU": "Cubansk normaltid", "UYST": "Uruguayansk sommertid", "HEPM": "Saint Pierre- og Miquelon-sommertid", "AWDT": "Vestaustralsk sommertid"},
80 // Locale returns the current translators string locale
81 func (da *da) Locale() string {
85 // PluralsCardinal returns the list of cardinal plural rules associated with 'da'
86 func (da *da) PluralsCardinal() []locales.PluralRule {
87 return da.pluralsCardinal
90 // PluralsOrdinal returns the list of ordinal plural rules associated with 'da'
91 func (da *da) PluralsOrdinal() []locales.PluralRule {
92 return da.pluralsOrdinal
95 // PluralsRange returns the list of range plural rules associated with 'da'
96 func (da *da) PluralsRange() []locales.PluralRule {
97 return da.pluralsRange
100 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'da'
101 func (da *da) 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'
115 func (da *da) 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'
120 func (da *da) 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) MonthAbbreviated(month time.Month) string {
139 return da.monthsAbbreviated[month]
142 // MonthsAbbreviated returns the locales abbreviated months
143 func (da *da) MonthsAbbreviated() []string {
144 return da.monthsAbbreviated[1:]
147 // MonthNarrow returns the locales narrow month given the 'month' provided
148 func (da *da) MonthNarrow(month time.Month) string {
149 return da.monthsNarrow[month]
152 // MonthsNarrow returns the locales narrow months
153 func (da *da) MonthsNarrow() []string {
154 return da.monthsNarrow[1:]
157 // MonthWide returns the locales wide month given the 'month' provided
158 func (da *da) MonthWide(month time.Month) string {
159 return da.monthsWide[month]
162 // MonthsWide returns the locales wide months
163 func (da *da) MonthsWide() []string {
164 return da.monthsWide[1:]
167 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
168 func (da *da) WeekdayAbbreviated(weekday time.Weekday) string {
169 return da.daysAbbreviated[weekday]
172 // WeekdaysAbbreviated returns the locales abbreviated weekdays
173 func (da *da) WeekdaysAbbreviated() []string {
174 return da.daysAbbreviated
177 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
178 func (da *da) WeekdayNarrow(weekday time.Weekday) string {
179 return da.daysNarrow[weekday]
182 // WeekdaysNarrow returns the locales narrow weekdays
183 func (da *da) WeekdaysNarrow() []string {
187 // WeekdayShort returns the locales short weekday given the 'weekday' provided
188 func (da *da) WeekdayShort(weekday time.Weekday) string {
189 return da.daysShort[weekday]
192 // WeekdaysShort returns the locales short weekdays
193 func (da *da) WeekdaysShort() []string {
197 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
198 func (da *da) WeekdayWide(weekday time.Weekday) string {
199 return da.daysWide[weekday]
202 // WeekdaysWide returns the locales wide weekdays
203 func (da *da) WeekdaysWide() []string {
207 // Decimal returns the decimal point of number
208 func (da *da) Decimal() string {
212 // Group returns the group of number
213 func (da *da) Group() string {
217 // Group returns the minus sign of number
218 func (da *da) Minus() string {
222 // FmtNumber returns 'num' with digits/precision of 'v' for 'da' and handles both Whole and Real numbers based on 'v'
223 func (da *da) 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' 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) 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'
297 func (da *da) 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'
354 // in accounting notation.
355 func (da *da) 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'
419 func (da *da) 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'
448 func (da *da) 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'
467 func (da *da) 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'
486 func (da *da) 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'
508 func (da *da) FmtTimeShort(t time.Time) string {
510 b := make([]byte, 0, 32)
516 b = strconv.AppendInt(b, int64(t.Hour()), 10)
517 b = append(b, []byte{0x2e}...)
523 b = strconv.AppendInt(b, int64(t.Minute()), 10)
528 // FmtTimeMedium returns the medium time representation of 't' for 'da'
529 func (da *da) FmtTimeMedium(t time.Time) string {
531 b := make([]byte, 0, 32)
537 b = strconv.AppendInt(b, int64(t.Hour()), 10)
538 b = append(b, []byte{0x2e}...)
544 b = strconv.AppendInt(b, int64(t.Minute()), 10)
545 b = append(b, []byte{0x2e}...)
551 b = strconv.AppendInt(b, int64(t.Second()), 10)
556 // FmtTimeLong returns the long time representation of 't' for 'da'
557 func (da *da) FmtTimeLong(t time.Time) string {
559 b := make([]byte, 0, 32)
565 b = strconv.AppendInt(b, int64(t.Hour()), 10)
566 b = append(b, []byte{0x2e}...)
572 b = strconv.AppendInt(b, int64(t.Minute()), 10)
573 b = append(b, []byte{0x2e}...)
579 b = strconv.AppendInt(b, int64(t.Second()), 10)
580 b = append(b, []byte{0x20}...)
588 // FmtTimeFull returns the full time representation of 't' for 'da'
589 func (da *da) FmtTimeFull(t time.Time) string {
591 b := make([]byte, 0, 32)
597 b = strconv.AppendInt(b, int64(t.Hour()), 10)
598 b = append(b, []byte{0x2e}...)
604 b = strconv.AppendInt(b, int64(t.Minute()), 10)
605 b = append(b, []byte{0x2e}...)
611 b = strconv.AppendInt(b, int64(t.Second()), 10)
612 b = append(b, []byte{0x20}...)
616 if btz, ok := da.timezones[tz]; ok {
617 b = append(b, btz...)