[i18n] add support of string formatting

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/1854/head
R4SAS 1 year ago
parent e8be39af17
commit e8ace998ba
No known key found for this signature in database
GPG Key ID: 66F6C87B98EBCFE2

@ -103,18 +103,18 @@ namespace http {
int num; int num;
if ((num = seconds / 86400) > 0) { if ((num = seconds / 86400) > 0) {
s << num << " " << tr("day", "days", num) << ", "; s << ntr("%d day", "%d days", num, num) << ", ";
seconds -= num * 86400; seconds -= num * 86400;
} }
if ((num = seconds / 3600) > 0) { if ((num = seconds / 3600) > 0) {
s << num << " " << tr("hour", "hours", num) << ", "; s << ntr("%d hour", "%d hours", num, num) << ", ";
seconds -= num * 3600; seconds -= num * 3600;
} }
if ((num = seconds / 60) > 0) { if ((num = seconds / 60) > 0) {
s << num << " " << tr("minute", "minutes", num) << ", "; s << ntr("%d minute", "%d minutes", num, num) << ", ";
seconds -= num * 60; seconds -= num * 60;
} }
s << seconds << " " << tr("second", "seconds", seconds); s << ntr("%d second", "%d seconds", seconds, seconds);
} }
static void ShowTraffic (std::stringstream& s, uint64_t bytes) static void ShowTraffic (std::stringstream& s, uint64_t bytes)
@ -122,11 +122,11 @@ namespace http {
s << std::fixed << std::setprecision(2); s << std::fixed << std::setprecision(2);
auto numKBytes = (double) bytes / 1024; auto numKBytes = (double) bytes / 1024;
if (numKBytes < 1024) if (numKBytes < 1024)
s << numKBytes << " " << tr(/* tr: Kibibit */ "KiB"); s << tr(/* tr: Kibibyte */ "%.2f KiB", numKBytes);
else if (numKBytes < 1024 * 1024) else if (numKBytes < 1024 * 1024)
s << numKBytes / 1024 << " " << tr(/* tr: Mebibit */ "MiB"); s << tr(/* tr: Mebibyte */ "%.2f MiB", numKBytes / 1024);
else else
s << numKBytes / 1024 / 1024 << " " << tr(/* tr: Gibibit */ "GiB"); s << tr(/* tr: Gibibyte */ "%.2f GiB", numKBytes / 1024 / 1024);
} }
static void ShowTunnelDetails (std::stringstream& s, enum i2p::tunnel::TunnelState eState, bool explr, int bytes) static void ShowTunnelDetails (std::stringstream& s, enum i2p::tunnel::TunnelState eState, bool explr, int bytes)
@ -150,7 +150,7 @@ namespace http {
else stateText = tr("unknown"); else stateText = tr("unknown");
s << "<span class=\"tunnel " << state << "\"> " << stateText << ((explr) ? " (" + tr("exploratory") + ")" : "") << "</span>, "; s << "<span class=\"tunnel " << state << "\"> " << stateText << ((explr) ? " (" + tr("exploratory") + ")" : "") << "</span>, ";
s << " " << (int) (bytes / 1024) << "&nbsp;" << tr(/* tr: Kibibit */ "KiB") << "\r\n"; s << " " << tr(/* tr: Kibibit */ "%.2f KiB", (double) bytes / 1024) << "\r\n";
} }
static void SetLogLevel (const std::string& level) static void SetLogLevel (const std::string& level)
@ -247,7 +247,7 @@ namespace http {
break; break;
case eRouterErrorFullConeNAT: case eRouterErrorFullConeNAT:
s << " - " << tr("Full cone NAT"); s << " - " << tr("Full cone NAT");
break; break;
case eRouterErrorNoDescriptors: case eRouterErrorNoDescriptors:
s << " - " << tr("No Descriptors"); s << " - " << tr("No Descriptors");
break; break;
@ -290,13 +290,13 @@ namespace http {
s << "<b>" << tr("Tunnel creation success rate") << ":</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n"; s << "<b>" << tr("Tunnel creation success rate") << ":</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n";
s << "<b>" << tr("Received") << ":</b> "; s << "<b>" << tr("Received") << ":</b> ";
ShowTraffic (s, i2p::transport::transports.GetTotalReceivedBytes ()); ShowTraffic (s, i2p::transport::transports.GetTotalReceivedBytes ());
s << " (" << (double) i2p::transport::transports.GetInBandwidth15s () / 1024 << " " << tr(/* tr: Kibibit/s */ "KiB/s") << ")<br>\r\n"; s << " (" << tr(/* tr: Kibibit/s */ "%.2f KiB/s", (double) i2p::transport::transports.GetInBandwidth15s () / 1024) << ")<br>\r\n";
s << "<b>" << tr("Sent") << ":</b> "; s << "<b>" << tr("Sent") << ":</b> ";
ShowTraffic (s, i2p::transport::transports.GetTotalSentBytes ()); ShowTraffic (s, i2p::transport::transports.GetTotalSentBytes ());
s << " (" << (double) i2p::transport::transports.GetOutBandwidth15s () / 1024 << " " << tr(/* tr: Kibibit/s */ "KiB/s") << ")<br>\r\n"; s << " (" << tr(/* tr: Kibibit/s */ "%.2f KiB/s", (double) i2p::transport::transports.GetOutBandwidth15s () / 1024) << ")<br>\r\n";
s << "<b>" << tr("Transit") << ":</b> "; s << "<b>" << tr("Transit") << ":</b> ";
ShowTraffic (s, i2p::transport::transports.GetTotalTransitTransmittedBytes ()); ShowTraffic (s, i2p::transport::transports.GetTotalTransitTransmittedBytes ());
s << " (" << (double) i2p::transport::transports.GetTransitBandwidth15s () / 1024 << " " << tr(/* tr: Kibibit/s */ "KiB/s") << ")<br>\r\n"; s << " (" << tr(/* tr: Kibibit/s */ "%.2f KiB/s", (double) i2p::transport::transports.GetTransitBandwidth15s () / 1024) << ")<br>\r\n";
s << "<b>" << tr("Data path") << ":</b> " << i2p::fs::GetUTF8DataDir() << "<br>\r\n"; s << "<b>" << tr("Data path") << ":</b> " << i2p::fs::GetUTF8DataDir() << "<br>\r\n";
s << "<div class='slide'>"; s << "<div class='slide'>";
if ((outputFormat == OutputFormatEnum::forWebConsole) || !includeHiddenContent) { if ((outputFormat == OutputFormatEnum::forWebConsole) || !includeHiddenContent) {
@ -338,7 +338,7 @@ namespace http {
s << "<td>" << address->host.to_string() << ":" << address->port << "</td>\r\n"; s << "<td>" << address->host.to_string() << ":" << address->port << "</td>\r\n";
else else
{ {
s << "<td>" << tr("supported"); s << "<td>" << tr(/* tr: Shown when router doesn't publish itself and have "Firewalled" state */ "supported");
if (address->port) if (address->port)
s << " :" << address->port; s << " :" << address->port;
s << "</td>\r\n"; s << "</td>\r\n";
@ -466,7 +466,7 @@ namespace http {
} }
s << "&#8658; " << it->GetTunnelID () << ":me"; s << "&#8658; " << it->GetTunnelID () << ":me";
if (it->LatencyIsKnown()) if (it->LatencyIsKnown())
s << " ( " << it->GetMeanLatency() << tr(/* tr: Milliseconds */ "ms") << " )"; s << " ( " << tr(/* tr: Milliseconds */ "%dms", it->GetMeanLatency()) << " )";
ShowTunnelDetails(s, it->GetState (), false, it->GetNumReceivedBytes ()); ShowTunnelDetails(s, it->GetState (), false, it->GetNumReceivedBytes ());
s << "</div>\r\n"; s << "</div>\r\n";
} }
@ -486,22 +486,26 @@ namespace http {
); );
} }
if (it->LatencyIsKnown()) if (it->LatencyIsKnown())
s << " ( " << it->GetMeanLatency() << tr("ms") << " )"; s << " ( " << tr("%dms", it->GetMeanLatency()) << " )";
ShowTunnelDetails(s, it->GetState (), false, it->GetNumSentBytes ()); ShowTunnelDetails(s, it->GetState (), false, it->GetNumSentBytes ());
s << "</div>\r\n"; s << "</div>\r\n";
} }
} }
s << "<br>\r\n"; s << "<br>\r\n";
s << "<b>" << tr("Tags") << "</b><br>\r\n" << tr("Incoming") << ": <i>" << dest->GetNumIncomingTags () << "</i><br>\r\n"; s << "<b>" << tr("Tags") << "</b><br>\r\n"
<< tr("Incoming") << ": <i>" << dest->GetNumIncomingTags () << "</i><br>\r\n";
if (!dest->GetSessions ().empty ()) { if (!dest->GetSessions ().empty ()) {
std::stringstream tmp_s; uint32_t out_tags = 0; std::stringstream tmp_s; uint32_t out_tags = 0;
for (const auto& it: dest->GetSessions ()) { for (const auto& it: dest->GetSessions ()) {
tmp_s << "<tr><td>" << i2p::client::context.GetAddressBook ().ToAddress(it.first) << "</td><td>" << it.second->GetNumOutgoingTags () << "</td></tr>\r\n"; tmp_s << "<tr><td>" << i2p::client::context.GetAddressBook ().ToAddress(it.first) << "</td><td>" << it.second->GetNumOutgoingTags () << "</td></tr>\r\n";
out_tags += it.second->GetNumOutgoingTags (); out_tags += it.second->GetNumOutgoingTags ();
} }
s << "<div class='slide'><label for='slide-tags'>" << tr("Outgoing") << ": <i>" << out_tags << "</i></label>\r\n<input type=\"checkbox\" id=\"slide-tags\" />\r\n" s << "<div class='slide'><label for='slide-tags'>" << tr("Outgoing") << ": <i>" << out_tags << "</i></label>\r\n"
<< "<div class=\"slidecontent\">\r\n<table>\r\n<thead><th>" << tr("Destination") << "</th><th>" << tr("Amount") << "</th></thead>\r\n<tbody class=\"tableitem\">\r\n" << tmp_s.str () << "</tbody></table>\r\n</div>\r\n</div>\r\n"; << "<input type=\"checkbox\" id=\"slide-tags\" />\r\n"
<< "<div class=\"slidecontent\">\r\n"
<< "<table>\r\n<thead><th>" << tr("Destination") << "</th><th>" << tr("Amount") << "</th></thead>\r\n"
<< "<tbody class=\"tableitem\">\r\n" << tmp_s.str () << "</tbody></table>\r\n</div>\r\n</div>\r\n";
} else } else
s << tr("Outgoing") << ": <i>0</i><br>\r\n"; s << tr("Outgoing") << ": <i>0</i><br>\r\n";
s << "<br>\r\n"; s << "<br>\r\n";
@ -516,8 +520,11 @@ namespace http {
tmp_s << "<tr><td>" << i2p::client::context.GetAddressBook ().ToAddress(it.second->GetDestination ()) << "</td><td>" << it.second->GetState () << "</td></tr>\r\n"; tmp_s << "<tr><td>" << i2p::client::context.GetAddressBook ().ToAddress(it.second->GetDestination ()) << "</td><td>" << it.second->GetState () << "</td></tr>\r\n";
ecies_sessions++; ecies_sessions++;
} }
s << "<div class='slide'><label for='slide-ecies-sessions'>" << tr("Tags sessions") << ": <i>" << ecies_sessions << "</i></label>\r\n<input type=\"checkbox\" id=\"slide-ecies-sessions\" />\r\n" s << "<div class='slide'><label for='slide-ecies-sessions'>" << tr("Tags sessions") << ": <i>" << ecies_sessions << "</i></label>\r\n"
<< "<div class=\"slidecontent\">\r\n<table>\r\n<thead><th>" << tr("Destination") << "</th><th>" << tr("Status") << "</th></thead>\r\n<tbody class=\"tableitem\">\r\n" << tmp_s.str () << "</tbody></table>\r\n</div>\r\n</div>\r\n"; << "<input type=\"checkbox\" id=\"slide-ecies-sessions\" />\r\n"
<< "<div class=\"slidecontent\">\r\n<table>\r\n"
<< "<thead><th>" << tr("Destination") << "</th><th>" << tr("Status") << "</th></thead>\r\n"
<< "<tbody class=\"tableitem\">\r\n" << tmp_s.str () << "</tbody></table>\r\n</div>\r\n</div>\r\n";
} else } else
s << tr("Tags sessions") << ": <i>0</i><br>\r\n"; s << tr("Tags sessions") << ": <i>0</i><br>\r\n";
s << "<br>\r\n"; s << "<br>\r\n";
@ -671,7 +678,7 @@ namespace http {
} }
s << "&#8658; " << it->GetTunnelID () << ":me"; s << "&#8658; " << it->GetTunnelID () << ":me";
if (it->LatencyIsKnown()) if (it->LatencyIsKnown())
s << " ( " << it->GetMeanLatency() << tr("ms") << " )"; s << " ( " << tr("%dms", it->GetMeanLatency()) << " )";
ShowTunnelDetails(s, it->GetState (), (it->GetTunnelPool () == ExplPool), it->GetNumReceivedBytes ()); ShowTunnelDetails(s, it->GetState (), (it->GetTunnelPool () == ExplPool), it->GetNumReceivedBytes ());
s << "</div>\r\n"; s << "</div>\r\n";
} }
@ -691,7 +698,7 @@ namespace http {
); );
} }
if (it->LatencyIsKnown()) if (it->LatencyIsKnown())
s << " ( " << it->GetMeanLatency() << tr("ms") << " )"; s << " ( " << tr("%dms", it->GetMeanLatency()) << " )";
ShowTunnelDetails(s, it->GetState (), (it->GetTunnelPool () == ExplPool), it->GetNumSentBytes ()); ShowTunnelDetails(s, it->GetState (), (it->GetTunnelPool () == ExplPool), it->GetNumSentBytes ());
s << "</div>\r\n"; s << "</div>\r\n";
} }

