summaryrefslogtreecommitdiffstats
path: root/modules/base
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-04-04 00:58:09 +0800
committerGitHub <noreply@github.com>2023-04-03 12:58:09 -0400
commit19de52e0f4cbd2d62f9d41589fe8815c2c3ceef2 (patch)
treef5e2f0a5431f315946aed6d72e40e5e9893dabc0 /modules/base
parent01d9466bfdbb2e043a03368ca7872944db211f49 (diff)
downloadgitea-19de52e0f4cbd2d62f9d41589fe8815c2c3ceef2.tar.gz
gitea-19de52e0f4cbd2d62f9d41589fe8815c2c3ceef2.zip
Introduce GiteaLocaleNumber custom element to handle number localization on pages. (#23861)
Follow #21429 & #22861 Use `<gitea-locale-number>` instead of backend `PrettyNumber`. All old `PrettyNumber` related functions are removed. A lot of code could be simplified. And some functions haven't been used for long time (dead code), so they are also removed by the way (eg: `SplitStringAtRuneN`, `Dedent`) This PR only tries to improve the `PrettyNumber` rendering problem, it doesn't touch the "plural" problem. Screenshot: ![image](https://user-images.githubusercontent.com/2114189/229290804-1f63db65-1e34-4a54-84ba-e00b44331b17.png) ![image](https://user-images.githubusercontent.com/2114189/229290911-c88dea00-b11d-48dd-accb-9f52edd73ce4.png)
Diffstat (limited to 'modules/base')
-rw-r--r--modules/base/tool.go7
-rw-r--r--modules/base/tool_test.go7
2 files changed, 0 insertions, 14 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index 94f19576b4..bd3a8458ee 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -22,7 +22,6 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
- "code.gitea.io/gitea/modules/util"
"github.com/dustin/go-humanize"
"github.com/minio/sha256-simd"
@@ -142,12 +141,6 @@ func FileSize(s int64) string {
return humanize.IBytes(uint64(s))
}
-// PrettyNumber produces a string form of the given number in base 10 with
-// commas after every three orders of magnitude
-func PrettyNumber(i interface{}) string {
- return humanize.Comma(util.NumberIntoInt64(i))
-}
-
// Subtract deals with subtraction of all types of number.
func Subtract(left, right interface{}) interface{} {
var rleft, rright int64
diff --git a/modules/base/tool_test.go b/modules/base/tool_test.go
index 81f4b464e6..33677a910c 100644
--- a/modules/base/tool_test.go
+++ b/modules/base/tool_test.go
@@ -114,13 +114,6 @@ func TestFileSize(t *testing.T) {
assert.Equal(t, "2.0 EiB", FileSize(size))
}
-func TestPrettyNumber(t *testing.T) {
- assert.Equal(t, "23,342,432", PrettyNumber(23342432))
- assert.Equal(t, "23,342,432", PrettyNumber(int32(23342432)))
- assert.Equal(t, "0", PrettyNumber(0))
- assert.Equal(t, "-100,000", PrettyNumber(-100000))
-}
-
func TestSubtract(t *testing.T) {
toFloat64 := func(n interface{}) float64 {
switch v := n.(type) {