diff options
author | joeybloggs <Dean.Karn@gmail.com> | 2016-08-15 05:41:26 +0300 |
---|---|---|
committer | joeybloggs <Dean.Karn@gmail.com> | 2016-08-15 05:41:26 +0300 |
commit | 15e8d9841c4e3269faa135537ab14e77ae1a0a81 (patch) | |
tree | bd1e150efc7f3b56df3400489d168b21b9ff7913 /tr_TR | |
parent | fb2acb93602d54a9be9ff735bcabbe17a66cb876 (diff) |
sure up percent prefix logic, just need to turn prefixes into bytes...
Diffstat (limited to 'tr_TR')
-rw-r--r-- | tr_TR/tr_TR.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tr_TR/tr_TR.go b/tr_TR/tr_TR.go index 2f69d8ab..f174fcfb 100644 --- a/tr_TR/tr_TR.go +++ b/tr_TR/tr_TR.go @@ -133,17 +133,29 @@ func (tr *tr_TR) FmtNumber(num float64, v uint64) []byte { func (tr *tr_TR) FmtPercent(num float64, v uint64) []byte { s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) - l := len(s) + len(tr.decimal) - + l := len(s) + len(tr.decimal) + len(tr.group)*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 b := make([]byte, 0, l) for i := len(s) - 1; i >= 0; i-- { if s[i] == '.' { b = append(b, tr.decimal[0]) + inWhole = true + continue } + if inWhole { + if count == 3 { + b = append(b, tr.group[0]) + count = 1 + } else { + count++ + } + } + b = append(b, s[i]) } @@ -151,7 +163,7 @@ func (tr *tr_TR) FmtPercent(num float64, v uint64) []byte { b = append(b, tr.minus[0]) } - b = append(b, tr.Percent[0]) + b = append(b, tr.percent[0]) // reverse for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { |