mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-27 07:16:17 +00:00
Rename ByteSize to ReadableSize
This commit is contained in:
parent
d2cd1342bf
commit
470886bf52
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
files_service "code.gitea.io/gitea/services/repository/files"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue