forked from forgejo/forgejo
Added user language setting (#3875)
* Added user language setting * Added translation string for setting * Fixed import order + typo * improved checking if the user has a language saved in the db * The current saved language is now set a default inside the dropdown * fmt * When a user signs in and doesn't have a language saved, the current browser language is saved * updated gitea-sdk * Merge branch 'master' of https://github.com/go-gitea/gitea into save-user-language # Conflicts: # models/migrations/migrations.go # models/migrations/v62.go * Made tests work again * trigger CI * trigger CI * fmt * re-trigger that FUCKING CI SO IT REALLY PICKS UP THE LATEST COMMIT ISTEAD OF PREDENDING TO DO SO * re-trigger that FUCKING CI SO IT REALLY PICKS UP THE LATEST COMMIT ISTEAD OF PREDENDING TO DO SO * When loggin in, only the language col gets updated instead of everything
This commit is contained in:
parent
795dcc8ecf
commit
1fdf560678
13 changed files with 81 additions and 10 deletions
|
@ -178,6 +178,8 @@ var migrations = []Migration{
|
|||
NewMigration("add size column for attachments", addSizeToAttachment),
|
||||
// v62 -> v63
|
||||
NewMigration("add last used passcode column for TOTP", addLastUsedPasscodeTOTP),
|
||||
// v63 -> v64
|
||||
NewMigration("add language column for user setting", addLanguageSetting),
|
||||
}
|
||||
|
||||
// Migrate database to current version
|
||||
|
|
23
models/migrations/v63.go
Normal file
23
models/migrations/v63.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-xorm/xorm"
|
||||
)
|
||||
|
||||
func addLanguageSetting(x *xorm.Engine) error {
|
||||
type User struct {
|
||||
Language string `xorm:"VARCHAR(5)"`
|
||||
}
|
||||
|
||||
if err := x.Sync2(new(User)); err != nil {
|
||||
return fmt.Errorf("Sync2: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -94,6 +94,7 @@ type User struct {
|
|||
Website string
|
||||
Rands string `xorm:"VARCHAR(10)"`
|
||||
Salt string `xorm:"VARCHAR(10)"`
|
||||
Language string `xorm:"VARCHAR(5)"`
|
||||
|
||||
CreatedUnix util.TimeStamp `xorm:"INDEX created"`
|
||||
UpdatedUnix util.TimeStamp `xorm:"INDEX updated"`
|
||||
|
@ -185,6 +186,7 @@ func (u *User) APIFormat() *api.User {
|
|||
FullName: u.FullName,
|
||||
Email: u.getEmail(),
|
||||
AvatarURL: u.AvatarLink(),
|
||||
Language: u.Language,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue