Expose i18n translation API to tools.h

This commit is contained in:
ShaopengLin 2024-08-03 04:21:55 -04:00
parent ece40966f1
commit 22c54adb58
2 changed files with 10 additions and 2 deletions

View File

@ -282,5 +282,14 @@ FeedCategories readCategoriesFromFeed(const std::string& content);
* @return full language name. * @return full language name.
*/ */
std::string getLanguageSelfName(const std::string& lang); std::string getLanguageSelfName(const std::string& lang);
/**
* Retrieve the translation corresponding to key in language lang
*
* @param lang ISO 639-3 language code.
* @param key translation key string
* @return translated key
*/
std::string getTranslatedString(const std::string& lang, const std::string& key);
} }
#endif // KIWIX_TOOLS_H #endif // KIWIX_TOOLS_H

View File

@ -20,6 +20,7 @@
#ifndef KIWIX_SERVER_I18N #ifndef KIWIX_SERVER_I18N
#define KIWIX_SERVER_I18N #define KIWIX_SERVER_I18N
#include <tools.h>
#include <map> #include <map>
#include <string> #include <string>
#include <mustache.hpp> #include <mustache.hpp>
@ -40,8 +41,6 @@ struct I18nStringTable {
const char* get(const std::string& key) const; const char* get(const std::string& key) const;
}; };
std::string getTranslatedString(const std::string& lang, const std::string& key);
namespace i18n namespace i18n
{ {