aboutsummaryrefslogtreecommitdiff
path: root/src/gettext.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gettext.h')
-rw-r--r--src/gettext.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gettext.h b/src/gettext.h
index 42b375d86..5a3654be4 100644
--- a/src/gettext.h
+++ b/src/gettext.h
@@ -59,3 +59,21 @@ inline std::string strgettext(const std::string &text)
{
return text.empty() ? "" : gettext(text.c_str());
}
+
+/**
+ * Returns translated string with format args applied
+ *
+ * @tparam Args Template parameter for format args
+ * @param src Translation source string
+ * @param args Variable format args
+ * @return translated string
+ */
+template <typename ...Args>
+inline std::wstring fwgettext(const char *src, Args&&... args)
+{
+ wchar_t buf[255];
+ const wchar_t* str = wgettext(src);
+ swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, std::forward<Args>(args)...);
+ delete[] str;
+ return std::wstring(buf);
+}