@ -64,10 +64,10 @@ namespace afrikaans // language namespace
static std::map<std::string, std::vector<std::string>> plurals static std::map<std::string, std::vector<std::string>> plurals
{ {
{"days", {"dag", "dae"}}, {"%d days", {"%d dag", "%d dae"}},
{"hours", {"uur", "ure"}}, {"%d hours", {"%d uur", "%d ure"}},
{"minutes", {"minuut", "minute"}}, {"%d minutes", {"%d minuut", "%d minute"}},
{"seconds", {"seconde", "sekondes"}}, {"%d seconds", {"%d seconde", "%d sekondes"}},
{"", {"", ""}}, {"", {"", ""}},
}; };

@ -31,9 +31,9 @@ namespace armenian // language namespace
static std::map<std::string, std::string> strings static std::map<std::string, std::string> strings
{ {
{"KiB", "ԿիԲ"}, {"%.2f KiB", "%.2f ԿիԲ"},
{"MiB", "ՄիԲ"}, {"%.2f MiB", "%.2f ՄիԲ"},
{"GiB", "ԳիԲ"}, {"%.2f GiB", "%.2f ԳիԲ"},
{"building", "կառուցվում է"}, {"building", "կառուցվում է"},
{"failed", "Անհաջող"}, {"failed", "Անհաջող"},
{"expiring", "Լրանում է"}, {"expiring", "Լրանում է"},
@ -68,7 +68,7 @@ namespace armenian // language namespace
{"Family", "Խմբատեսակ"}, {"Family", "Խմբատեսակ"},
{"Tunnel creation success rate", "Հաջողությամբ կառուցված թունելներ"}, {"Tunnel creation success rate", "Հաջողությամբ կառուցված թունելներ"},
{"Received", "Ստացվել է"}, {"Received", "Ստացվել է"},
{"KiB/s", "ԿիԲ/վ"}, {"%.2f KiB/s", "%.2f ԿիԲ/վ"},
{"Sent", "Ուղարկվել է"}, {"Sent", "Ուղարկվել է"},
{"Transit", "Տարանցում"}, {"Transit", "Տարանցում"},
{"Data path", "Տվյալների ուղին"}, {"Data path", "Տվյալների ուղին"},
@ -94,7 +94,7 @@ namespace armenian // language namespace
{"Type", "Տեսակը"}, {"Type", "Տեսակը"},
{"EncType", "Գաղտնագրի տեսակը"}, {"EncType", "Գաղտնագրի տեսակը"},
{"Inbound tunnels", "Մուտքային թունելներ"}, {"Inbound tunnels", "Մուտքային թունելներ"},
{"ms", "մլվ"}, {"%dms", "%dմլվ"},
{"Outbound tunnels", "Ելքային թունելներ"}, {"Outbound tunnels", "Ելքային թունելներ"},
{"Tags", "Թեգեր"}, {"Tags", "Թեգեր"},
{"Incoming", "Մուտքային"}, {"Incoming", "Մուտքային"},
@ -198,10 +198,10 @@ namespace armenian // language namespace
static std::map<std::string, std::vector<std::string>> plurals static std::map<std::string, std::vector<std::string>> plurals
{ {
{"days", {"օր", "օր"}}, {"%d days", {"%d օր", "%d օր"}},
{"hours", {"ժամ", "ժամ"}}, {"%d hours", {"%d ժամ", "%d ժամ"}},
{"minutes", {"րոպե", "րոպե"}}, {"%d minutes", {"%d րոպե", "%d րոպե"}},
{"seconds", {"վարկյան", "վարկյան"}}, {"%d seconds", {"%d վարկյան", "%d վարկյան"}},
{"", {"", ""}}, {"", {"", ""}},
}; };

@ -32,9 +32,9 @@ namespace chinese // language namespace
static std::map<std::string, std::string> strings static std::map<std::string, std::string> strings
{ {
{"KiB", "KiB"}, {"%.2f KiB", "%.2f KiB"},
{"MiB", "MiB"}, {"%.2f MiB", "%.2f MiB"},
{"GiB", "GiB"}, {"%.2f GiB", "%.2f GiB"},
{"building", "正在构建"}, {"building", "正在构建"},
{"failed", "连接失败"}, {"failed", "连接失败"},
{"expiring", "即将过期"}, {"expiring", "即将过期"},
@ -70,7 +70,7 @@ namespace chinese // language namespace
{"Family", "家族"}, {"Family", "家族"},
{"Tunnel creation success rate", "隧道创建成功率"}, {"Tunnel creation success rate", "隧道创建成功率"},
{"Received", "已接收"}, {"Received", "已接收"},
{"KiB/s", "KiB/s"}, {"%.2f KiB/s", "%.2f KiB/s"},
{"Sent", "已发送"}, {"Sent", "已发送"},
{"Transit", "中转"}, {"Transit", "中转"},
{"Data path", "数据文件路径"}, {"Data path", "数据文件路径"},
@ -96,7 +96,7 @@ namespace chinese // language namespace
{"Type", "类型"}, {"Type", "类型"},
{"EncType", "加密类型"}, {"EncType", "加密类型"},
{"Inbound tunnels", "入站隧道"}, {"Inbound tunnels", "入站隧道"},
{"ms", "毫秒"}, {"%dms", "%d毫秒"},
{"Outbound tunnels", "出站隧道"}, {"Outbound tunnels", "出站隧道"},
{"Tags", "标签"}, {"Tags", "标签"},
{"Incoming", "传入"}, {"Incoming", "传入"},
@ -200,10 +200,10 @@ namespace chinese // language namespace
static std::map<std::string, std::vector<std::string>> plurals static std::map<std::string, std::vector<std::string>> plurals
{ {
{"days", {""}}, {"%d days", {"%d "}},
{"hours", {""}}, {"%d hours", {"%d "}},
{"minutes", {""}}, {"%d minutes", {"%d "}},
{"seconds", {""}}, {"%d seconds", {"%d "}},
{"", {""}}, {"", {""}},
}; };

@ -31,9 +31,9 @@ namespace czech // language namespace
static std::map<std::string, std::string> strings static std::map<std::string, std::string> strings
{ {
{"KiB", "KiB"}, {"%.2f KiB", "%.2f KiB"},
{"MiB", "MiB"}, {"%.2f MiB", "%.2f MiB"},
{"GiB", "GiB"}, {"%.2f GiB", "%.2f GiB"},
{"building", "vytváří se"}, {"building", "vytváří se"},
{"failed", "selhalo"}, {"failed", "selhalo"},
{"expiring", "končící"}, {"expiring", "končící"},
@ -69,7 +69,7 @@ namespace czech // language namespace
{"Family", "Rodina"}, {"Family", "Rodina"},
{"Tunnel creation success rate", "Úspěšnost vytváření tunelů"}, {"Tunnel creation success rate", "Úspěšnost vytváření tunelů"},
{"Received", "Přijato"}, {"Received", "Přijato"},
{"KiB/s", "KiB/s"}, {"%.2f KiB/s", "%.2f KiB/s"},
{"Sent", "Odesláno"}, {"Sent", "Odesláno"},
{"Transit", "Tranzit"}, {"Transit", "Tranzit"},
{"Data path", "Cesta k data souborům"}, {"Data path", "Cesta k data souborům"},
@ -95,7 +95,7 @@ namespace czech // language namespace
{"Type", "Typ"}, {"Type", "Typ"},
{"EncType", "EncType"}, {"EncType", "EncType"},
{"Inbound tunnels", "Příchozí tunely"}, {"Inbound tunnels", "Příchozí tunely"},
{"ms", "ms"}, {"%dms", "%dms"},
{"Outbound tunnels", "Odchozí tunely"}, {"Outbound tunnels", "Odchozí tunely"},
{"Tags", "Štítky"}, {"Tags", "Štítky"},
{"Incoming", "Příchozí"}, {"Incoming", "Příchozí"},
@ -199,10 +199,10 @@ namespace czech // language namespace
static std::map<std::string, std::vector<std::string>> plurals static std::map<std::string, std::vector<std::string>> plurals
{ {
{"days", {"den", "dny", "dní", "dní"}}, {"%d days", {"%d den", "%d dny", "%d dní", "%d dní"}},
{"hours", {"hodina", "hodiny", "hodin", "hodin"}}, {"%d hours", {"%d hodina", "%d hodiny", "%d hodin", "%d hodin"}},
{"minutes", {"minuta", "minuty", "minut", "minut"}}, {"%d minutes", {"%d minuta", "%d minuty", "%d minut", "%d minut"}},
{"seconds", {"vteřina", "vteřiny", "vteřin", "vteřin"}}, {"%d seconds", {"%d vteřina", "%d vteřiny", "%d vteřin", "%d vteřin"}},
{"", {"", "", "", ""}}, {"", {"", "", "", ""}},
}; };

@ -31,9 +31,9 @@ namespace french // language namespace
static std::map<std::string, std::string> strings static std::map<std::string, std::string> strings
{ {
{"KiB", "Kio"}, {"%.2f KiB", "%.2f Kio"},
{"MiB", "Mio"}, {"%.2f MiB", "%.2f Mio"},
{"GiB", "Gio"}, {"%.2f GiB", "%.2f Gio"},
{"building", "En construction"}, {"building", "En construction"},
{"failed", "échoué"}, {"failed", "échoué"},
{"expiring", "expiré"}, {"expiring", "expiré"},
@ -69,7 +69,7 @@ namespace french // language namespace
{"Family", "Famille"}, {"Family", "Famille"},
{"Tunnel creation success rate", "Taux de succès de création de tunnels"}, {"Tunnel creation success rate", "Taux de succès de création de tunnels"},
{"Received", "Reçu"}, {"Received", "Reçu"},
{"KiB/s", "kio/s"}, {"%.2f KiB/s", "%.2f kio/s"},
{"Sent", "Envoyé"}, {"Sent", "Envoyé"},
{"Transit", "Transité"}, {"Transit", "Transité"},
{"Data path", "Emplacement des données"}, {"Data path", "Emplacement des données"},
@ -93,7 +93,7 @@ namespace french // language namespace
{"Address", "Adresse"}, {"Address", "Adresse"},
{"Type", "Type"}, {"Type", "Type"},
{"Inbound tunnels", "Tunnels entrants"}, {"Inbound tunnels", "Tunnels entrants"},
{"ms", "ms"}, {"%dms", "%dms"},
{"Outbound tunnels", "Tunnels sortants"}, {"Outbound tunnels", "Tunnels sortants"},
{"Tags", "Balises"}, {"Tags", "Balises"},
{"Incoming", "Entrant"}, {"Incoming", "Entrant"},
@ -194,10 +194,10 @@ namespace french // language namespace
static std::map<std::string, std::vector<std::string>> plurals static std::map<std::string, std::vector<std::string>> plurals
{ {
{"days", {"jour", "jours"}}, {"%d days", {"%d jour", "%d jours"}},
{"hours", {"heure", "heures"}}, {"%d hours", {"%d heure", "%d heures"}},
{"minutes", {"minute", "minutes"}}, {"%d minutes", {"%d minute", "%d minutes"}},
{"seconds", {"seconde", "secondes"}}, {"%d seconds", {"%d seconde", "%d secondes"}},
{"", {"", ""}}, {"", {"", ""}},
}; };

@ -31,9 +31,9 @@ namespace german // language namespace
static std::map<std::string, std::string> strings static std::map<std::string, std::string> strings
{ {
{"KiB", "KiB"}, {"%.2f KiB", "%.2f KiB"},
{"MiB", "MiB"}, {"%.2f MiB", "%.2f MiB"},
{"GiB", "GiB"}, {"%.2f GiB", "%.2f GiB"},
{"building", "In Bau"}, {"building", "In Bau"},
{"failed", "fehlgeschlagen"}, {"failed", "fehlgeschlagen"},
{"expiring", "läuft ab"}, {"expiring", "läuft ab"},
@ -69,7 +69,7 @@ namespace german // language namespace
{"Family", "Familie"}, {"Family", "Familie"},
{"Tunnel creation success rate", "Erfolgsrate der Tunnelerstellung"}, {"Tunnel creation success rate", "Erfolgsrate der Tunnelerstellung"},
{"Received", "Eingegangen"}, {"Received", "Eingegangen"},
{"KiB/s", "KiB/s"}, {"%.2f KiB/s", "%.2f KiB/s"},
{"Sent", "Gesendet"}, {"Sent", "Gesendet"},
{"Transit", "Transit"}, {"Transit", "Transit"},
{"Data path", "Datenpfad"}, {"Data path", "Datenpfad"},
@ -95,7 +95,7 @@ namespace german // language namespace
{"Type", "Typ"}, {"Type", "Typ"},
{"EncType", "Verschlüsselungstyp"}, {"EncType", "Verschlüsselungstyp"},
{"Inbound tunnels", "Eingehende Tunnel"}, {"Inbound tunnels", "Eingehende Tunnel"},
{"ms", "ms"}, {"%dms", "%dms"},
{"Outbound tunnels", "Ausgehende Tunnel"}, {"Outbound tunnels", "Ausgehende Tunnel"},
{"Tags", "Tags"}, {"Tags", "Tags"},
{"Incoming", "Eingehend"}, {"Incoming", "Eingehend"},
@ -199,10 +199,10 @@ namespace german // language namespace
static std::map<std::string, std::vector<std::string>> plurals static std::map<std::string, std::vector<std::string>> plurals
{ {
{"days", {"Tag", "Tage"}}, {"%d days", {"%d Tag", "%d Tage"}},
{"hours", {"Stunde", "Stunden"}}, {"%d hours", {"%d Stunde", "%d Stunden"}},
{"minutes", {"Minute", "Minuten"}}, {"%d minutes", {"%d Minute", "%d Minuten"}},
{"seconds", {"Sekunde", "Sekunden"}}, {"%d seconds", {"%d Sekunde", "%d Sekunden"}},
{"", {"", ""}}, {"", {"", ""}},
}; };

@ -67,17 +67,71 @@ namespace i18n
const std::map<std::string, std::vector<std::string>> m_Plurals; const std::map<std::string, std::vector<std::string>> m_Plurals;
std::function<int(int)> m_Formula; std::function<int(int)> m_Formula;
}; };
void SetLanguage(const std::string &lang); void SetLanguage(const std::string &lang);
std::string translate (const std::string& arg); std::string translate (const std::string& arg);
std::string translate (const std::string& arg, const std::string& arg2, const int& n); std::string translate (const std::string& arg, const std::string& arg2, const int& n);
} // i18n } // i18n
} // i2p } // i2p
template<typename... TArgs> /**
std::string tr (TArgs&&... args) * @brief Get translation of string
* @param arg String with message
*/
template<typename TValue>
std::string tr (TValue&& arg)
{
return i2p::i18n::translate(std::forward<TValue>(arg));
}
/**
* @brief Get translation of string and format it
* @param arg String with message
* @param args Array of arguments for string formatting
*/
template<typename TValue, typename... TArgs>
std::string tr (TValue&& arg, TArgs&&... args)
{ {
return i2p::i18n::translate(std::forward<TArgs>(args)...); std::string tr_str = i2p::i18n::translate(std::forward<TValue>(arg));
size_t size = snprintf(NULL, 0, tr_str.c_str(), std::forward<TArgs>(args)...);
size = size + 1;
std::string str(size, 0);
snprintf(str.data(), size, tr_str.c_str(), std::forward<TArgs>(args)...);
return str;
}
/**
* @brief Get translation of string with plural forms
* @param arg String with message in singular form
* @param arg2 String with message in plural form
* @param n Integer, used for selection of form
*/
template<typename TValue, typename TValue2>
std::string ntr (TValue&& arg, TValue2&& arg2, int& n)
{
return i2p::i18n::translate(std::forward<TValue>(arg), std::forward<TValue2>(arg2), std::forward<int>(n));
}
/**
* @brief Get translation of string with plural forms and format it
* @param arg String with message in singular form
* @param arg2 String with message in plural form
* @param n Integer, used for selection of form
* @param args Array of arguments for string formatting
*/
template<typename TValue, typename TValue2, typename... TArgs>
std::string ntr (TValue&& arg, TValue2&& arg2, int& n, TArgs&&... args)
{
std::string tr_str = i2p::i18n::translate(std::forward<TValue>(arg), std::forward<TValue2>(arg2), std::forward<int>(n));
size_t size = snprintf(NULL, 0, tr_str.c_str(), std::forward<TArgs>(args)...);
size = size + 1;
std::string str(size, 0);
snprintf(str.data(), size, tr_str.c_str(), std::forward<TArgs>(args)...);
return str;
} }
#endif // __I18N_H__ #endif // __I18N_H__

@ -31,9 +31,9 @@ namespace italian // language namespace
static std::map<std::string, std::string> strings static std::map<std::string, std::string> strings
{ {
{"KiB", "KiB"}, {"%.2f KiB", "%.2f KiB"},
{"MiB", "MiB"}, {"%.2f MiB", "%.2f MiB"},
{"GiB", "GiB"}, {"%.2f GiB", "%.2f GiB"},
{"building", "in costruzione"}, {"building", "in costruzione"},
{"failed", "fallito"}, {"failed", "fallito"},
{"expiring", "in scadenza"}, {"expiring", "in scadenza"},
@ -69,7 +69,7 @@ namespace italian // language namespace
{"Family", "Famiglia"}, {"Family", "Famiglia"},
{"Tunnel creation success rate", "Percentuale di tunnel creati con successo"}, {"Tunnel creation success rate", "Percentuale di tunnel creati con successo"},
{"Received", "Ricevuti"}, {"Received", "Ricevuti"},
{"KiB/s", "KiB/s"}, {"%.2f KiB/s", "%.2f KiB/s"},
{"Sent", "Inviati"}, {"Sent", "Inviati"},
{"Transit", "Transitati"}, {"Transit", "Transitati"},
{"Data path", "Percorso dati"}, {"Data path", "Percorso dati"},
@ -95,7 +95,7 @@ namespace italian // language namespace
{"Type", "Tipologia"}, {"Type", "Tipologia"},
{"EncType", "Tipo di crittografia"}, {"EncType", "Tipo di crittografia"},
{"Inbound tunnels", "Tunnel in entrata"}, {"Inbound tunnels", "Tunnel in entrata"},
{"ms", "ms"}, {"%dms", "%dms"},
{"Outbound tunnels", "Tunnel in uscita"}, {"Outbound tunnels", "Tunnel in uscita"},
{"Tags", "Tag"}, {"Tags", "Tag"},
{"Incoming", "In entrata"}, {"Incoming", "In entrata"},
@ -199,10 +199,10 @@ namespace italian // language namespace
static std::map<std::string, std::vector<std::string>> plurals static std::map<std::string, std::vector<std::string>> plurals
{ {
{"days", {"giorno", "giorni"}}, {"%d days", {"%d giorno", "%d giorni"}},
{"hours", {"ora", "ore"}}, {"%d hours", {"%d ora", "%d ore"}},
{"minutes", {"minuto", "minuti"}}, {"%d minutes", {"%d minuto", "%d minuti"}},
{"seconds", {"secondo", "secondi"}}, {"%d seconds", {"%d secondo", "%d secondi"}},
{"", {"", ""}}, {"", {"", ""}},
}; };

@ -31,9 +31,9 @@ namespace russian // language namespace
static std::map<std::string, std::string> strings static std::map<std::string, std::string> strings
{ {
{"KiB", "КиБ"}, {"%.2f KiB", "%.2f КиБ"},
{"MiB", "МиБ"}, {"%.2f MiB", "%.2f МиБ"},
{"GiB", "ГиБ"}, {"%.2f GiB", "%.2f ГиБ"},
{"building", "строится"}, {"building", "строится"},
{"failed", "неудачный"}, {"failed", "неудачный"},
{"expiring", "истекает"}, {"expiring", "истекает"},
@ -68,7 +68,7 @@ namespace russian // language namespace
{"Family", "Семейство"}, {"Family", "Семейство"},
{"Tunnel creation success rate", "Успешно построенных туннелей"}, {"Tunnel creation success rate", "Успешно построенных туннелей"},
{"Received", "Получено"}, {"Received", "Получено"},
{"KiB/s", "КиБ/с"}, {"%.2f KiB/s", "%.2f КиБ/с"},
{"Sent", "Отправлено"}, {"Sent", "Отправлено"},
{"Transit", "Транзит"}, {"Transit", "Транзит"},
{"Data path", "Путь к данным"}, {"Data path", "Путь к данным"},
@ -94,7 +94,7 @@ namespace russian // language namespace
{"Type", "Тип"}, {"Type", "Тип"},
{"EncType", "ТипШифр"}, {"EncType", "ТипШифр"},
{"Inbound tunnels", "Входящие туннели"}, {"Inbound tunnels", "Входящие туннели"},
{"ms", "мс"}, {"%dms", "%dмс"},
{"Outbound tunnels", "Исходящие туннели"}, {"Outbound tunnels", "Исходящие туннели"},
{"Tags", "Теги"}, {"Tags", "Теги"},
{"Incoming", "Входящие"}, {"Incoming", "Входящие"},
@ -198,10 +198,10 @@ namespace russian // language namespace
static std::map<std::string, std::vector<std::string>> plurals static std::map<std::string, std::vector<std::string>> plurals
{ {
{"days", {"день", "дня", "дней"}}, {"%d days", {"%d день", "%d дня", "%d дней"}},
{"hours", {"час", "часа", "часов"}}, {"%d hours", {"%d час", "%d часа", "%d часов"}},
{"minutes", {"минуту", "минуты", "минут"}}, {"%d minutes", {"%d минуту", "%d минуты", "%d минут"}},
{"seconds", {"секунду", "секунды", "секунд"}}, {"%d seconds", {"%d секунду", "%d секунды", "%d секунд"}},
{"", {"", "", ""}}, {"", {"", "", ""}},
}; };

@ -31,9 +31,9 @@ namespace spanish // language namespace
static std::map<std::string, std::string> strings static std::map<std::string, std::string> strings
{ {
{"KiB", "KiB"}, {"%.2f KiB", "%.2f KiB"},
{"MiB", "MiB"}, {"%.2f MiB", "%.2f MiB"},
{"GiB", "GiB"}, {"%.2f GiB", "%.2f GiB"},
{"building", "pendiente"}, {"building", "pendiente"},
{"failed", "fallido"}, {"failed", "fallido"},
{"expiring", "expiró"}, {"expiring", "expiró"},
@ -69,7 +69,7 @@ namespace spanish // language namespace
{"Family", "Familia"}, {"Family", "Familia"},
{"Tunnel creation success rate", "Tasa de éxito de creación de túneles"}, {"Tunnel creation success rate", "Tasa de éxito de creación de túneles"},
{"Received", "Recibido"}, {"Received", "Recibido"},
{"KiB/s", "KiB/s"}, {"%.2f KiB/s", "%.2f KiB/s"},
{"Sent", "Enviado"}, {"Sent", "Enviado"},
{"Transit", "Tránsito"}, {"Transit", "Tránsito"},
{"Data path", "Ruta de datos"}, {"Data path", "Ruta de datos"},
@ -95,7 +95,7 @@ namespace spanish // language namespace
{"Type", "Tipo"}, {"Type", "Tipo"},
{"EncType", "TipoEncrip"}, {"EncType", "TipoEncrip"},
{"Inbound tunnels", "Túneles entrantes"}, {"Inbound tunnels", "Túneles entrantes"},
{"ms", "ms"}, {"%dms", "%dms"},
{"Outbound tunnels", "Túneles salientes"}, {"Outbound tunnels", "Túneles salientes"},
{"Tags", "Etiquetas"}, {"Tags", "Etiquetas"},
{"Incoming", "Entrante"}, {"Incoming", "Entrante"},
@ -199,10 +199,10 @@ namespace spanish // language namespace
static std::map<std::string, std::vector<std::string>> plurals static std::map<std::string, std::vector<std::string>> plurals
{ {
{"days", {"día", "días"}}, {"%d days", {"%d día", "%d días"}},
{"hours", {"hora", "horas"}}, {"%d hours", {"%d hora", "%d horas"}},
{"minutes", {"minuto", "minutos"}}, {"%d minutes", {"%d minuto", "%d minutos"}},
{"seconds", {"segundo", "segundos"}}, {"%d seconds", {"%d segundo", "%d segundos"}},
{"", {"", ""}}, {"", {"", ""}},
}; };

@ -31,9 +31,9 @@ namespace turkmen // language namespace
static std::map<std::string, std::string> strings static std::map<std::string, std::string> strings
{ {
{"KiB", "KiB"}, {"%.2f KiB", "%.2f KiB"},
{"MiB", "MiB"}, {"%.2f MiB", "%.2f MiB"},
{"GiB", "GiB"}, {"%.2f GiB", "%.2f GiB"},
{"building", "bina"}, {"building", "bina"},
{"failed", "şowsuz"}, {"failed", "şowsuz"},
{"expiring", "möhleti gutarýar"}, {"expiring", "möhleti gutarýar"},
@ -68,7 +68,7 @@ namespace turkmen // language namespace
{"Family", "Maşgala"}, {"Family", "Maşgala"},
{"Tunnel creation success rate", "Gurlan teneller üstünlikli gurlan teneller"}, {"Tunnel creation success rate", "Gurlan teneller üstünlikli gurlan teneller"},
{"Received", "Alnan"}, {"Received", "Alnan"},
{"KiB/s", "KiB/s"}, {"%.2f KiB/s", "%.2f KiB/s"},
{"Sent", "Ýerleşdirildi"}, {"Sent", "Ýerleşdirildi"},
{"Transit", "Tranzit"}, {"Transit", "Tranzit"},
{"Data path", "Maglumat ýoly"}, {"Data path", "Maglumat ýoly"},
@ -94,7 +94,7 @@ namespace turkmen // language namespace
{"Type", "Görnüş"}, {"Type", "Görnüş"},
{"EncType", "Şifrlemek görnüşi"}, {"EncType", "Şifrlemek görnüşi"},
{"Inbound tunnels", "Gelýän tuneller"}, {"Inbound tunnels", "Gelýän tuneller"},
{"ms", "ms"}, {"%dms", "%dms"},
{"Outbound tunnels", "Çykýan tuneller"}, {"Outbound tunnels", "Çykýan tuneller"},
{"Tags", "Bellikler"}, {"Tags", "Bellikler"},
{"Incoming", "Gelýän"}, {"Incoming", "Gelýän"},
@ -198,10 +198,10 @@ namespace turkmen // language namespace
static std::map<std::string, std::vector<std::string>> plurals static std::map<std::string, std::vector<std::string>> plurals
{ {
{"days", {"gün", "gün"}}, {"%d days", {"%d gün", "%d gün"}},
{"hours", {"sagat", "sagat"}}, {"%d hours", {"%d sagat", "%d sagat"}},
{"minutes", {"minut", "minut"}}, {"%d minutes", {"%d minut", "%d minut"}},
{"seconds", {"sekunt", "sekunt"}}, {"%d seconds", {"%d sekunt", "%d sekunt"}},
{"", {"", ""}}, {"", {"", ""}},
}; };

@ -31,9 +31,9 @@ namespace ukrainian // language namespace
static std::map<std::string, std::string> strings static std::map<std::string, std::string> strings
{ {
{"KiB", "КіБ"}, {"%.2f KiB", "%.2f КіБ"},
{"MiB", "МіБ"}, {"%.2f MiB", "%.2f МіБ"},
{"GiB", "ГіБ"}, {"%.2f GiB", "%.2f ГіБ"},
{"building", "будується"}, {"building", "будується"},
{"failed", "невдалий"}, {"failed", "невдалий"},
{"expiring", "завершується"}, {"expiring", "завершується"},
@ -68,7 +68,7 @@ namespace ukrainian // language namespace
{"Family", "Сімейство"}, {"Family", "Сімейство"},
{"Tunnel creation success rate", "Успішно побудованих тунелів"}, {"Tunnel creation success rate", "Успішно побудованих тунелів"},
{"Received", "Отримано"}, {"Received", "Отримано"},
{"KiB/s", "КіБ/с"}, {"%.2f KiB/s", "%.2f КіБ/с"},
{"Sent", "Відправлено"}, {"Sent", "Відправлено"},
{"Transit", "Транзит"}, {"Transit", "Транзит"},
{"Data path", "Шлях до даних"}, {"Data path", "Шлях до даних"},
@ -94,7 +94,7 @@ namespace ukrainian // language namespace
{"Type", "Тип"}, {"Type", "Тип"},
{"EncType", "ТипШифр"}, {"EncType", "ТипШифр"},
{"Inbound tunnels", "Вхідні тунелі"}, {"Inbound tunnels", "Вхідні тунелі"},
{"ms", "мс"}, {"%dms", "%dмс"},
{"Outbound tunnels", "Вихідні тунелі"}, {"Outbound tunnels", "Вихідні тунелі"},
{"Tags", "Теги"}, {"Tags", "Теги"},
{"Incoming", "Вхідні"}, {"Incoming", "Вхідні"},
@ -198,10 +198,10 @@ namespace ukrainian // language namespace
static std::map<std::string, std::vector<std::string>> plurals static std::map<std::string, std::vector<std::string>> plurals
{ {
{"days", {"день", "дня", "днів"}}, {"%d days", {"%d день", "%d дня", "%d днів"}},
{"hours", {"годину", "години", "годин"}}, {"%d hours", {"%d годину", "%d години", "%d годин"}},
{"minutes", {"хвилину", "хвилини", "хвилин"}}, {"%d minutes", {"%d хвилину", "%d хвилини", "%d хвилин"}},
{"seconds", {"секунду", "секунди", "секунд"}}, {"%d seconds", {"%d секунду", "%d секунди", "%d секунд"}},
{"", {"", "", ""}}, {"", {"", "", ""}},
}; };

@ -31,9 +31,9 @@ namespace uzbek // language namespace
static std::map<std::string, std::string> strings static std::map<std::string, std::string> strings
{ {
{"KiB", "KiB"}, {"%.2f KiB", "%.2f KiB"},
{"MiB", "MiB"}, {"%.2f MiB", "%.2f MiB"},
{"GiB", "GiB"}, {"%.2f GiB", "%.2f GiB"},
{"building", "yaratilmoqda"}, {"building", "yaratilmoqda"},
{"failed", "muvaffaqiyatsiz"}, {"failed", "muvaffaqiyatsiz"},
{"expiring", "muddati tugaydi"}, {"expiring", "muddati tugaydi"},
@ -68,7 +68,7 @@ namespace uzbek // language namespace
{"Family", "Oila"}, {"Family", "Oila"},
{"Tunnel creation success rate", "Tunnel yaratish muvaffaqiyat darajasi"}, {"Tunnel creation success rate", "Tunnel yaratish muvaffaqiyat darajasi"},
{"Received", "Qabul qilindi"}, {"Received", "Qabul qilindi"},
{"KiB/s", "KiB/s"}, {"%.2f KiB/s", "%.2f KiB/s"},
{"Sent", "Yuborilgan"}, {"Sent", "Yuborilgan"},
{"Transit", "Tranzit"}, {"Transit", "Tranzit"},
{"Data path", "Ma'lumotlar joylanishi"}, {"Data path", "Ma'lumotlar joylanishi"},
@ -94,7 +94,7 @@ namespace uzbek // language namespace
{"Type", "Turi"}, {"Type", "Turi"},
{"EncType", "ShifrlashTuri"}, {"EncType", "ShifrlashTuri"},
{"Inbound tunnels", "Kirish tunnellari"}, {"Inbound tunnels", "Kirish tunnellari"},
{"ms", "ms"}, {"%dms", "%dms"},
{"Outbound tunnels", "Chiquvchi tunnellar"}, {"Outbound tunnels", "Chiquvchi tunnellar"},
{"Tags", "Teglar"}, {"Tags", "Teglar"},
{"Incoming", "Kiruvchi"}, {"Incoming", "Kiruvchi"},
@ -198,10 +198,10 @@ namespace uzbek // language namespace
static std::map<std::string, std::vector<std::string>> plurals static std::map<std::string, std::vector<std::string>> plurals
{ {
{"days", {"kun", "kun"}}, {"%d days", {"%d kun", "%d kun"}},
{"hours", {"soat", "soat"}}, {"%d hours", {"%d soat", "%d soat"}},
{"minutes", {"daqiqa", "daqiqa"}}, {"%d minutes", {"%d daqiqa", "%d daqiqa"}},
{"seconds", {"soniya", "soniya"}}, {"%d seconds", {"%d soniya", "%d soniya"}},
{"", {"", ""}}, {"", {"", ""}},
}; };

Loading…
Cancel
Save