ObsidianDragon - DragonX ImGui Wallet
Full-node GUI wallet for DragonX cryptocurrency. Built with Dear ImGui, SDL3, and OpenGL3/DX11. Features: - Send/receive shielded and transparent transactions - Autoshield with merged transaction display - Built-in CPU mining (xmrig) - Peer management and network monitoring - Wallet encryption with PIN lock - QR code generation for receive addresses - Transaction history with pagination - Console for direct RPC commands - Cross-platform (Linux, Windows)
This commit is contained in:
79
src/util/i18n.h
Normal file
79
src/util/i18n.h
Normal file
@@ -0,0 +1,79 @@
|
||||
// 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();
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user