mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-25 22:22:48 +00:00
feat(locale): load every locale in locale.xml on request
Locale::LoadFromFile can keep the other locales' phrases too, and GetPhrase(id, locale) answers in one of them, falling back to the default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,8 +5,17 @@
|
||||
#include <vector>
|
||||
|
||||
namespace Locale {
|
||||
void LoadFromFile(const std::string& filepath, const std::string& locale = "en_US");
|
||||
/**
|
||||
* Load the client's locale.xml: the phrases of `locale` (the default, which GetPhrase(id) answers from) and, with
|
||||
* `allLocales`, those of every other locale the file lists too. Replaces what an earlier load read. Call before
|
||||
* other threads read phrases; lookups only read afterwards.
|
||||
*/
|
||||
void LoadFromFile(const std::string& filepath, const std::string& locale = "en_US", bool allLocales = false);
|
||||
const std::string& GetPhrase(const std::string& phraseId);
|
||||
// The phrase in `locale`, else in the default locale; empty when neither has it
|
||||
const std::string& GetPhrase(const std::string& phraseId, const std::string& locale);
|
||||
// The locales loaded ("en_US", "de_DE", ...), the default first; empty before a load
|
||||
const std::vector<std::string>& GetLocales();
|
||||
bool IsLoaded();
|
||||
std::vector<std::string> GetPhraseIdsWithPrefix(const std::string& prefix);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user