diff --git a/lttoolbox/i18n.h b/lttoolbox/i18n.h index a8fb4a1..14b3aff 100644 --- a/lttoolbox/i18n.h +++ b/lttoolbox/i18n.h @@ -25,11 +25,11 @@ class I18n public: I18n(const char *locales_path, std::string package_name); icu::UnicodeString format(const char* key, const std::vector arg_names, - const std::vector arg_values); - icu::UnicodeString format(const char* key); + const std::vector arg_values) const; + icu::UnicodeString format(const char* key) const; void error(const char* key, const std::vector arg_names, - const std::vector arg_values, bool quit); - void error(const char* key, bool quit); + const std::vector arg_values, bool quit) const; + void error(const char* key, bool quit) const; }; // Store .dat files and map it to package name of it. @@ -39,7 +39,7 @@ inline std::unordered_map> I18n::locales_da // being overriden by LtLocale::tryToSetLocale() function. inline icu::Locale I18n::locale = icu::Locale().getName(); -inline I18n::I18n(const char *locales_path, std::string package_name) : resource("", "", status) +inline I18n::I18n(const char *locales_path, std::string package_name) : resource(status) { // Initialize status. status = U_ZERO_ERROR; @@ -90,8 +90,9 @@ inline I18n::I18n(const char *locales_path, std::string package_name) : resource } inline icu::UnicodeString I18n::format(const char* key, const std::vector arg_names, - const std::vector arg_values) + const std::vector arg_values) const { + UErrorCode status = U_ZERO_ERROR; icu::UnicodeString pattern; icu::UnicodeString output; @@ -141,20 +142,20 @@ inline icu::UnicodeString I18n::format(const char* key, const std::vector arg_names, - const std::vector arg_values, bool quit) + const std::vector arg_values, bool quit) const { std::cerr << format(key, arg_names, arg_values) << std::endl; if (quit) { exit(EXIT_FAILURE); } } -inline void I18n::error(const char* key, bool quit) +inline void I18n::error(const char* key, bool quit) const { error(key, {}, {}, quit); }