- Replace all hardcoded English strings with TR() translation keys across every tab, dialog, and component (~20 UI files) - Expand all 8 language files (de, es, fr, ja, ko, pt, ru, zh) with complete translations (~37k lines added) - Improve i18n loader with exe-relative path fallback and English base fallback for missing keys - Add pool-side hashrate polling via pool stats API in xmrig_manager - Introduce Layout::beginFrame() per-frame caching and refresh balance layout config only on schema generation change - Offload daemon output parsing to worker thread - Add CJK subset fallback font for Chinese/Japanese/Korean glyphs
81 lines
2.0 KiB
C++
81 lines
2.0 KiB
C++
// DragonX Wallet - ImGui Edition
|
|
// Copyright 2024-2026 The Hush Developers
|
|
// Released under the GPLv3
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
namespace dragonx {
|
|
namespace util {
|
|
|
|
/**
|
|
* @brief Internationalization support
|
|
*
|
|
* Simple string table implementation for translating UI text.
|
|
* Strings are stored in JSON files in res/lang/ directory.
|
|
*/
|
|
class I18n {
|
|
public:
|
|
/**
|
|
* @brief Get the singleton instance
|
|
*/
|
|
static I18n& instance();
|
|
|
|
/**
|
|
* @brief Load a language file
|
|
* @param locale Language code (e.g., "en", "es", "zh")
|
|
* @return true if loaded successfully
|
|
*/
|
|
bool loadLanguage(const std::string& locale);
|
|
|
|
/**
|
|
* @brief Translate a string
|
|
* @param key The string key (usually English text)
|
|
* @return Translated string, or key if not found
|
|
*/
|
|
const char* translate(const char* key) const;
|
|
|
|
/**
|
|
* @brief Get current locale
|
|
*/
|
|
const std::string& getCurrentLocale() const { return current_locale_; }
|
|
|
|
/**
|
|
* @brief Get list of available languages
|
|
*/
|
|
const std::vector<std::pair<std::string, std::string>>& getAvailableLanguages() const { return available_languages_; }
|
|
|
|
/**
|
|
* @brief Register an available language
|
|
* @param code Language code (e.g., "en")
|
|
* @param name Display name (e.g., "English")
|
|
*/
|
|
void registerLanguage(const std::string& code, const std::string& name);
|
|
|
|
private:
|
|
I18n();
|
|
void loadBuiltinEnglish();
|
|
|
|
std::string current_locale_ = "en";
|
|
std::unordered_map<std::string, std::string> strings_;
|
|
std::vector<std::pair<std::string, std::string>> available_languages_;
|
|
};
|
|
|
|
/**
|
|
* @brief Convenience function for translation
|
|
* @param key The string key
|
|
* @return Translated string
|
|
*/
|
|
inline const char* tr(const char* key) {
|
|
return I18n::instance().translate(key);
|
|
}
|
|
|
|
} // namespace util
|
|
} // namespace dragonx
|
|
|
|
// Convenience macro for translations
|
|
#define TR(key) dragonx::util::tr(key)
|