mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
Set default client language when creating them
This commit is contained in:
parent
275227a461
commit
090095b2b9
@ -102,6 +102,7 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) *Client {
|
||||
nickCasefolded: "*",
|
||||
nickMaskString: "*", // * is used until actual nick is given
|
||||
}
|
||||
client.languages = server.languages.Default()
|
||||
|
||||
client.recomputeMaxlens()
|
||||
if isTLS {
|
||||
|
@ -13,13 +13,15 @@ type LanguageManager struct {
|
||||
sync.RWMutex
|
||||
Info map[string]LangData
|
||||
translations map[string]map[string]string
|
||||
defaultLang string
|
||||
}
|
||||
|
||||
// NewLanguageManager returns a new LanguageManager.
|
||||
func NewLanguageManager(languageData map[string]LangData) *LanguageManager {
|
||||
func NewLanguageManager(defaultLang string, languageData map[string]LangData) *LanguageManager {
|
||||
lm := LanguageManager{
|
||||
Info: make(map[string]LangData),
|
||||
translations: make(map[string]map[string]string),
|
||||
defaultLang: defaultLang,
|
||||
}
|
||||
|
||||
// make fake "en" info
|
||||
@ -38,6 +40,17 @@ func NewLanguageManager(languageData map[string]LangData) *LanguageManager {
|
||||
return &lm
|
||||
}
|
||||
|
||||
// Default returns the default languages.
|
||||
func (lm *LanguageManager) Default() []string {
|
||||
lm.RLock()
|
||||
defer lm.RUnlock()
|
||||
|
||||
if lm.defaultLang == "" {
|
||||
return []string{}
|
||||
}
|
||||
return []string{lm.defaultLang}
|
||||
}
|
||||
|
||||
// Count returns how many languages we have.
|
||||
func (lm *LanguageManager) Count() int {
|
||||
lm.RLock()
|
||||
|
@ -150,7 +150,7 @@ func NewServer(config *Config, logger *logger.Manager) (*Server, error) {
|
||||
commands: make(chan Command),
|
||||
connectionLimiter: connection_limits.NewLimiter(),
|
||||
connectionThrottler: connection_limits.NewThrottler(),
|
||||
languages: NewLanguageManager(config.Languages.Data),
|
||||
languages: NewLanguageManager(config.Languages.Default, config.Languages.Data),
|
||||
listeners: make(map[string]*ListenerWrapper),
|
||||
logger: logger,
|
||||
monitorManager: NewMonitorManager(),
|
||||
|
Loading…
Reference in New Issue
Block a user