mirror of https://github.com/kiwix/libkiwix.git
kiwix::i18n::expandParameterizedString()
This commit is contained in:
parent
e4a0a029ff
commit
577b6e29f9
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
|
#include "tools/otherTools.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
@ -91,4 +93,17 @@ std::string getTranslatedString(const std::string& lang, const std::string& key)
|
||||||
return stringDb.get(lang, key);
|
return stringDb.get(lang, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace i18n
|
||||||
|
{
|
||||||
|
|
||||||
|
std::string expandParameterizedString(const std::string& lang,
|
||||||
|
const std::string& key,
|
||||||
|
const Parameters& params)
|
||||||
|
{
|
||||||
|
const std::string tmpl = getTranslatedString(lang, key);
|
||||||
|
return render_template(tmpl, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace i18n
|
||||||
|
|
||||||
} // namespace kiwix
|
} // namespace kiwix
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#define KIWIX_SERVER_I18N
|
#define KIWIX_SERVER_I18N
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <mustache.hpp>
|
||||||
|
|
||||||
namespace kiwix
|
namespace kiwix
|
||||||
{
|
{
|
||||||
|
@ -40,6 +41,17 @@ struct I18nStringTable {
|
||||||
|
|
||||||
std::string getTranslatedString(const std::string& lang, const std::string& key);
|
std::string getTranslatedString(const std::string& lang, const std::string& key);
|
||||||
|
|
||||||
|
namespace i18n
|
||||||
|
{
|
||||||
|
|
||||||
|
typedef kainjow::mustache::object Parameters;
|
||||||
|
|
||||||
|
std::string expandParameterizedString(const std::string& lang,
|
||||||
|
const std::string& key,
|
||||||
|
const Parameters& params);
|
||||||
|
|
||||||
|
} // namespace i18n
|
||||||
|
|
||||||
} // namespace kiwix
|
} // namespace kiwix
|
||||||
|
|
||||||
#endif // KIWIX_SERVER_I18N
|
#endif // KIWIX_SERVER_I18N
|
||||||
|
|
|
@ -445,10 +445,11 @@ namespace
|
||||||
|
|
||||||
std::string makeFulltextSearchSuggestion(const std::string& lang, const std::string& queryString)
|
std::string makeFulltextSearchSuggestion(const std::string& lang, const std::string& queryString)
|
||||||
{
|
{
|
||||||
MustacheData data;
|
return i18n::expandParameterizedString(lang, "suggest-full-text-search",
|
||||||
data.set("SEARCH_TERMS", queryString);
|
{
|
||||||
const std::string tmpl = getTranslatedString(lang, "suggest-full-text-search");
|
{"SEARCH_TERMS", queryString}
|
||||||
return render_template(tmpl, data);
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string noSuchBookErrorMsg(const std::string& bookName)
|
std::string noSuchBookErrorMsg(const std::string& bookName)
|
||||||
|
|
Loading…
Reference in New Issue