From 1aa7ec4539170739986bcbb4d542f5432f98bea5 Mon Sep 17 00:00:00 2001 From: garder500 Date: Thu, 1 May 2025 17:25:14 +0200 Subject: Ajout de la gestion des traductions et des messages d'erreur en plusieurs langues, suppression des fichiers de traduction obsolètes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot/include/utils.hpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'bot/include/utils.hpp') 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 #include 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> &array_translations, const std::unordered_map &args = {}); + + } // namespace dpp #endif // UTILS_HPP -- cgit v1.2.3