1 {{ define "translator" }}
9 "github.com/go-playground/locales"
10 "github.com/go-playground/locales/currency"
13 type {{ .Locale }} struct {
15 pluralsCardinal []locales.PluralRule
16 pluralsOrdinal []locales.PluralRule
17 pluralsRange []locales.PluralRule
22 {{- if gt (len .FmtPercentPrefix) 0}}
25 {{- if gt (len .FmtPercentSuffix) 0}}
31 currencies []string // idx = enum of currency code
32 {{- if gt (len .FmtCurrencyPrefix) 0}}
33 currencyPositivePrefix string
35 {{- if gt (len .FmtCurrencySuffix) 0}}
36 currencyPositiveSuffix string
38 {{- if gt (len .FmtCurrencyNegativePrefix) 0}}
39 currencyNegativePrefix string
41 {{- if gt (len .FmtCurrencyNegativeSuffix) 0}}
42 currencyNegativeSuffix string
44 monthsAbbreviated []string
47 daysAbbreviated []string
51 periodsAbbreviated []string
52 periodsNarrow []string
55 erasAbbreviated []string
58 timezones map[string]string
61 // New returns a new instance of translator for the '{{ .Locale }}' locale
62 func New() locales.Translator {
63 return &{{ .Locale }}{
64 locale: "{{ .Locale }}",
65 pluralsCardinal: {{ .Plurals }},
66 pluralsOrdinal: {{ .PluralsOrdinal }},
67 pluralsRange: {{ .PluralsRange }},
68 {{- if gt (len .Decimal) 0}}
69 decimal: "{{ .Decimal }}",
71 {{- if gt (len .Group) 0}}
72 group: "{{ .Group }}",
74 {{- if gt (len .Minus) 0}}
75 minus: "{{ .Minus }}",
77 {{- if gt (len .Percent) 0}}
78 percent: "{{ .Percent }}",
80 {{- if gt (len .PerMille) 0}}
81 perMille: "{{ .PerMille }}",
83 {{- if gt (len .TimeSeparator) 0}}
84 timeSeparator: "{{ .TimeSeparator }}",
86 {{- if gt (len .Infinity) 0}}
87 inifinity: "{{ .Infinity }}",
89 currencies: {{ .Currencies }},
90 {{- if gt (len .FmtPercentPrefix) 0}}
91 percentPrefix: "{{ .FmtPercentPrefix }}",
93 {{- if gt (len .FmtPercentSuffix) 0}}
94 percentSuffix: "{{ .FmtPercentSuffix }}",
96 {{- if gt (len .FmtCurrencyPrefix) 0}}
97 currencyPositivePrefix: "{{ .FmtCurrencyPrefix }}",
99 {{- if gt (len .FmtCurrencySuffix) 0}}
100 currencyPositiveSuffix: "{{ .FmtCurrencySuffix }}",
102 {{- if gt (len .FmtCurrencyNegativePrefix) 0}}
103 currencyNegativePrefix: "{{ .FmtCurrencyNegativePrefix }}",
105 {{- if gt (len .FmtCurrencyNegativeSuffix) 0}}
106 currencyNegativeSuffix: "{{ .FmtCurrencyNegativeSuffix }}",
108 {{- if gt (len .FmtMonthsAbbreviated) 0 }}
109 monthsAbbreviated: {{ .FmtMonthsAbbreviated }},
111 {{- if gt (len .FmtMonthsNarrow) 0 }}
112 monthsNarrow: {{ .FmtMonthsNarrow }},
114 {{- if gt (len .FmtMonthsWide) 0 }}
115 monthsWide: {{ .FmtMonthsWide }},
117 {{- if gt (len .FmtDaysAbbreviated) 0 }}
118 daysAbbreviated: {{ .FmtDaysAbbreviated }},
120 {{- if gt (len .FmtDaysNarrow) 0 }}
121 daysNarrow: {{ .FmtDaysNarrow }},
123 {{- if gt (len .FmtDaysShort) 0 }}
124 daysShort: {{ .FmtDaysShort }},
126 {{- if gt (len .FmtDaysWide) 0 }}
127 daysWide: {{ .FmtDaysWide }},
129 {{- if gt (len .FmtPeriodsAbbreviated) 0 }}
130 periodsAbbreviated: {{ .FmtPeriodsAbbreviated }},
132 {{- if gt (len .FmtPeriodsNarrow) 0 }}
133 periodsNarrow: {{ .FmtPeriodsNarrow }},
135 {{- if gt (len .FmtPeriodsShort) 0 }}
136 periodsShort: {{ .FmtPeriodsShort }},
138 {{- if gt (len .FmtPeriodsWide) 0 }}
139 periodsWide: {{ .FmtPeriodsWide }},
141 {{- if gt (len .FmtErasAbbreviated) 0 }}
142 erasAbbreviated: {{ .FmtErasAbbreviated }},
144 {{- if gt (len .FmtErasNarrow) 0 }}
145 erasNarrow: {{ .FmtErasNarrow }},
147 {{- if gt (len .FmtErasWide) 0 }}
148 erasWide: {{ .FmtErasWide }},
150 timezones: {{ .FmtTimezones }},
154 // Locale returns the current translators string locale
155 func({{ .BaseLocale }} *{{ .Locale }}) Locale() string {
156 return {{ .BaseLocale }}.locale
159 // PluralsCardinal returns the list of cardinal plural rules associated with '{{ .Locale }}'
160 func({{ .BaseLocale }} *{{ .Locale }}) PluralsCardinal() []locales.PluralRule {
161 return {{ .BaseLocale }}.pluralsCardinal
164 // PluralsOrdinal returns the list of ordinal plural rules associated with '{{ .Locale }}'
165 func({{ .BaseLocale }} *{{ .Locale }}) PluralsOrdinal() []locales.PluralRule {
166 return {{ .BaseLocale }}.pluralsOrdinal
169 // PluralsRange returns the list of range plural rules associated with '{{ .Locale }}'
170 func({{ .BaseLocale }} *{{ .Locale }}) PluralsRange() []locales.PluralRule {
171 return {{ .BaseLocale }}.pluralsRange
174 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for '{{ .Locale }}'
175 func({{ .BaseLocale }} *{{ .Locale }}) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
179 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for '{{ .Locale }}'
180 func({{ .BaseLocale }} *{{ .Locale }}) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
184 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for '{{ .Locale }}'
185 func({{ .BaseLocale }} *{{ .Locale }}) RangePluralRule(num1 float64, v1 uint64,num2 float64, v2 uint64) locales.PluralRule {
189 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
190 func({{ .BaseLocale }} *{{ .Locale }}) MonthAbbreviated(month time.Month) string {
191 return {{ .BaseLocale }}.monthsAbbreviated[month]
194 // MonthsAbbreviated returns the locales abbreviated months
195 func({{ .BaseLocale }} *{{ .Locale }}) MonthsAbbreviated() []string {
196 {{- if gt (len .FmtMonthsAbbreviated) 0 }}
197 return {{ .BaseLocale }}.monthsAbbreviated[1:]
203 // MonthNarrow returns the locales narrow month given the 'month' provided
204 func({{ .BaseLocale }} *{{ .Locale }}) MonthNarrow(month time.Month) string {
205 return {{ .BaseLocale }}.monthsNarrow[month]
208 // MonthsNarrow returns the locales narrow months
209 func({{ .BaseLocale }} *{{ .Locale }}) MonthsNarrow() []string {
210 {{- if gt (len .FmtMonthsNarrow) 0 }}
211 return {{ .BaseLocale }}.monthsNarrow[1:]
217 // MonthWide returns the locales wide month given the 'month' provided
218 func({{ .BaseLocale }} *{{ .Locale }}) MonthWide(month time.Month) string {
219 return {{ .BaseLocale }}.monthsWide[month]
222 // MonthsWide returns the locales wide months
223 func({{ .BaseLocale }} *{{ .Locale }}) MonthsWide() []string {
224 {{- if gt (len .FmtMonthsWide) 0 }}
225 return {{ .BaseLocale }}.monthsWide[1:]
231 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
232 func({{ .BaseLocale }} *{{ .Locale }}) WeekdayAbbreviated(weekday time.Weekday) string {
233 return {{ .BaseLocale }}.daysAbbreviated[weekday]
236 // WeekdaysAbbreviated returns the locales abbreviated weekdays
237 func({{ .BaseLocale }} *{{ .Locale }}) WeekdaysAbbreviated() []string {
238 return {{ .BaseLocale }}.daysAbbreviated
241 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
242 func({{ .BaseLocale }} *{{ .Locale }}) WeekdayNarrow(weekday time.Weekday) string {
243 return {{ .BaseLocale }}.daysNarrow[weekday]
246 // WeekdaysNarrow returns the locales narrow weekdays
247 func({{ .BaseLocale }} *{{ .Locale }}) WeekdaysNarrow() []string {
248 return {{ .BaseLocale }}.daysNarrow
251 // WeekdayShort returns the locales short weekday given the 'weekday' provided
252 func({{ .BaseLocale }} *{{ .Locale }}) WeekdayShort(weekday time.Weekday) string {
253 return {{ .BaseLocale }}.daysShort[weekday]
256 // WeekdaysShort returns the locales short weekdays
257 func({{ .BaseLocale }} *{{ .Locale }}) WeekdaysShort() []string {
258 return {{ .BaseLocale }}.daysShort
261 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
262 func({{ .BaseLocale }} *{{ .Locale }}) WeekdayWide(weekday time.Weekday) string {
263 return {{ .BaseLocale }}.daysWide[weekday]
266 // WeekdaysWide returns the locales wide weekdays
267 func({{ .BaseLocale }} *{{ .Locale }}) WeekdaysWide() []string {
268 return {{ .BaseLocale }}.daysWide
271 // Decimal returns the decimal point of number
272 func({{ .BaseLocale }} *{{ .Locale }}) Decimal() string {
273 return {{ .BaseLocale }}.decimal
276 // Group returns the group of number
277 func({{ .BaseLocale }} *{{ .Locale }}) Group() string {
278 return {{ .BaseLocale }}.group
281 // Group returns the minus sign of number
282 func({{ .BaseLocale }} *{{ .Locale }}) Minus() string {
283 return {{ .BaseLocale }}.minus
286 // FmtNumber returns 'num' with digits/precision of 'v' for '{{ .Locale }}' and handles both Whole and Real numbers based on 'v'
287 func({{ .BaseLocale }} *{{ .Locale }}) FmtNumber(num float64, v uint64) string {
289 {{ if eq .FmtNumberExists true }}
290 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
291 {{- if gt .FmtNumberGroupLen 0 }}
292 {{- $byteCountGroup := byte_count .Group -}}
293 {{ if ne $byteCountGroup "0" }}
294 l := len(s) + {{ byte_count .Decimal .Minus }} + {{ $byteCountGroup }} * len(s[:len(s)-int(v)-1]) / {{ .FmtNumberGroupLen }}
296 l := len(s) + {{ byte_count .Decimal .Minus }}
300 {{- if gt .FmtNumberSecondaryGroupLen 0}}
302 groupThreshold := {{ .FmtNumberGroupLen }}
305 l := len(s) + {{ byte_count .Decimal .Minus }}
307 b := make([]byte, 0, l)
309 for i := len(s) - 1; i >= 0; i-- {
313 {{- if is_multibyte .Decimal }}
314 for j := len({{ .BaseLocale }}.decimal) - 1; j >= 0; j-- {
315 b = append(b, {{ .BaseLocale }}.decimal[j])
318 b = append(b, {{ .BaseLocale }}.decimal[0])
320 {{- if gt .FmtNumberGroupLen 0 }}
326 {{ if gt .FmtNumberGroupLen 0 }}
329 {{- if gt .FmtNumberSecondaryGroupLen 0}}
331 if count == groupThreshold {
332 {{- if is_multibyte .Group }}
333 for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- {
334 b = append(b, {{ .BaseLocale }}.group[j])
337 b = append(b, {{ .BaseLocale }}.group[0])
343 groupThreshold = {{ .FmtNumberSecondaryGroupLen }}
346 if count == {{ .FmtNumberGroupLen }} {
347 {{- if is_multibyte .Group }}
348 for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- {
349 b = append(b, {{ .BaseLocale }}.group[j])
352 b = append(b, {{ .BaseLocale }}.group[0])
367 {{- if is_multibyte .Minus }}
368 for j := len({{ .BaseLocale }}.minus) - 1; j >= 0; j-- {
369 b = append(b, {{ .BaseLocale }}.minus[j])
372 b = append(b, {{ .BaseLocale }}.minus[0])
377 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
378 b[i], b[j] = b[j], b[i]
381 {{ if gt .FmtNumberMinDecimalLen 0 }}
382 if int(v) < {{ .FmtNumberMinDecimalLen }} {
385 b = append(b, {{ .BaseLocale }}.decimal...)
388 for i := 0; i < {{ .FmtNumberMinDecimalLen }}-int(v); i++ {
396 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
400 // FmtPercent returns 'num' with digits/precision of 'v' for '{{ .Locale }}' and handles both Whole and Real numbers based on 'v'
401 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
402 func({{ .BaseLocale }} *{{ .Locale }}) FmtPercent(num float64, v uint64) string {
404 {{- if eq .FmtPercentExists true }}
405 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
406 {{- if gt .FmtPercentGroupLen 0 }}
407 {{- $byteCountGroup := byte_count .Group -}}
408 {{ if ne $byteCountGroup "0" }}
409 l := len(s) + {{ byte_count .Decimal .Minus .Percent .FmtPercentPrefix .FmtPercentSuffix }} + {{ $byteCountGroup }} * len(s[:len(s)-int(v)-1]) / {{ .FmtPercentGroupLen }}
411 l := len(s) + {{ byte_count .Decimal .Minus .Percent .FmtPercentPrefix .FmtPercentSuffix }}
415 {{- if gt .FmtPercentSecondaryGroupLen 0}}
417 groupThreshold := {{ .FmtPercentGroupLen }}
420 l := len(s) + {{ byte_count .Decimal .Minus .Percent .FmtPercentPrefix .FmtPercentSuffix }}
422 b := make([]byte, 0, l)
424 for i := len(s) - 1; i >= 0; i-- {
428 {{- if is_multibyte .Decimal }}
429 for j := len({{ .BaseLocale }}.decimal) - 1; j >= 0; j-- {
430 b = append(b, {{ .BaseLocale }}.decimal[j])
433 b = append(b, {{ .BaseLocale }}.decimal[0])
435 {{- if gt .FmtPercentGroupLen 0 }}
441 {{ if gt .FmtPercentGroupLen 0 }}
444 {{- if gt .FmtPercentSecondaryGroupLen 0}}
446 if count == groupThreshold {
447 {{- if is_multibyte .Group }}
448 for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- {
449 b = append(b, {{ .BaseLocale }}.group[j])
452 b = append(b, {{ .BaseLocale }}.group[0])
458 groupThreshold = {{ .FmtPercentSecondaryGroupLen }}
461 if count == {{ .FmtPercentGroupLen }} {
462 {{- if is_multibyte .Group }}
463 for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- {
464 b = append(b, {{ .BaseLocale }}.group[j])
467 b = append(b, {{ .BaseLocale }}.group[0])
482 {{- if is_multibyte .Minus }}
483 for j := len({{ .BaseLocale }}.minus) - 1; j >= 0; j-- {
484 b = append(b, {{ .BaseLocale }}.minus[j])
487 b = append(b, {{ .BaseLocale }}.minus[0])
491 {{ if and .FmtPercentInPrefix (not .FmtPercentLeft) }}
492 {{- if is_multibyte .Percent }}
493 for j := len({{ .BaseLocale }}.percent) - 1; j >= 0; j-- {
494 b = append(b, {{ .BaseLocale }}.percent[j])
497 b = append(b, {{ .BaseLocale }}.percent[0])
501 {{ if gt (len .FmtPercentPrefix) 0}}
502 {{- if is_multibyte .FmtPercentPrefix }}
503 for j := len({{ .BaseLocale }}.percentPrefix) - 1; j >= 0; j-- {
504 b = append(b, {{ .BaseLocale }}.percentPrefix[j])
507 b = append(b, {{ .BaseLocale }}.percentPrefix[0])
511 {{ if and .FmtPercentInPrefix .FmtPercentLeft }}
512 {{- if is_multibyte .Percent }}
513 for j := len({{ .BaseLocale }}.percent) - 1; j >= 0; j-- {
514 b = append(b, {{ .BaseLocale }}.percent[j])
517 b = append(b, {{ .BaseLocale }}.percent[0])
522 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
523 b[i], b[j] = b[j], b[i]
526 {{ if gt .FmtPercentMinDecimalLen 0 }}
527 if int(v) < {{ .FmtPercentMinDecimalLen }} {
530 b = append(b, {{ .BaseLocale }}.decimal...)
533 for i := 0; i < {{ .FmtPercentMinDecimalLen }}-int(v); i++ {
539 {{ if and (not .FmtPercentInPrefix) .FmtPercentLeft }}
540 b = append(b, {{ .BaseLocale }}.percent...)
543 {{ if gt (len .FmtPercentSuffix) 0}}
544 b = append(b, {{ .BaseLocale }}.percentSuffix...)
547 {{ if and (not .FmtPercentInPrefix) (not .FmtPercentLeft) }}
548 b = append(b, {{ .BaseLocale }}.percent...)
553 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
557 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for '{{ .Locale }}'
558 func({{ .BaseLocale }} *{{ .Locale }}) FmtCurrency(num float64, v uint64, currency currency.Type) string {
560 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
561 symbol := {{ .BaseLocale }}.currencies[currency]
562 {{- if eq .FmtCurrencyExists true }}
563 {{- if gt .FmtCurrencyGroupLen 0 }}
564 {{- $byteCountGroup := byte_count .Group -}}
565 {{ if ne $byteCountGroup "0" }}
566 l := len(s) + len(symbol) + {{ byte_count .Decimal .Minus .FmtCurrencyPrefix .FmtCurrencySuffix }} + {{ $byteCountGroup }} * len(s[:len(s)-int(v)-1]) / {{ .FmtCurrencyGroupLen }}
568 l := len(s) + len(symbol) + {{ byte_count .Decimal .Minus .FmtCurrencyPrefix .FmtCurrencySuffix }}
572 {{- if gt .FmtCurrencySecondaryGroupLen 0}}
574 groupThreshold := {{ .FmtCurrencyGroupLen }}
577 l := len(s) + len(symbol) + {{ byte_count .Decimal .Minus .FmtCurrencyPrefix .FmtCurrencySuffix }}
579 b := make([]byte, 0, l)
581 for i := len(s) - 1; i >= 0; i-- {
585 {{- if is_multibyte .Decimal }}
586 for j := len({{ .BaseLocale }}.decimal) - 1; j >= 0; j-- {
587 b = append(b, {{ .BaseLocale }}.decimal[j])
590 b = append(b, {{ .BaseLocale }}.decimal[0])
592 {{- if gt .FmtCurrencyGroupLen 0 }}
598 {{ if gt .FmtCurrencyGroupLen 0 }}
601 {{- if gt .FmtCurrencySecondaryGroupLen 0}}
603 if count == groupThreshold {
604 {{- if is_multibyte .Group }}
605 for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- {
606 b = append(b, {{ .BaseLocale }}.group[j])
609 b = append(b, {{ .BaseLocale }}.group[0])
615 groupThreshold = {{ .FmtCurrencySecondaryGroupLen }}
618 if count == {{ .FmtCurrencyGroupLen }} {
619 {{- if is_multibyte .Group }}
620 for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- {
621 b = append(b, {{ .BaseLocale }}.group[j])
624 b = append(b, {{ .BaseLocale }}.group[0])
638 {{ if and .FmtCurrencyInPrefix (not .FmtCurrencyLeft) }}
639 for j := len(symbol) - 1; j >= 0; j-- {
640 b = append(b, symbol[j])
644 {{ if gt (len .FmtCurrencyPrefix) 0}}
645 {{- if is_multibyte .FmtCurrencyPrefix }}
646 for j := len({{ .BaseLocale }}.currencyPositivePrefix) - 1; j >= 0; j-- {
647 b = append(b, {{ .BaseLocale }}.currencyPositivePrefix[j])
650 b = append(b, {{ .BaseLocale }}.currencyPositivePrefix[0])
654 {{ if and .FmtCurrencyInPrefix .FmtCurrencyLeft }}
655 for j := len(symbol) - 1; j >= 0; j-- {
656 b = append(b, symbol[j])
661 {{- if is_multibyte .Minus }}
662 for j := len({{ .BaseLocale }}.minus) - 1; j >= 0; j-- {
663 b = append(b, {{ .BaseLocale }}.minus[j])
666 b = append(b, {{ .BaseLocale }}.minus[0])
671 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
672 b[i], b[j] = b[j], b[i]
675 {{ if gt .FmtCurrencyMinDecimalLen 0 }}
676 if int(v) < {{ .FmtCurrencyMinDecimalLen }} {
679 b = append(b, {{ .BaseLocale }}.decimal...)
682 for i := 0; i < {{ .FmtCurrencyMinDecimalLen }}-int(v); i++ {
688 {{ if and (not .FmtCurrencyInPrefix) .FmtCurrencyLeft }}
689 b = append(b, symbol...)
692 {{ if gt (len .FmtCurrencySuffix) 0}}
693 b = append(b, {{ .BaseLocale }}.currencyPositiveSuffix...)
696 {{ if and (not .FmtCurrencyInPrefix) (not .FmtCurrencyLeft) }}
697 b = append(b, symbol...)
702 return string(append(append([]byte{}, symbol...), s...))
706 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for '{{ .Locale }}'
707 // in accounting notation.
708 func({{ .BaseLocale }} *{{ .Locale }}) FmtAccounting(num float64, v uint64, currency currency.Type) string {
710 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
711 symbol := {{ .BaseLocale }}.currencies[currency]
712 {{- if eq .FmtCurrencyExists true }}
713 {{- if gt .FmtCurrencyGroupLen 0 }}
714 {{- $byteCountGroup := byte_count .Group -}}
715 {{ if ne $byteCountGroup "0" }}
716 l := len(s) + len(symbol) + {{ byte_count .Decimal .Minus .FmtCurrencyNegativePrefix .FmtCurrencyNegativeSuffix }} + {{ $byteCountGroup }} * len(s[:len(s)-int(v)-1]) / {{ .FmtCurrencyGroupLen }}
718 l := len(s) + len(symbol) + {{ byte_count .Decimal .Minus .FmtCurrencyNegativePrefix .FmtCurrencyNegativeSuffix }}
722 {{- if gt .FmtCurrencySecondaryGroupLen 0}}
724 groupThreshold := {{ .FmtCurrencyGroupLen }}
727 l := len(s) + len(symbol) + {{ byte_count .Decimal .Minus .FmtCurrencyNegativePrefix .FmtCurrencyNegativeSuffix }}
729 b := make([]byte, 0, l)
731 for i := len(s) - 1; i >= 0; i-- {
735 {{- if is_multibyte .Decimal }}
736 for j := len({{ .BaseLocale }}.decimal) - 1; j >= 0; j-- {
737 b = append(b, {{ .BaseLocale }}.decimal[j])
740 b = append(b, {{ .BaseLocale }}.decimal[0])
742 {{- if gt .FmtCurrencyGroupLen 0 }}
748 {{ if gt .FmtCurrencyGroupLen 0 }}
751 {{- if gt .FmtCurrencySecondaryGroupLen 0}}
753 if count == groupThreshold {
754 {{- if is_multibyte .Group }}
755 for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- {
756 b = append(b, {{ .BaseLocale }}.group[j])
759 b = append(b, {{ .BaseLocale }}.group[0])
765 groupThreshold = {{ .FmtCurrencySecondaryGroupLen }}
768 if count == {{ .FmtCurrencyGroupLen }} {
769 {{- if is_multibyte .Group }}
770 for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- {
771 b = append(b, {{ .BaseLocale }}.group[j])
774 b = append(b, {{ .BaseLocale }}.group[0])
790 {{ if and .FmtCurrencyNegativeInPrefix (not .FmtCurrencyNegativeLeft) }}
791 for j := len(symbol) - 1; j >= 0; j-- {
792 b = append(b, symbol[j])
796 {{ if gt (len .FmtCurrencyNegativePrefix) 0}}
797 {{- if is_multibyte .FmtCurrencyNegativePrefix }}
798 for j := len({{ .BaseLocale }}.currencyNegativePrefix) - 1; j >= 0; j-- {
799 b = append(b, {{ .BaseLocale }}.currencyNegativePrefix[j])
802 b = append(b, {{ .BaseLocale }}.currencyNegativePrefix[0])
806 {{ if and .FmtCurrencyNegativeInPrefix .FmtCurrencyNegativeLeft }}
807 for j := len(symbol) - 1; j >= 0; j-- {
808 b = append(b, symbol[j])
812 {{ if eq (not .FmtCurrencyNegativeExists) true}}
813 {{- if is_multibyte .Minus }}
814 for j := len({{ .BaseLocale }}.minus) - 1; j >= 0; j-- {
815 b = append(b, {{ .BaseLocale }}.minus[j])
818 b = append(b, {{ .BaseLocale }}.minus[0])
822 {{ if or .FmtCurrencyInPrefix (gt (len .FmtCurrencyPrefix) 0) }}
826 {{ if and .FmtCurrencyInPrefix (not .FmtCurrencyLeft) }}
827 for j := len(symbol) - 1; j >= 0; j-- {
828 b = append(b, symbol[j])
832 {{ if gt (len .FmtCurrencyPrefix) 0}}
833 {{- if is_multibyte .FmtCurrencyPrefix }}
834 for j := len({{ .BaseLocale }}.currencyPositivePrefix) - 1; j >= 0; j-- {
835 b = append(b, {{ .BaseLocale }}.currencyPositivePrefix[j])
838 b = append(b, {{ .BaseLocale }}.currencyPositivePrefix[0])
842 {{ if and .FmtCurrencyInPrefix .FmtCurrencyLeft }}
843 for j := len(symbol) - 1; j >= 0; j-- {
844 b = append(b, symbol[j])
850 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
851 b[i], b[j] = b[j], b[i]
854 {{ if gt .FmtCurrencyMinDecimalLen 0 }}
855 if int(v) < {{ .FmtCurrencyMinDecimalLen }} {
858 b = append(b, {{ .BaseLocale }}.decimal...)
861 for i := 0; i < {{ .FmtCurrencyMinDecimalLen }}-int(v); i++ {
867 {{ if or (not .FmtCurrencyNegativeInPrefix) (gt (len .FmtCurrencyNegativeSuffix) 0)}}
870 {{- if and (not .FmtCurrencyNegativeInPrefix) .FmtCurrencyNegativeLeft }}
871 b = append(b, symbol...)
874 {{- if gt (len .FmtCurrencyNegativeSuffix) 0}}
875 b = append(b, {{ .BaseLocale }}.currencyNegativeSuffix...)
878 {{- if and (not .FmtCurrencyNegativeInPrefix) (not .FmtCurrencyNegativeLeft) }}
879 b = append(b, symbol...)
881 {{ if or (not .FmtCurrencyInPrefix) (gt (len .FmtCurrencySuffix) 0)}}
884 {{- if and (not .FmtCurrencyInPrefix) .FmtCurrencyLeft }}
885 b = append(b, symbol...)
888 {{- if gt (len .FmtCurrencySuffix) 0}}
889 b = append(b, {{ .BaseLocale }}.currencyPositiveSuffix...)
892 {{- if and (not .FmtCurrencyInPrefix) (not .FmtCurrencyLeft) }}
893 b = append(b, symbol...)
895 {{- if or (not .FmtCurrencyNegativeInPrefix) (gt (len .FmtCurrencyNegativeSuffix) 0)}}
901 return string(append(append([]byte{}, symbol...), s...))
905 // FmtDateShort returns the short date representation of 't' for '{{ .Locale }}'
906 func({{ .BaseLocale }} *{{ .Locale }}) FmtDateShort(t time.Time) string {
908 b := make([]byte, 0, 32)
915 // FmtDateMedium returns the medium date representation of 't' for '{{ .Locale }}'
916 func({{ .BaseLocale }} *{{ .Locale }}) FmtDateMedium(t time.Time) string {
918 b := make([]byte, 0, 32)
925 // FmtDateLong returns the long date representation of 't' for '{{ .Locale }}'
926 func({{ .BaseLocale }} *{{ .Locale }}) FmtDateLong(t time.Time) string {
928 b := make([]byte, 0, 32)
935 // FmtDateFull returns the full date representation of 't' for '{{ .Locale }}'
936 func({{ .BaseLocale }} *{{ .Locale }}) FmtDateFull(t time.Time) string {
938 b := make([]byte, 0, 32)
945 // FmtTimeShort returns the short time representation of 't' for '{{ .Locale }}'
946 func({{ .BaseLocale }} *{{ .Locale }}) FmtTimeShort(t time.Time) string {
948 b := make([]byte, 0, 32)
955 // FmtTimeMedium returns the medium time representation of 't' for '{{ .Locale }}'
956 func({{ .BaseLocale }} *{{ .Locale }}) FmtTimeMedium(t time.Time) string {
958 b := make([]byte, 0, 32)
965 // FmtTimeLong returns the long time representation of 't' for '{{ .Locale }}'
966 func({{ .BaseLocale }} *{{ .Locale }}) FmtTimeLong(t time.Time) string {
968 b := make([]byte, 0, 32)
975 // FmtTimeFull returns the full time representation of 't' for '{{ .Locale }}'
976 func({{ .BaseLocale }} *{{ .Locale }}) FmtTimeFull(t time.Time) string {
978 b := make([]byte, 0, 32)