package localization import ( "RenewCMS/internal/domain/language" "RenewCMS/internal/domain/site" ) type SetupSuggestion struct { Lang string `json:"lang"` Substituted bool `json:"substituted"` } type PendingSite struct { Key string `json:"key"` Name string `json:"name"` Locale *string `json:"locale"` ArticleCount int `json:"article_count"` Suggestion *SetupSuggestion `json:"suggestion"` } type SetupView struct { Sites []PendingSite `json:"sites"` Available []Option `json:"available"` } type SetupChoice struct { Key string Lang string } type SetupAssignment struct { Key string `json:"key"` Lang string `json:"lang"` Assigned int `json:"assigned"` } type SetupResult struct { Assigned int `json:"assigned"` Sites []SetupAssignment `json:"sites"` Skipped []string `json:"skipped"` } func NewPendingSite(s site.Site) PendingSite { pending := PendingSite{Key: s.Key, Name: s.Name, Locale: s.Locale, ArticleCount: s.ArticleCount} if suggestion := language.Suggest(s.Locale); suggestion.Found { pending.Suggestion = &SetupSuggestion{Lang: suggestion.Tag, Substituted: suggestion.Substituted} } return pending }