summaryrefslogtreecommitdiffstats
path: root/modules/test/context_tests.go
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/test/context_tests.go
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/test/context_tests.go')
-rw-r--r--modules/test/context_tests.go17
1 files changed, 2 insertions, 15 deletions
diff --git a/modules/test/context_tests.go b/modules/test/context_tests.go
index 94dbd2f290..e558bf1b9f 100644
--- a/modules/test/context_tests.go
+++ b/modules/test/context_tests.go
@@ -18,6 +18,7 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
+ "code.gitea.io/gitea/modules/translation"
"code.gitea.io/gitea/modules/web/middleware"
chi "github.com/go-chi/chi/v5"
@@ -34,7 +35,7 @@ func MockContext(t *testing.T, path string) *context.Context {
Values: make(url.Values),
},
Resp: context.NewResponse(resp),
- Locale: &mockLocale{},
+ Locale: &translation.MockLocale{},
}
defer ctx.Close()
@@ -91,20 +92,6 @@ func LoadGitRepo(t *testing.T, ctx *context.Context) {
assert.NoError(t, err)
}
-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
-}
-
type mockResponseWriter struct {
httptest.ResponseRecorder
size int