mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-25 06:02:49 +00:00
feat(dashboard): every request and page gets game text in the viewer's language
The dashboard loads every language in the client's locale; each request runs in the viewer's language (Workers::Reply carries it to the worker), templates get game.* and phrase()/zone_name(), scripts get GameText.* on <body data-game>, and the user menu picks the game text language. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <exception>
|
||||
#include <thread>
|
||||
|
||||
#include "GameText.h"
|
||||
#include "RouteUtils.h"
|
||||
#include "Web.h"
|
||||
|
||||
@@ -37,8 +38,10 @@ namespace Workers {
|
||||
if (ready || !g_Pool.Running()) return fill(reply);
|
||||
const auto deferred = Web::Defer(reply, context);
|
||||
const auto path = context.path;
|
||||
g_Pool.Submit(priority, [deferred, path, fill = std::move(fill)] {
|
||||
// The worker writes game text in the viewer's language too
|
||||
g_Pool.Submit(priority, [deferred, path, language = GameText::Language(), fill = std::move(fill)] {
|
||||
if (deferred.Cancelled()) return;
|
||||
const GameText::LanguageScope scope(language);
|
||||
HTTPReply out;
|
||||
try {
|
||||
fill(out);
|
||||
|
||||
Reference in New Issue
Block a user