Skip to content

Commit 24f7bd5

Browse files
authored
Use i18n.Reset to reload locales (#15073)
1 parent 17731e0 commit 24f7bd5

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ require (
120120
github.com/tstranex/u2f v1.0.0
121121
github.com/ulikunitz/xz v0.5.10 // indirect
122122
github.com/unknwon/com v1.0.1
123-
github.com/unknwon/i18n v0.0.0-20200823051745-09abd91c7f2c
123+
github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44
124124
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae
125125
github.com/unrolled/render v1.0.3
126126
github.com/urfave/cli v1.22.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,8 +1111,8 @@ github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0o
11111111
github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM=
11121112
github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs=
11131113
github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM=
1114-
github.com/unknwon/i18n v0.0.0-20200823051745-09abd91c7f2c h1:679/gJXwrsHC3RATr0YYjZvDMJPYN7W9FGSGNoLmKxM=
1115-
github.com/unknwon/i18n v0.0.0-20200823051745-09abd91c7f2c/go.mod h1:+5rDk6sDGpl3azws3O+f+GpFSyN9GVr0K8cvQLQM2ZQ=
1114+
github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44 h1:7bSo/vjZKVYUoZfxpYh9Y9JV+9hi1gYJp4WIykhrZag=
1115+
github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44/go.mod h1:+5rDk6sDGpl3azws3O+f+GpFSyN9GVr0K8cvQLQM2ZQ=
11161116
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae h1:ihaXiJkaca54IaCSnEXtE/uSZOmPxKZhDfVLrzZLFDs=
11171117
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae/go.mod h1:1fdkY6xxl6ExVs2QFv7R0F5IRZHKA8RahhB9fMC9RvM=
11181118
github.com/unrolled/render v1.0.3 h1:baO+NG1bZSF2WR4zwh+0bMWauWky7DVrTOfvE2w+aFo=

modules/translation/translation.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
package translation
66

77
import (
8-
"errors"
9-
108
"code.gitea.io/gitea/modules/log"
119
"code.gitea.io/gitea/modules/options"
1210
"code.gitea.io/gitea/modules/setting"
@@ -38,6 +36,7 @@ func AllLangs() []LangType {
3836

3937
// InitLocales loads the locales
4038
func InitLocales() {
39+
i18n.Reset()
4140
localeNames, err := options.Dir("locale")
4241
if err != nil {
4342
log.Fatal("Failed to list locale files: %v", err)
@@ -60,12 +59,7 @@ func InitLocales() {
6059
for i := range setting.Names {
6160
key := "locale_" + setting.Langs[i] + ".ini"
6261
if err = i18n.SetMessageWithDesc(setting.Langs[i], setting.Names[i], localFiles[key]); err != nil {
63-
if errors.Is(err, i18n.ErrLangAlreadyExist) {
64-
// just log if lang is already loaded since we can not reload it
65-
log.Warn("Can not load language '%s' since already loaded", setting.Langs[i])
66-
} else {
67-
log.Error("Failed to set messages to %s: %v", setting.Langs[i], err)
68-
}
62+
log.Error("Failed to set messages to %s: %v", setting.Langs[i], err)
6963
}
7064
}
7165
i18n.SetDefaultLang("en-US")

vendor/github.com/unknwon/i18n/i18n.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ github.com/ulikunitz/xz/lzma
772772
# github.com/unknwon/com v1.0.1
773773
## explicit
774774
github.com/unknwon/com
775-
# github.com/unknwon/i18n v0.0.0-20200823051745-09abd91c7f2c
775+
# github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44
776776
## explicit
777777
github.com/unknwon/i18n
778778
# github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae

0 commit comments

Comments
 (0)