// DragonX Wallet - ImGui Edition // Copyright 2024-2026 The Hush Developers // Released under the GPLv3 #pragma once #include #include #include 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>& 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 strings_; std::vector> 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)