initial commit. Cloned timetracker repository
This commit is contained in:
67
app/model/i18n.go
Normal file
67
app/model/i18n.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// contextKey is a custom type for context keys
|
||||
type contextKey string
|
||||
|
||||
// ContextLanguageID is the key for storing language ID in context
|
||||
const ContextLanguageID contextKey = "languageID"
|
||||
|
||||
type Translation struct {
|
||||
LangID uint `gorm:"primaryKey;column:lang_id"`
|
||||
ScopeID uint `gorm:"primaryKey;column:scope_id"`
|
||||
ComponentID uint `gorm:"primaryKey;column:component_id"`
|
||||
Key string `gorm:"primaryKey;size:255;column:key"`
|
||||
Data *string `gorm:"type:text;column:data"`
|
||||
|
||||
Language Language `gorm:"foreignKey:LangID;references:ID;constraint:OnUpdate:RESTRICT,OnDelete:RESTRICT"`
|
||||
Scope Scope `gorm:"foreignKey:ScopeID;references:ID;constraint:OnUpdate:RESTRICT,OnDelete:RESTRICT"`
|
||||
Component Component `gorm:"foreignKey:ComponentID;references:ID;constraint:OnUpdate:RESTRICT,OnDelete:RESTRICT"`
|
||||
}
|
||||
|
||||
func (Translation) TableName() string {
|
||||
return "translations"
|
||||
}
|
||||
|
||||
type Language struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement;column:id"`
|
||||
CreatedAt time.Time `gorm:"not null;column:created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index:idx_language_deleted_at;column:deleted_at"`
|
||||
Name string `gorm:"size:128;not null;column:name"`
|
||||
ISOCode string `gorm:"size:2;not null;column:iso_code"`
|
||||
LangCode string `gorm:"size:5;not null;column:lang_code"`
|
||||
DateFormat string `gorm:"size:32;not null;column:date_format"`
|
||||
DateFormatShort string `gorm:"size:32;not null;column:date_format_short"`
|
||||
RTL bool `gorm:"not null;default:0;column:rtl"`
|
||||
IsDefault bool `gorm:"not null;default:0;column:is_default;comment:there should be only one default language"`
|
||||
Active bool `gorm:"not null;default:1;column:active"`
|
||||
Flag string `gorm:"size:16;not null;column:flag"`
|
||||
}
|
||||
|
||||
func (Language) TableName() string {
|
||||
return "language"
|
||||
}
|
||||
|
||||
type Component struct {
|
||||
ID uint64 `gorm:"primaryKey;autoIncrement;column:id"`
|
||||
Name string `gorm:"size:255;not null;uniqueIndex:uk_components_name;column:name"`
|
||||
}
|
||||
|
||||
func (Component) TableName() string {
|
||||
return "components"
|
||||
}
|
||||
|
||||
type Scope struct {
|
||||
ID uint64 `gorm:"primaryKey;autoIncrement;column:id"`
|
||||
Name string `gorm:"size:255;not null;uniqueIndex:uk_scopes_name;column:name"`
|
||||
}
|
||||
|
||||
func (Scope) TableName() string {
|
||||
return "scopes"
|
||||
}
|
||||
Reference in New Issue
Block a user