From 484b12a0a39686935d8ab60a684956aa2ff3b80e Mon Sep 17 00:00:00 2001 From: Nick Logozzo Date: Mon, 25 Dec 2023 11:28:06 -0500 Subject: [PATCH] All - Cleanup --- include/helpers/stringhelpers.h | 2 +- src/helpers/stringhelpers.cpp | 2 +- src/localization/gettext.cpp | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/helpers/stringhelpers.h b/include/helpers/stringhelpers.h index bc239df..f7ecd79 100644 --- a/include/helpers/stringhelpers.h +++ b/include/helpers/stringhelpers.h @@ -62,7 +62,7 @@ namespace Nickvision::Aura::StringHelpers * @param replace The new string to replace with * @return The new replaced string */ - std::string replace(std::string s, std::string toReplace, std::string replace); + std::string replace(std::string s, const std::string& toReplace, const std::string& replace); /** * @brief Generates a new guid value. * @return The guid value diff --git a/src/helpers/stringhelpers.cpp b/src/helpers/stringhelpers.cpp index 97d8a08..df5debc 100644 --- a/src/helpers/stringhelpers.cpp +++ b/src/helpers/stringhelpers.cpp @@ -53,7 +53,7 @@ namespace Nickvision::Aura return result; } - std::string StringHelpers::replace(std::string s, std::string toReplace, std::string replace) + std::string StringHelpers::replace(std::string s, const std::string& toReplace, const std::string& replace) { if (s.empty() || toReplace.empty()) { diff --git a/src/localization/gettext.cpp b/src/localization/gettext.cpp index 7425c4f..5402a8c 100644 --- a/src/localization/gettext.cpp +++ b/src/localization/gettext.cpp @@ -7,13 +7,15 @@ namespace Nickvision::Aura { bool Localization::init() { + bool res{ true }; std::string name{ StringHelpers::toLower(StringHelpers::replace(Aura::getActive().getAppInfo().getEnglishShortName(), " ", "")) }; if (name.empty()) { name = StringHelpers::toLower(StringHelpers::replace(Aura::getActive().getAppInfo().getName(), " ", "")); } - bindtextdomain(name.c_str(), std::filesystem::current_path().string().c_str()); - bind_textdomain_codeset(name.c_str(), "UTF-8"); - textdomain(name.c_str()); + res &= bindtextdomain(name.c_str(), std::filesystem::current_path().string().c_str()) != nullptr; + res &= bind_textdomain_codeset(name.c_str(), "UTF-8") != nullptr; + res &= textdomain(name.c_str()) != nullptr; + return res; } } \ No newline at end of file