aboutsummaryrefslogtreecommitdiffstats
path: root/modules/csv
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-04-17 11:37:23 +0800
committerGitHub <noreply@github.com>2023-04-17 11:37:23 +0800
commit7681d582cdae42d9322309ddf732117e6d332776 (patch)
tree6cdfa61a2055f23153884404fe93d4b4792fd532 /modules/csv
parentbe7cd73439c2210bfd889915f74d66686e99dab6 (diff)
downloadgitea-7681d582cdae42d9322309ddf732117e6d332776.tar.gz
gitea-7681d582cdae42d9322309ddf732117e6d332776.zip
Refactor locale number (#24134)
Before, the `GiteaLocaleNumber.js` was just written as a a drop-in replacement for old `js-pretty-number`. Actually, we can use Golang's `text` package to format. This PR partially completes the TODOs in `GiteaLocaleNumber.js`: > if we have complete backend locale support (eg: Golang "x/text" package), we can drop this component. > tooltip: only 2 usages of this, we can replace it with Golang's "x/text/number" package in the future. This PR also helps #24131 Screenshots: <details> ![image](https://user-images.githubusercontent.com/2114189/232179420-b1b9974b-9d96-4408-b209-b80182c8b359.png) ![image](https://user-images.githubusercontent.com/2114189/232179416-14f36aa0-3f3e-4ac9-b366-7bd3a4464a11.png) </details>
Diffstat (limited to 'modules/csv')
-rw-r--r--modules/csv/csv_test.go17
1 files changed, 2 insertions, 15 deletions
diff --git a/modules/csv/csv_test.go b/modules/csv/csv_test.go
index 6b91a81fc4..f6e782a5a4 100644
--- a/modules/csv/csv_test.go
+++ b/modules/csv/csv_test.go
@@ -13,6 +13,7 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/markup"
+ "code.gitea.io/gitea/modules/translation"
"github.com/stretchr/testify/assert"
)
@@ -550,20 +551,6 @@ a|"he said, ""here I am"""`,
}
}
-type mockLocale struct{}
-
-func (l mockLocale) Language() string {
- return "en"
-}
-
-func (l mockLocale) Tr(s string, _ ...interface{}) string {
- return s
-}
-
-func (l mockLocale) TrN(_cnt interface{}, key1, _keyN string, _args ...interface{}) string {
- return key1
-}
-
func TestFormatError(t *testing.T) {
cases := []struct {
err error
@@ -591,7 +578,7 @@ func TestFormatError(t *testing.T) {
}
for n, c := range cases {
- message, err := FormatError(c.err, mockLocale{})
+ message, err := FormatError(c.err, &translation.MockLocale{})
if c.expectsError {
assert.Error(t, err, "case %d: expected an error to be returned", n)
} else {