mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-23 03:02:48 +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: "*",
|
nickCasefolded: "*",
|
||||||
nickMaskString: "*", // * is used until actual nick is given
|
nickMaskString: "*", // * is used until actual nick is given
|
||||||
}
|
}
|
||||||
|
client.languages = server.languages.Default()
|
||||||
|
|
||||||
client.recomputeMaxlens()
|
client.recomputeMaxlens()
|
||||||
if isTLS {
|
if isTLS {
|
||||||
|
@ -13,13 +13,15 @@ type LanguageManager struct {
|
|||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
Info map[string]LangData
|
Info map[string]LangData
|
||||||
translations map[string]map[string]string
|
translations map[string]map[string]string
|
||||||
|
defaultLang string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLanguageManager returns a new LanguageManager.
|
// NewLanguageManager returns a new LanguageManager.
|
||||||
func NewLanguageManager(languageData map[string]LangData) *LanguageManager {
|
func NewLanguageManager(defaultLang string, languageData map[string]LangData) *LanguageManager {
|
||||||
lm := LanguageManager{
|
lm := LanguageManager{
|
||||||
Info: make(map[string]LangData),
|
Info: make(map[string]LangData),
|
||||||
translations: make(map[string]map[string]string),
|
translations: make(map[string]map[string]string),
|
||||||
|
defaultLang: defaultLang,
|
||||||
}
|
}
|
||||||
|
|
||||||
// make fake "en" info
|
// make fake "en" info
|
||||||
@ -38,6 +40,17 @@ func NewLanguageManager(languageData map[string]LangData) *LanguageManager {
|
|||||||
return &lm
|
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.
|
// Count returns how many languages we have.
|
||||||
func (lm *LanguageManager) Count() int {
|
func (lm *LanguageManager) Count() int {
|
||||||
lm.RLock()
|
lm.RLock()
|
||||||
|
@ -150,7 +150,7 @@ func NewServer(config *Config, logger *logger.Manager) (*Server, error) {
|
|||||||
commands: make(chan Command),
|
commands: make(chan Command),
|
||||||
connectionLimiter: connection_limits.NewLimiter(),
|
connectionLimiter: connection_limits.NewLimiter(),
|
||||||
connectionThrottler: connection_limits.NewThrottler(),
|
connectionThrottler: connection_limits.NewThrottler(),
|
||||||
languages: NewLanguageManager(config.Languages.Data),
|
languages: NewLanguageManager(config.Languages.Default, config.Languages.Data),
|
||||||
listeners: make(map[string]*ListenerWrapper),
|
listeners: make(map[string]*ListenerWrapper),
|
||||||
logger: logger,
|
logger: logger,
|
||||||
monitorManager: NewMonitorManager(),
|
monitorManager: NewMonitorManager(),
|
||||||
|
Loading…
Reference in New Issue
Block a user