mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-15 01:25:00 +03:00
fix(i18n): publish the translation bundle only once it is complete
InitLocalizer filled the shared bundle in place, and the Telegram bot runs it again while the panel is serving, so a request could read the bundle's maps while they were being written and the process died on a concurrent map access. Build the bundle privately and publish it, and the bot and web localizers, through atomic pointers; the lazy load in the middleware publishes only if nothing else did first.
This commit is contained in:
@@ -291,9 +291,8 @@ func TestNotifyExhaustedLooksUpEachIDOnce(t *testing.T) {
|
||||
func TestServerUsageInfoShowsUnavailableUptime(t *testing.T) {
|
||||
bundle := i18n.NewBundle(language.English)
|
||||
_ = bundle.AddMessages(language.English, &i18n.Message{ID: "tgbot.messages.serverUpTime", Other: "Uptime: {{.UpTime}} {{.Unit}}\n"}, &i18n.Message{ID: "tgbot.days", Other: "days"})
|
||||
oldLocale := locale.LocalizerBot
|
||||
locale.LocalizerBot = i18n.NewLocalizer(bundle, "en")
|
||||
t.Cleanup(func() { locale.LocalizerBot = oldLocale })
|
||||
oldLocale := locale.SwapBotLocalizer(i18n.NewLocalizer(bundle, "en"))
|
||||
t.Cleanup(func() { locale.SwapBotLocalizer(oldLocale) })
|
||||
statusCache.mutex.Lock()
|
||||
oldStatus, oldTime := statusCache.data, statusCache.timestamp
|
||||
statusCache.mutex.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user