From 99b774e741a1d222d42518c276987e689a6a490a Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 25 Mar 2015 19:51:22 -0400 Subject: [PATCH] auto fix locale file name change --- models/migrations/migrations.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 94cab453f6..7ad0cbdd12 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -11,6 +11,7 @@ import ( "github.com/Unknwon/com" "github.com/go-xorm/xorm" + "gopkg.in/ini.v1" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/setting" @@ -54,6 +55,7 @@ var migrations = []Migration{ NewMigration("make authorize 4 if team is owners", ownerTeamUpdate), // V1 -> V2:v0.5.13 NewMigration("refactor access table to use id's", accessRefactor), // V2 -> V3:v0.5.13 NewMigration("generate team-repo from team", teamToTeamRepo), // V3 -> V4:v0.5.13 + NewMigration("fix locale file load panic", fixLocaleFileLoadPanic), // V4 -> V5:v0.6.0 } // Migrate database to current version @@ -372,3 +374,18 @@ func teamToTeamRepo(x *xorm.Engine) error { return sess.Commit() } + +func fixLocaleFileLoadPanic(_ *xorm.Engine) error { + cfg, err := ini.Load(setting.CustomConf) + if err != nil { + return fmt.Errorf("load custom config: %v", err) + } + + cfg.DeleteSection("i18n") + if err = cfg.SaveTo(setting.CustomConf); err != nil { + return fmt.Errorf("save custom config: %v", err) + } + + setting.Langs = strings.Split(strings.Replace(strings.Join(setting.Langs, ","), "fr-CA", "fr-FR", 1), ",") + return nil +}