diff options
| author | garder500 <jeremy27.clara22@gmail.com> | 2025-05-01 17:25:14 +0200 |
|---|---|---|
| committer | garder500 <jeremy27.clara22@gmail.com> | 2025-05-01 17:25:14 +0200 |
| commit | 1aa7ec4539170739986bcbb4d542f5432f98bea5 (patch) | |
| tree | d66322220c7a585a22be4261c96633ac6e2b4f8c /bot/include/utils.hpp | |
| parent | 6c4647611317e27e38d70bfbc55eb180bc377809 (diff) | |
Ajout de la gestion des traductions et des messages d'erreur en plusieurs langues, suppression des fichiers de traduction obsolètes.
Diffstat (limited to 'bot/include/utils.hpp')
| -rw-r--r-- | bot/include/utils.hpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bot/include/utils.hpp b/bot/include/utils.hpp index 820fd01..801006a 100644 --- a/bot/include/utils.hpp +++ b/bot/include/utils.hpp @@ -11,6 +11,9 @@ #include <sstream> #include <algorithm> using namespace dpp; + +enum class Lang { en, fr }; + namespace app { @@ -81,6 +84,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 + */ + std::string 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::map<Lang, std::map<std::string, std::string>> &array_translations, const std::unordered_map<std::string, std::string> &args = {}); + + } // namespace dpp #endif // UTILS_HPP |
