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
24 currencies []string // idx = enum of currency code
25 currencyPositiveSuffix string
26 currencyNegativeSuffix string
27 monthsAbbreviated []string
30 daysAbbreviated []string
34 periodsAbbreviated []string
35 periodsNarrow []string
38 erasAbbreviated []string
41 timezones map[string]string
44 // New returns a new instance of translator for the 'vi_VN' locale
45 func New() locales.Translator {
48 pluralsCardinal: []locales.PluralRule{6},
49 pluralsOrdinal: []locales.PluralRule{2, 6},
50 pluralsRange: []locales.PluralRule{6},
58 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"},
59 currencyPositiveSuffix: " ",
60 currencyNegativeSuffix: " ",
61 monthsAbbreviated: []string{"", "thg 1", "thg 2", "thg 3", "thg 4", "thg 5", "thg 6", "thg 7", "thg 8", "thg 9", "thg 10", "thg 11", "thg 12"},
62 monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"},
63 monthsWide: []string{"", "tháng 1", "tháng 2", "tháng 3", "tháng 4", "tháng 5", "tháng 6", "tháng 7", "tháng 8", "tháng 9", "tháng 10", "tháng 11", "tháng 12"},
64 daysAbbreviated: []string{"CN", "Th 2", "Th 3", "Th 4", "Th 5", "Th 6", "Th 7"},
65 daysNarrow: []string{"CN", "T2", "T3", "T4", "T5", "T6", "T7"},
66 daysShort: []string{"CN", "T2", "T3", "T4", "T5", "T6", "T7"},
67 daysWide: []string{"Chủ Nhật", "Thứ Hai", "Thứ Ba", "Thứ Tư", "Thứ Năm", "Thứ Sáu", "Thứ Bảy"},
68 periodsAbbreviated: []string{"SA", "CH"},
69 periodsNarrow: []string{"s", "c"},
70 periodsWide: []string{"SA", "CH"},
71 erasAbbreviated: []string{"", ""},
72 erasNarrow: []string{"tr. CN", "sau CN"},
73 erasWide: []string{"", ""},
74 timezones: map[string]string{"GFT": "Giờ Guiana thuộc Pháp", "GYT": "Giờ Guyana", "AKDT": "Giờ Mùa Hè Alaska", "HEPM": "Giờ Mùa Hè Saint Pierre và Miquelon", "JST": "Giờ Chuẩn Nhật Bản", "EAT": "Giờ Đông Phi", "HEPMX": "Giờ Mùa Hè Thái Bình Dương Mexico", "CDT": "Giờ mùa hè miền trung", "ACWDT": "Giờ Mùa Hè Miền Trung Tây Nước Úc", "WARST": "Giờ mùa hè miền tây Argentina", "JDT": "Giờ Mùa Hè Nhật Bản", "HEEG": "Giờ Mùa Hè Miền Đông Greenland", "CAT": "Giờ Trung Phi", "GMT": "Giờ Trung bình Greenwich", "WIT": "Giờ Miền Đông Indonesia", "WITA": "Giờ Miền Trung Indonesia", "TMT": "Giờ Chuẩn Turkmenistan", "OESZ": "Giờ Mùa Hè Đông Âu", "WAST": "Giờ Mùa Hè Tây Phi", "HKT": "Giờ Chuẩn Hồng Kông", "AKST": "Giờ Chuẩn Alaska", "ECT": "Giờ Ecuador", "CST": "Giờ chuẩn miền trung", "MEZ": "Giờ Chuẩn Trung Âu", "UYT": "Giờ Chuẩn Uruguay", "ChST": "Giờ Chamorro", "CHADT": "Giờ Mùa Hè Chatham", "HNOG": "Giờ Chuẩn Miền Tây Greenland", "ART": "Giờ Chuẩn Argentina", "SAST": "Giờ Chuẩn Nam Phi", "WIB": "Giờ Miền Tây Indonesia", "SRT": "Giờ Suriname", "AEDT": "Giờ Mùa Hè Miền Đông Nước Úc", "LHDT": "Giờ Mùa Hè Lord Howe", "AEST": "Giờ Chuẩn Miền Đông Nước Úc", "WAT": "Giờ Chuẩn Tây Phi", "HNEG": "Giờ Chuẩn Miền Đông Greenland", "HKST": "Giờ Mùa Hè Hồng Kông", "CLT": "Giờ Chuẩn Chile", "COT": "Giờ Chuẩn Colombia", "LHST": "Giờ Chuẩn Lord Howe", "BOT": "Giờ Bolivia", "EST": "Giờ chuẩn miền đông", "PST": "Giờ chuẩn Thái Bình Dương", "HECU": "Giờ Mùa Hè Cuba", "ADT": "Giờ Mùa hè Đại Tây Dương", "CHAST": "Giờ Chuẩn Chatham", "BT": "Giờ Bhutan", "MDT": "Giờ mùa hè miền núi", "ACST": "Giờ Chuẩn Miền Trung Nước Úc", "HNCU": "Giờ Chuẩn Cuba", "HNPM": "Giờ Chuẩn St. Pierre và Miquelon", "TMST": "Giờ Mùa Hè Turkmenistan", "IST": "Giờ Chuẩn Ấn Độ", "CLST": "Giờ Mùa Hè Chile", "SGT": "Giờ Singapore", "AWST": "Giờ Chuẩn Miền Tây Nước Úc", "UYST": "Giờ Mùa Hè Uruguay", "HNNOMX": "Giờ Chuẩn Tây Bắc Mexico", "HEOG": "Giờ Mùa Hè Miền Tây Greenland", "HADT": "Giờ Mùa Hè Hawaii-Aleutian", "HAT": "Giờ Mùa Hè Newfoundland", "COST": "Giờ Mùa Hè Colombia", "PDT": "Giờ Mùa hè Thái Bình Dương", "ACWST": "Giờ Chuẩn Miền Trung Tây Nước Úc", "AST": "Giờ Chuẩn Đại Tây Dương", "OEZ": "Giờ Chuẩn Đông Âu", "HNT": "Giờ Chuẩn Newfoundland", "WESZ": "Giờ Mùa hè Tây Âu", "VET": "Giờ Venezuela", "NZST": "Giờ Chuẩn New Zealand", "MST": "Giờ chuẩn miền núi", "∅∅∅": "Giờ Mùa Hè Azores", "EDT": "Giờ mùa hè miền đông", "ACDT": "Giờ Mùa Hè Miền Trung Nước Úc", "AWDT": "Giờ Mùa Hè Miền Tây Nước Úc", "MYT": "Giờ Malaysia", "HAST": "Giờ Chuẩn Hawaii-Aleutian", "NZDT": "Giờ Mùa Hè New Zealand", "HENOMX": "Giờ Mùa Hè Tây Bắc Mexico", "WART": "Giờ chuẩn miền mây Argentina", "ARST": "Giờ Mùa Hè Argentina", "WEZ": "Giờ Chuẩn Tây Âu", "HNPMX": "Giờ Chuẩn Thái Bình Dương Mexico", "MESZ": "Giờ Mùa Hè Trung Âu"},
78 // Locale returns the current translators string locale
79 func (vi *vi_VN) Locale() string {
83 // PluralsCardinal returns the list of cardinal plural rules associated with 'vi_VN'
84 func (vi *vi_VN) PluralsCardinal() []locales.PluralRule {
85 return vi.pluralsCardinal
88 // PluralsOrdinal returns the list of ordinal plural rules associated with 'vi_VN'
89 func (vi *vi_VN) PluralsOrdinal() []locales.PluralRule {
90 return vi.pluralsOrdinal
93 // PluralsRange returns the list of range plural rules associated with 'vi_VN'
94 func (vi *vi_VN) PluralsRange() []locales.PluralRule {
95 return vi.pluralsRange
98 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'vi_VN'
99 func (vi *vi_VN) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100 return locales.PluralRuleOther
103 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'vi_VN'
104 func (vi *vi_VN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
109 return locales.PluralRuleOne
112 return locales.PluralRuleOther
115 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'vi_VN'
116 func (vi *vi_VN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
117 return locales.PluralRuleOther
120 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
121 func (vi *vi_VN) MonthAbbreviated(month time.Month) string {
122 return vi.monthsAbbreviated[month]
125 // MonthsAbbreviated returns the locales abbreviated months
126 func (vi *vi_VN) MonthsAbbreviated() []string {
127 return vi.monthsAbbreviated[1:]
130 // MonthNarrow returns the locales narrow month given the 'month' provided
131 func (vi *vi_VN) MonthNarrow(month time.Month) string {
132 return vi.monthsNarrow[month]
135 // MonthsNarrow returns the locales narrow months
136 func (vi *vi_VN) MonthsNarrow() []string {
137 return vi.monthsNarrow[1:]
140 // MonthWide returns the locales wide month given the 'month' provided
141 func (vi *vi_VN) MonthWide(month time.Month) string {
142 return vi.monthsWide[month]
145 // MonthsWide returns the locales wide months
146 func (vi *vi_VN) MonthsWide() []string {
147 return vi.monthsWide[1:]
150 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
151 func (vi *vi_VN) WeekdayAbbreviated(weekday time.Weekday) string {
152 return vi.daysAbbreviated[weekday]
155 // WeekdaysAbbreviated returns the locales abbreviated weekdays
156 func (vi *vi_VN) WeekdaysAbbreviated() []string {
157 return vi.daysAbbreviated
160 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
161 func (vi *vi_VN) WeekdayNarrow(weekday time.Weekday) string {
162 return vi.daysNarrow[weekday]
165 // WeekdaysNarrow returns the locales narrow weekdays
166 func (vi *vi_VN) WeekdaysNarrow() []string {
170 // WeekdayShort returns the locales short weekday given the 'weekday' provided
171 func (vi *vi_VN) WeekdayShort(weekday time.Weekday) string {
172 return vi.daysShort[weekday]
175 // WeekdaysShort returns the locales short weekdays
176 func (vi *vi_VN) WeekdaysShort() []string {
180 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
181 func (vi *vi_VN) WeekdayWide(weekday time.Weekday) string {
182 return vi.daysWide[weekday]
185 // WeekdaysWide returns the locales wide weekdays
186 func (vi *vi_VN) WeekdaysWide() []string {
190 // Decimal returns the decimal point of number
191 func (vi *vi_VN) Decimal() string {
195 // Group returns the group of number
196 func (vi *vi_VN) Group() string {
200 // Group returns the minus sign of number
201 func (vi *vi_VN) Minus() string {
205 // FmtNumber returns 'num' with digits/precision of 'v' for 'vi_VN' and handles both Whole and Real numbers based on 'v'
206 func (vi *vi_VN) FmtNumber(num float64, v uint64) string {
208 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
209 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
212 b := make([]byte, 0, l)
214 for i := len(s) - 1; i >= 0; i-- {
217 b = append(b, vi.decimal[0])
224 b = append(b, vi.group[0])
235 b = append(b, vi.minus[0])
239 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
240 b[i], b[j] = b[j], b[i]
246 // FmtPercent returns 'num' with digits/precision of 'v' for 'vi_VN' and handles both Whole and Real numbers based on 'v'
247 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
248 func (vi *vi_VN) FmtPercent(num float64, v uint64) string {
249 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
251 b := make([]byte, 0, l)
253 for i := len(s) - 1; i >= 0; i-- {
256 b = append(b, vi.decimal[0])
264 b = append(b, vi.minus[0])
268 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
269 b[i], b[j] = b[j], b[i]
272 b = append(b, vi.percent...)
277 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'vi_VN'
278 func (vi *vi_VN) FmtCurrency(num float64, v uint64, currency currency.Type) string {
280 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
281 symbol := vi.currencies[currency]
282 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
285 b := make([]byte, 0, l)
287 for i := len(s) - 1; i >= 0; i-- {
290 b = append(b, vi.decimal[0])
297 b = append(b, vi.group[0])
308 b = append(b, vi.minus[0])
312 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
313 b[i], b[j] = b[j], b[i]
319 b = append(b, vi.decimal...)
322 for i := 0; i < 2-int(v); i++ {
327 b = append(b, vi.currencyPositiveSuffix...)
329 b = append(b, symbol...)
334 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'vi_VN'
335 // in accounting notation.
336 func (vi *vi_VN) FmtAccounting(num float64, v uint64, currency currency.Type) string {
338 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
339 symbol := vi.currencies[currency]
340 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
343 b := make([]byte, 0, l)
345 for i := len(s) - 1; i >= 0; i-- {
348 b = append(b, vi.decimal[0])
355 b = append(b, vi.group[0])
367 b = append(b, vi.minus[0])
372 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
373 b[i], b[j] = b[j], b[i]
379 b = append(b, vi.decimal...)
382 for i := 0; i < 2-int(v); i++ {
388 b = append(b, vi.currencyNegativeSuffix...)
389 b = append(b, symbol...)
392 b = append(b, vi.currencyPositiveSuffix...)
393 b = append(b, symbol...)
399 // FmtDateShort returns the short date representation of 't' for 'vi_VN'
400 func (vi *vi_VN) FmtDateShort(t time.Time) string {
402 b := make([]byte, 0, 32)
408 b = strconv.AppendInt(b, int64(t.Day()), 10)
409 b = append(b, []byte{0x2f}...)
415 b = strconv.AppendInt(b, int64(t.Month()), 10)
417 b = append(b, []byte{0x2f}...)
420 b = strconv.AppendInt(b, int64(t.Year()), 10)
422 b = strconv.AppendInt(b, int64(-t.Year()), 10)
428 // FmtDateMedium returns the medium date representation of 't' for 'vi_VN'
429 func (vi *vi_VN) FmtDateMedium(t time.Time) string {
431 b := make([]byte, 0, 32)
433 b = strconv.AppendInt(b, int64(t.Day()), 10)
434 b = append(b, []byte{0x20}...)
435 b = append(b, vi.monthsAbbreviated[t.Month()]...)
436 b = append(b, []byte{0x2c, 0x20}...)
439 b = strconv.AppendInt(b, int64(t.Year()), 10)
441 b = strconv.AppendInt(b, int64(-t.Year()), 10)
447 // FmtDateLong returns the long date representation of 't' for 'vi_VN'
448 func (vi *vi_VN) FmtDateLong(t time.Time) string {
450 b := make([]byte, 0, 32)
452 b = strconv.AppendInt(b, int64(t.Day()), 10)
453 b = append(b, []byte{0x20}...)
454 b = append(b, vi.monthsWide[t.Month()]...)
455 b = append(b, []byte{0x2c, 0x20}...)
458 b = strconv.AppendInt(b, int64(t.Year()), 10)
460 b = strconv.AppendInt(b, int64(-t.Year()), 10)
466 // FmtDateFull returns the full date representation of 't' for 'vi_VN'
467 func (vi *vi_VN) FmtDateFull(t time.Time) string {
469 b := make([]byte, 0, 32)
471 b = append(b, vi.daysWide[t.Weekday()]...)
472 b = append(b, []byte{0x2c, 0x20}...)
473 b = strconv.AppendInt(b, int64(t.Day()), 10)
474 b = append(b, []byte{0x20}...)
475 b = append(b, vi.monthsWide[t.Month()]...)
476 b = append(b, []byte{0x2c, 0x20}...)
479 b = strconv.AppendInt(b, int64(t.Year()), 10)
481 b = strconv.AppendInt(b, int64(-t.Year()), 10)
487 // FmtTimeShort returns the short time representation of 't' for 'vi_VN'
488 func (vi *vi_VN) FmtTimeShort(t time.Time) string {
490 b := make([]byte, 0, 32)
496 b = strconv.AppendInt(b, int64(t.Hour()), 10)
497 b = append(b, vi.timeSeparator...)
503 b = strconv.AppendInt(b, int64(t.Minute()), 10)
508 // FmtTimeMedium returns the medium time representation of 't' for 'vi_VN'
509 func (vi *vi_VN) FmtTimeMedium(t time.Time) string {
511 b := make([]byte, 0, 32)
517 b = strconv.AppendInt(b, int64(t.Hour()), 10)
518 b = append(b, vi.timeSeparator...)
524 b = strconv.AppendInt(b, int64(t.Minute()), 10)
525 b = append(b, vi.timeSeparator...)
531 b = strconv.AppendInt(b, int64(t.Second()), 10)
536 // FmtTimeLong returns the long time representation of 't' for 'vi_VN'
537 func (vi *vi_VN) FmtTimeLong(t time.Time) string {
539 b := make([]byte, 0, 32)
545 b = strconv.AppendInt(b, int64(t.Hour()), 10)
546 b = append(b, vi.timeSeparator...)
552 b = strconv.AppendInt(b, int64(t.Minute()), 10)
553 b = append(b, vi.timeSeparator...)
559 b = strconv.AppendInt(b, int64(t.Second()), 10)
560 b = append(b, []byte{0x20}...)
568 // FmtTimeFull returns the full time representation of 't' for 'vi_VN'
569 func (vi *vi_VN) FmtTimeFull(t time.Time) string {
571 b := make([]byte, 0, 32)
577 b = strconv.AppendInt(b, int64(t.Hour()), 10)
578 b = append(b, vi.timeSeparator...)
584 b = strconv.AppendInt(b, int64(t.Minute()), 10)
585 b = append(b, vi.timeSeparator...)
591 b = strconv.AppendInt(b, int64(t.Second()), 10)
592 b = append(b, []byte{0x20}...)
596 if btz, ok := vi.timezones[tz]; ok {
597 b = append(b, btz...)