aboutsummaryrefslogtreecommitdiffstats
path: root/routers/init.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-01-05 21:05:40 +0800
committerGitHub <noreply@github.com>2021-01-05 21:05:40 +0800
commit15a475b7dbcf7923d9518dff7764b20e404eb774 (patch)
tree8789f1f82c5e41345b442df4e58120bdd5f8bade /routers/init.go
parent126c9331d6d8789563fae5d5bac2196d63fee0e8 (diff)
downloadgitea-15a475b7dbcf7923d9518dff7764b20e404eb774.tar.gz
gitea-15a475b7dbcf7923d9518dff7764b20e404eb774.zip
Fix recovery middleware to render gitea style page. (#13857)
* Some changes to fix recovery * Move Recovery to middlewares * Remove trace code * Fix lint * add session middleware and remove dependent on macaron for sso * Fix panic 500 page rendering * Fix bugs * Fix fmt * Fix vendor * recover unnecessary change * Fix lint and addd some comments about the copied codes. * Use util.StatDir instead of com.StatDir Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'routers/init.go')
-rw-r--r--routers/init.go34
1 files changed, 3 insertions, 31 deletions
diff --git a/routers/init.go b/routers/init.go
index ca8944bb2b..ff2ddcc0b7 100644
--- a/routers/init.go
+++ b/routers/init.go
@@ -26,19 +26,18 @@ import (
"code.gitea.io/gitea/modules/markup/external"
repo_migrations "code.gitea.io/gitea/modules/migrations"
"code.gitea.io/gitea/modules/notification"
- "code.gitea.io/gitea/modules/options"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/ssh"
"code.gitea.io/gitea/modules/storage"
"code.gitea.io/gitea/modules/svg"
"code.gitea.io/gitea/modules/task"
+ "code.gitea.io/gitea/modules/translation"
"code.gitea.io/gitea/services/mailer"
mirror_service "code.gitea.io/gitea/services/mirror"
pull_service "code.gitea.io/gitea/services/pull"
"code.gitea.io/gitea/services/repository"
"code.gitea.io/gitea/services/webhook"
- "gitea.com/macaron/i18n"
"gitea.com/macaron/macaron"
)
@@ -93,33 +92,6 @@ func initDBEngine(ctx context.Context) (err error) {
return nil
}
-// InitLocales loads the locales
-func InitLocales() {
- localeNames, err := options.Dir("locale")
-
- if err != nil {
- log.Fatal("Failed to list locale files: %v", err)
- }
- localFiles := make(map[string][]byte)
-
- for _, name := range localeNames {
- localFiles[name], err = options.Locale(name)
-
- if err != nil {
- log.Fatal("Failed to load %s locale file. %v", name, err)
- }
- }
- i18n.I18n(i18n.Options{
- SubURL: setting.AppSubURL,
- Files: localFiles,
- Langs: setting.Langs,
- Names: setting.Names,
- DefaultLang: "en-US",
- Redirect: false,
- CookieDomain: setting.SessionConfig.Domain,
- })
-}
-
// PreInstallInit preloads the configuration to check if we need to run install
func PreInstallInit(ctx context.Context) bool {
setting.NewContext()
@@ -129,7 +101,7 @@ func PreInstallInit(ctx context.Context) bool {
log.Trace("Custom path: %s", setting.CustomPath)
log.Trace("Log path: %s", setting.LogRootPath)
log.Trace("Preparing to run install page")
- InitLocales()
+ translation.InitLocales()
if setting.EnableSQLite3 {
log.Info("SQLite3 Supported")
}
@@ -170,7 +142,7 @@ func GlobalInit(ctx context.Context) {
log.Trace("Log path: %s", setting.LogRootPath)
// Setup i18n
- InitLocales()
+ translation.InitLocales()
NewServices()