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 currencyPositivePrefix string
27 currencyNegativePrefix 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 'nb_SJ' locale
46 func New() locales.Translator {
49 pluralsCardinal: []locales.PluralRule{2, 6},
50 pluralsOrdinal: []locales.PluralRule{6},
51 pluralsRange: []locales.PluralRule{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 currencyPositivePrefix: " ",
62 currencyNegativePrefix: " ",
63 monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des."},
64 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
65 monthsWide: []string{"", "januar", "februar", "mars", "april", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"},
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{"a.m.", "p.m."},
71 periodsNarrow: []string{"a", "p"},
72 periodsWide: []string{"a.m.", "p.m."},
73 erasAbbreviated: []string{"f.Kr.", "e.Kr."},
74 erasNarrow: []string{"f.Kr.", "e.Kr."},
75 erasWide: []string{"før Kristus", "etter Kristus"},
76 timezones: map[string]string{"CDT": "sommertid for det sentrale Nord-Amerika", "HAST": "normaltid for Hawaii og Aleutene", "CHADT": "sommertid for Chatham", "HECU": "cubansk sommertid", "WIT": "østindonesisk tid", "HEPMX": "sommertid for den meksikanske Stillehavskysten", "AWDT": "vestaustralsk sommertid", "NZDT": "newzealandsk sommertid", "HENOMX": "sommertid for nordvestlige Mexico", "IST": "indisk tid", "SAST": "sørafrikansk tid", "∅∅∅": "sommertid for Amazonas", "UYT": "uruguayansk normaltid", "ACWST": "vest-sentralaustralsk normaltid", "NZST": "newzealandsk normaltid", "WARST": "vestargentinsk sommertid", "ACST": "sentralaustralsk normaltid", "CAT": "sentralafrikansk tid", "TMST": "turkmensk sommertid", "OEZ": "østeuropeisk normaltid", "AEST": "østaustralsk normaltid", "ART": "argentinsk normaltid", "WESZ": "vesteuropeisk sommertid", "MST": "Macau, standardtid", "WAST": "vestafrikansk sommertid", "GFT": "tidssone for Fransk Guyana", "HEEG": "østgrønlandsk sommertid", "HKT": "normaltid for Hongkong", "GYT": "guyansk tid", "ACDT": "sentralaustralsk sommertid", "AKDT": "alaskisk sommertid", "HNPMX": "normaltid for den meksikanske Stillehavskysten", "HNOG": "vestgrønlandsk normaltid", "HNEG": "østgrønlandsk normaltid", "UYST": "uruguayansk sommertid", "ACWDT": "vest-sentralaustralsk sommertid", "TMT": "turkmensk normaltid", "MEZ": "sentraleuropeisk normaltid", "PDT": "sommertid for den nordamerikanske Stillehavskysten", "MYT": "malaysisk tid", "ECT": "ecuadoriansk tid", "PST": "normaltid for den nordamerikanske Stillehavskysten", "LHDT": "sommertid for Lord Howe-øya", "ARST": "argentinsk sommertid", "WAT": "vestafrikansk normaltid", "EST": "normaltid for den nordamerikanske østkysten", "WIB": "vestindonesisk tid", "HEPM": "sommertid for Saint-Pierre-et-Miquelon", "MDT": "Macau, sommertid", "SRT": "surinamsk tid", "CST": "normaltid for det sentrale Nord-Amerika", "HKST": "sommertid for Hongkong", "COST": "colombiansk sommertid", "HADT": "sommertid for Hawaii og Aleutene", "WEZ": "vesteuropeisk normaltid", "GMT": "Greenwich middeltid", "VET": "venezuelansk tid", "AEDT": "østaustralsk sommertid", "AST": "atlanterhavskystlig standardtid", "HNCU": "cubansk normaltid", "BOT": "boliviansk tid", "WART": "vestargentinsk normaltid", "HAT": "sommertid for Newfoundland", "SGT": "singaporsk tid", "HNT": "normaltid for Newfoundland", "CHAST": "normaltid for Chatham", "MESZ": "sentraleuropeisk sommertid", "CLST": "chilensk sommertid", "COT": "colombiansk normaltid", "AWST": "vestaustralsk normaltid", "JDT": "japansk sommertid", "ADT": "atlanterhavskystlig sommertid", "JST": "japansk normaltid", "EDT": "sommertid for den nordamerikanske østkysten", "AKST": "alaskisk normaltid", "HNPM": "normaltid for Saint-Pierre-et-Miquelon", "LHST": "normaltid for Lord Howe-øya", "OESZ": "østeuropeisk sommertid", "EAT": "østafrikansk tid", "CLT": "chilensk normaltid", "BT": "bhutansk tid", "HNNOMX": "normaltid for nordvestlige Mexico", "WITA": "sentralindonesisk tid", "HEOG": "vestgrønlandsk sommertid", "ChST": "tidssone for Chamorro"},
80 // Locale returns the current translators string locale
81 func (nb *nb_SJ) Locale() string {
85 // PluralsCardinal returns the list of cardinal plural rules associated with 'nb_SJ'
86 func (nb *nb_SJ) PluralsCardinal() []locales.PluralRule {
87 return nb.pluralsCardinal
90 // PluralsOrdinal returns the list of ordinal plural rules associated with 'nb_SJ'
91 func (nb *nb_SJ) PluralsOrdinal() []locales.PluralRule {
92 return nb.pluralsOrdinal
95 // PluralsRange returns the list of range plural rules associated with 'nb_SJ'
96 func (nb *nb_SJ) PluralsRange() []locales.PluralRule {
97 return nb.pluralsRange
100 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nb_SJ'
101 func (nb *nb_SJ) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
106 return locales.PluralRuleOne
109 return locales.PluralRuleOther
112 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nb_SJ'
113 func (nb *nb_SJ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
114 return locales.PluralRuleOther
117 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nb_SJ'
118 func (nb *nb_SJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
119 return locales.PluralRuleOther
122 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
123 func (nb *nb_SJ) MonthAbbreviated(month time.Month) string {
124 return nb.monthsAbbreviated[month]
127 // MonthsAbbreviated returns the locales abbreviated months
128 func (nb *nb_SJ) MonthsAbbreviated() []string {
129 return nb.monthsAbbreviated[1:]
132 // MonthNarrow returns the locales narrow month given the 'month' provided
133 func (nb *nb_SJ) MonthNarrow(month time.Month) string {
134 return nb.monthsNarrow[month]
137 // MonthsNarrow returns the locales narrow months
138 func (nb *nb_SJ) MonthsNarrow() []string {
139 return nb.monthsNarrow[1:]
142 // MonthWide returns the locales wide month given the 'month' provided
143 func (nb *nb_SJ) MonthWide(month time.Month) string {
144 return nb.monthsWide[month]
147 // MonthsWide returns the locales wide months
148 func (nb *nb_SJ) MonthsWide() []string {
149 return nb.monthsWide[1:]
152 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
153 func (nb *nb_SJ) WeekdayAbbreviated(weekday time.Weekday) string {
154 return nb.daysAbbreviated[weekday]
157 // WeekdaysAbbreviated returns the locales abbreviated weekdays
158 func (nb *nb_SJ) WeekdaysAbbreviated() []string {
159 return nb.daysAbbreviated
162 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
163 func (nb *nb_SJ) WeekdayNarrow(weekday time.Weekday) string {
164 return nb.daysNarrow[weekday]
167 // WeekdaysNarrow returns the locales narrow weekdays
168 func (nb *nb_SJ) WeekdaysNarrow() []string {
172 // WeekdayShort returns the locales short weekday given the 'weekday' provided
173 func (nb *nb_SJ) WeekdayShort(weekday time.Weekday) string {
174 return nb.daysShort[weekday]
177 // WeekdaysShort returns the locales short weekdays
178 func (nb *nb_SJ) WeekdaysShort() []string {
182 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
183 func (nb *nb_SJ) WeekdayWide(weekday time.Weekday) string {
184 return nb.daysWide[weekday]
187 // WeekdaysWide returns the locales wide weekdays
188 func (nb *nb_SJ) WeekdaysWide() []string {
192 // Decimal returns the decimal point of number
193 func (nb *nb_SJ) Decimal() string {
197 // Group returns the group of number
198 func (nb *nb_SJ) Group() string {
202 // Group returns the minus sign of number
203 func (nb *nb_SJ) Minus() string {
207 // FmtNumber returns 'num' with digits/precision of 'v' for 'nb_SJ' and handles both Whole and Real numbers based on 'v'
208 func (nb *nb_SJ) FmtNumber(num float64, v uint64) string {
210 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
211 l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3
214 b := make([]byte, 0, l)
216 for i := len(s) - 1; i >= 0; i-- {
219 b = append(b, nb.decimal[0])
226 for j := len(nb.group) - 1; j >= 0; j-- {
227 b = append(b, nb.group[j])
239 for j := len(nb.minus) - 1; j >= 0; j-- {
240 b = append(b, nb.minus[j])
245 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
246 b[i], b[j] = b[j], b[i]
252 // FmtPercent returns 'num' with digits/precision of 'v' for 'nb_SJ' and handles both Whole and Real numbers based on 'v'
253 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
254 func (nb *nb_SJ) FmtPercent(num float64, v uint64) string {
255 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
257 b := make([]byte, 0, l)
259 for i := len(s) - 1; i >= 0; i-- {
262 b = append(b, nb.decimal[0])
270 for j := len(nb.minus) - 1; j >= 0; j-- {
271 b = append(b, nb.minus[j])
276 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
277 b[i], b[j] = b[j], b[i]
280 b = append(b, nb.percentSuffix...)
282 b = append(b, nb.percent...)
287 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nb_SJ'
288 func (nb *nb_SJ) FmtCurrency(num float64, v uint64, currency currency.Type) string {
290 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
291 symbol := nb.currencies[currency]
292 l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
295 b := make([]byte, 0, l)
297 for i := len(s) - 1; i >= 0; i-- {
300 b = append(b, nb.decimal[0])
307 for j := len(nb.group) - 1; j >= 0; j-- {
308 b = append(b, nb.group[j])
319 for j := len(symbol) - 1; j >= 0; j-- {
320 b = append(b, symbol[j])
323 for j := len(nb.currencyPositivePrefix) - 1; j >= 0; j-- {
324 b = append(b, nb.currencyPositivePrefix[j])
328 for j := len(nb.minus) - 1; j >= 0; j-- {
329 b = append(b, nb.minus[j])
334 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
335 b[i], b[j] = b[j], b[i]
341 b = append(b, nb.decimal...)
344 for i := 0; i < 2-int(v); i++ {
352 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nb_SJ'
353 // in accounting notation.
354 func (nb *nb_SJ) FmtAccounting(num float64, v uint64, currency currency.Type) string {
356 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
357 symbol := nb.currencies[currency]
358 l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
361 b := make([]byte, 0, l)
363 for i := len(s) - 1; i >= 0; i-- {
366 b = append(b, nb.decimal[0])
373 for j := len(nb.group) - 1; j >= 0; j-- {
374 b = append(b, nb.group[j])
387 for j := len(symbol) - 1; j >= 0; j-- {
388 b = append(b, symbol[j])
391 for j := len(nb.currencyNegativePrefix) - 1; j >= 0; j-- {
392 b = append(b, nb.currencyNegativePrefix[j])
395 for j := len(nb.minus) - 1; j >= 0; j-- {
396 b = append(b, nb.minus[j])
401 for j := len(symbol) - 1; j >= 0; j-- {
402 b = append(b, symbol[j])
405 for j := len(nb.currencyPositivePrefix) - 1; j >= 0; j-- {
406 b = append(b, nb.currencyPositivePrefix[j])
412 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
413 b[i], b[j] = b[j], b[i]
419 b = append(b, nb.decimal...)
422 for i := 0; i < 2-int(v); i++ {
430 // FmtDateShort returns the short date representation of 't' for 'nb_SJ'
431 func (nb *nb_SJ) FmtDateShort(t time.Time) string {
433 b := make([]byte, 0, 32)
439 b = strconv.AppendInt(b, int64(t.Day()), 10)
440 b = append(b, []byte{0x2e}...)
446 b = strconv.AppendInt(b, int64(t.Month()), 10)
448 b = append(b, []byte{0x2e}...)
451 b = strconv.AppendInt(b, int64(t.Year()), 10)
453 b = strconv.AppendInt(b, int64(-t.Year()), 10)
459 // FmtDateMedium returns the medium date representation of 't' for 'nb_SJ'
460 func (nb *nb_SJ) FmtDateMedium(t time.Time) string {
462 b := make([]byte, 0, 32)
464 b = strconv.AppendInt(b, int64(t.Day()), 10)
465 b = append(b, []byte{0x2e, 0x20}...)
466 b = append(b, nb.monthsAbbreviated[t.Month()]...)
467 b = append(b, []byte{0x20}...)
470 b = strconv.AppendInt(b, int64(t.Year()), 10)
472 b = strconv.AppendInt(b, int64(-t.Year()), 10)
478 // FmtDateLong returns the long date representation of 't' for 'nb_SJ'
479 func (nb *nb_SJ) FmtDateLong(t time.Time) string {
481 b := make([]byte, 0, 32)
483 b = strconv.AppendInt(b, int64(t.Day()), 10)
484 b = append(b, []byte{0x2e, 0x20}...)
485 b = append(b, nb.monthsWide[t.Month()]...)
486 b = append(b, []byte{0x20}...)
489 b = strconv.AppendInt(b, int64(t.Year()), 10)
491 b = strconv.AppendInt(b, int64(-t.Year()), 10)
497 // FmtDateFull returns the full date representation of 't' for 'nb_SJ'
498 func (nb *nb_SJ) FmtDateFull(t time.Time) string {
500 b := make([]byte, 0, 32)
502 b = append(b, nb.daysWide[t.Weekday()]...)
503 b = append(b, []byte{0x20}...)
504 b = strconv.AppendInt(b, int64(t.Day()), 10)
505 b = append(b, []byte{0x2e, 0x20}...)
506 b = append(b, nb.monthsWide[t.Month()]...)
507 b = append(b, []byte{0x20}...)
510 b = strconv.AppendInt(b, int64(t.Year()), 10)
512 b = strconv.AppendInt(b, int64(-t.Year()), 10)
518 // FmtTimeShort returns the short time representation of 't' for 'nb_SJ'
519 func (nb *nb_SJ) FmtTimeShort(t time.Time) string {
521 b := make([]byte, 0, 32)
527 b = strconv.AppendInt(b, int64(t.Hour()), 10)
528 b = append(b, nb.timeSeparator...)
534 b = strconv.AppendInt(b, int64(t.Minute()), 10)
539 // FmtTimeMedium returns the medium time representation of 't' for 'nb_SJ'
540 func (nb *nb_SJ) FmtTimeMedium(t time.Time) string {
542 b := make([]byte, 0, 32)
548 b = strconv.AppendInt(b, int64(t.Hour()), 10)
549 b = append(b, nb.timeSeparator...)
555 b = strconv.AppendInt(b, int64(t.Minute()), 10)
556 b = append(b, nb.timeSeparator...)
562 b = strconv.AppendInt(b, int64(t.Second()), 10)
567 // FmtTimeLong returns the long time representation of 't' for 'nb_SJ'
568 func (nb *nb_SJ) FmtTimeLong(t time.Time) string {
570 b := make([]byte, 0, 32)
576 b = strconv.AppendInt(b, int64(t.Hour()), 10)
577 b = append(b, nb.timeSeparator...)
583 b = strconv.AppendInt(b, int64(t.Minute()), 10)
584 b = append(b, nb.timeSeparator...)
590 b = strconv.AppendInt(b, int64(t.Second()), 10)
591 b = append(b, []byte{0x20}...)
599 // FmtTimeFull returns the full time representation of 't' for 'nb_SJ'
600 func (nb *nb_SJ) FmtTimeFull(t time.Time) string {
602 b := make([]byte, 0, 32)
608 b = strconv.AppendInt(b, int64(t.Hour()), 10)
609 b = append(b, nb.timeSeparator...)
615 b = strconv.AppendInt(b, int64(t.Minute()), 10)
616 b = append(b, nb.timeSeparator...)
622 b = strconv.AppendInt(b, int64(t.Second()), 10)
623 b = append(b, []byte{0x20}...)
627 if btz, ok := nb.timezones[tz]; ok {
628 b = append(b, btz...)