diff options
Diffstat (limited to 'bot/include/utils.hpp')
| -rw-r--r-- | bot/include/utils.hpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/bot/include/utils.hpp b/bot/include/utils.hpp index 820fd01..7008dec 100644 --- a/bot/include/utils.hpp +++ b/bot/include/utils.hpp @@ -1,7 +1,5 @@ // utils.hpp #pragma once -#ifndef UTILS_HPP -#define UTILS_HPP #include <dpp/dpp.h> #include <dpp/nlohmann/json.hpp> @@ -11,6 +9,12 @@ #include <sstream> #include <algorithm> using namespace dpp; + +enum class Lang { + en, + fr, +}; + namespace app { @@ -81,7 +85,25 @@ namespace app */ std::string string_from_json(const nlohmann::json &j); + /** + * @brief Gets the available locale for a given locale string + * + * @param locale The locale string to check + * @return std::string The available locale or "en" if not found + */ + Lang get_available_locale(std::string locale); + + /** + * @brienf translate a string from a locale, optionnal parameters and a default value + * @param str The string to translate to found in an Array of translations + * @param locale The locale to use for translation + * @param array_translations The array of translations + * @param args The optional parameters to replace in the string + * @return std::string The translated string + */ + std::string translate(const std::string &str, const std::string &locale, const std::unordered_map<Lang, std::unordered_map<std::string, std::string>> &array_translations, const std::unordered_map<std::string, std::string> &args = {}); + + } // namespace dpp -#endif // UTILS_HPP // utils.hpp |
