Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/locales.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lt_LT/lt_LT.go')
-rw-r--r--lt_LT/lt_LT.go22
1 files changed, 9 insertions, 13 deletions
diff --git a/lt_LT/lt_LT.go b/lt_LT/lt_LT.go
index 0eae5832..8eb26c83 100644
--- a/lt_LT/lt_LT.go
+++ b/lt_LT/lt_LT.go
@@ -54,8 +54,8 @@ func (lt *lt_LT) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
n := math.Abs(num)
f := locales.F(n, v)
- nMod100 := math.Mod(n, 100)
nMod10 := math.Mod(n, 10)
+ nMod100 := math.Mod(n, 100)
if nMod10 == 1 && nMod100 < 11 && nMod100 > 19 {
return locales.PluralRuleOne
@@ -120,32 +120,23 @@ func (lt *lt_LT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint6
// avoid allocations; otherwise just cast as string.
func (lt *lt_LT) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(lt.decimal) + len(lt.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] == '.' {
-
- for j := len(lt.decimal) - 1; j >= 0; j-- {
- b = append(b, lt.decimal[j])
- }
-
+ b = append(b, lt.decimal[0])
inWhole = true
continue
}
if inWhole {
-
if count == 3 {
-
for j := len(lt.group) - 1; j >= 0; j-- {
b = append(b, lt.group[j])
}
@@ -159,11 +150,16 @@ func (lt *lt_LT) FmtNumber(num float64, v uint64) []byte {
b = append(b, s[i])
}
+ if num < 0 {
+ for j := len(lt.minus) - 1; j >= 0; j-- {
+ b = append(b, lt.minus[j])
+ }
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}