📄 i18n.h
字号:
/************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************/#ifndef _I18N_H__#define _I18N_H__#include "global.h"#include "string.h"#include <locale.h>#include <libintl.h>#include <string>using namespace std;/** * This class provides static methods which can be used * to translate strings into the systems locale using a slightly * advanced technique in contrast to the gettext() method. * Take a look at "man 3 gettext" to get more information * on the gettext function. * * @author Timo Benk <t_benk@web.de> */class I18N{ public: /** * Initialize the i18n subsystem. * Will be called by libsmtp++ when the library is loaded * but must be called again if messages that belongs to * another textdomain than "libsmtp++" should be translated. * * @param textdomain The textdomain that should be added. * @param locale_dir The directory that contains the message * files for this textdomain. */ static void init (const string &textdomain, const string &locale_dir); /** * Translates the string msgid. * The string msgid will be translated using the * glibc gettext() function. Additionally the string * can include special substitution characters, which * will be substituted with the strings in the array * params. * EG: "This is a test arg $0, and this is another one: $1" * $0 will be substituted by params[0], $1 will be substituted * by params[1], etc. * * @param textdomain The textdomain that should be used. * @param msgid The msgid that should be translated. * @param params The strings that should be inserted into * the translated message. * @param count The size of the array params. * @returns The translated string. */ static string i18n ( const string &textdomain, const string &msgid, string params[], unsigned int count ); /** * The same as the first method, just with only one * parameters. * Just for your convenience. * * @param textdomain The textdomain that should be used. * @param msgid The msgid that should be translated. * @param param Substitution string for $0. * @returns The translated string. */ static string i18n ( const string &textdomain, const string &msgid, const string ¶m ); /** * The same as the first method, just with only two * parameters. * Just for your convenience. * * @param textdomain The textdomain that should be used. * @param msgid The msgid that should be translated. * @param param1 Substitution string for $0. * @param param2 Substitution string for $1. * @returns The translated string. */ static string i18n ( const string &textdomain, const string &msgid, const string ¶m1, const string ¶m2 ); /** * The same as the first method, just with only three * parameters. * Just for your convenience. * * @param textdomain The textdomain that should be used. * @param msgid The msgid that should be translated. * @param param1 Substitution string for $0. * @param param2 Substitution string for $1. * @param param3 Substitution string for $2. * @returns The translated string. */ static string i18n ( const string &textdomain, const string &msgid, const string ¶m1, const string ¶m2, const string ¶m3 ); /** * The same as the first method, just with only four * parameters. * Just for your convenience. * * @param textdomain The textdomain that should be used. * @param msgid The msgid that should be translated. * @param param1 Substitution string for $0. * @param param2 Substitution string for $1. * @param param3 Substitution string for $2. * @param param4 Substitution string for $3. * @returns The translated string. */ static string i18n ( const string &textdomain, const string &msgid, const string ¶m1, const string ¶m2, const string ¶m3, const string ¶m4 ); /** * The same as the first method, just with only five * parameters. * Just for your convenience. * * @param textdomain The textdomain that should be used. * @param msgid The msgid that should be translated. * @param param1 Substitution string for $0. * @param param2 Substitution string for $1. * @param param3 Substitution string for $2. * @param param4 Substitution string for $3. * @param param5 Substitution string for $4. * @returns The translated string. */ static string i18n ( const string &textdomain, const string &msgid, const string ¶m1, const string ¶m2, const string ¶m3, const string ¶m4, const string ¶m5 ); /** * The same as the first method, just with no * parameters. * Just for your convenience. * * @param textdomain The textdomain that should be used. * @param msgid The msgid that should be translated. * @returns The translated string. */ static string i18n (const string &textdomain, const string &msgid);};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -