summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
author0ko <0ko@noreply.codeberg.org>2024-03-31 17:17:12 +0200
committer0ko <0ko@noreply.codeberg.org>2024-03-31 17:17:12 +0200
commitc2d137d1f24cb03fad9685694529068276f5f302 (patch)
tree022635fb60ac32268d41b0cbb50293576c86ec2a /modules
parentDeprecate usage of FileSize in templates (diff)
downloadforgejo-c2d137d1f24cb03fad9685694529068276f5f302.tar.xz
forgejo-c2d137d1f24cb03fad9685694529068276f5f302.zip
Rename ByteSize to ReadableSize
Diffstat (limited to 'modules')
-rw-r--r--modules/translation/mock.go4
-rw-r--r--modules/translation/translation.go12
2 files changed, 8 insertions, 8 deletions
diff --git a/modules/translation/mock.go b/modules/translation/mock.go
index c4f8822db3..fe3a1502ea 100644
--- a/modules/translation/mock.go
+++ b/modules/translation/mock.go
@@ -31,8 +31,8 @@ func (l MockLocale) TrN(cnt any, key1, keyN string, args ...any) template.HTML {
return template.HTML(key1)
}
-func (l MockLocale) TrSize(s int64) ByteSize {
- return ByteSize{fmt.Sprint(s), ""}
+func (l MockLocale) TrSize(s int64) ReadableSize {
+ return ReadableSize{fmt.Sprint(s), ""}
}
func (l MockLocale) PrettyNumber(v any) string {
diff --git a/modules/translation/translation.go b/modules/translation/translation.go
index a6013a288f..16eb55e28e 100644
--- a/modules/translation/translation.go
+++ b/modules/translation/translation.go
@@ -15,8 +15,8 @@ import (
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/translation/i18n"
"code.gitea.io/gitea/modules/util"
- "github.com/dustin/go-humanize"
+ "github.com/dustin/go-humanize"
"golang.org/x/text/language"
"golang.org/x/text/message"
"golang.org/x/text/number"
@@ -34,7 +34,7 @@ type Locale interface {
Tr(key string, args ...any) template.HTML
TrN(cnt any, key1, keyN string, args ...any) template.HTML
- TrSize(size int64) ByteSize
+ TrSize(size int64) ReadableSize
PrettyNumber(v any) string
}
@@ -255,18 +255,18 @@ func (l *locale) TrN(cnt any, key1, keyN string, args ...any) template.HTML {
return l.Tr(keyN, args...)
}
-type ByteSize struct {
+type ReadableSize struct {
PrettyNumber string
TranslatedUnit string
}
-func (bs ByteSize) String() string {
+func (bs ReadableSize) String() string {
return bs.PrettyNumber + " " + bs.TranslatedUnit
}
// TrSize returns array containing pretty formatted size and localized output of FileSize
// output of humanize.IBytes has to be split in order to be localized
-func (l *locale) TrSize(s int64) ByteSize {
+func (l *locale) TrSize(s int64) ReadableSize {
us := uint64(s)
if s < 0 {
us = uint64(-s)
@@ -281,7 +281,7 @@ func (l *locale) TrSize(s int64) ByteSize {
}
numberVal = l.PrettyNumber(numberVal)
unitVal = l.TrString("munits.data." + strings.ToLower(unitVal))
- return ByteSize{numberVal, unitVal}
+ return ReadableSize{numberVal, unitVal}
}
func (l *locale) PrettyNumber(v any) string {