mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
[i18n] rework localization system
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
1a4250d8cc
commit
779f2fa451
7 changed files with 111 additions and 109 deletions
38
i18n/I18N.h
38
i18n/I18N.h
|
@ -11,37 +11,27 @@
|
|||
|
||||
#include "RouterContext.h"
|
||||
|
||||
|
||||
namespace i2p {
|
||||
namespace i18n {
|
||||
namespace i2p
|
||||
{
|
||||
namespace i18n
|
||||
{
|
||||
inline void SetLanguage(const std::string &lang)
|
||||
{
|
||||
if (!lang.compare("russian"))
|
||||
i2p::context.SetLanguage (i2p::i18n::russian::GetLocale());
|
||||
else
|
||||
i2p::context.SetLanguage (i2p::i18n::english::GetLocale());
|
||||
}
|
||||
|
||||
inline std::string translate (const std::string& arg)
|
||||
{
|
||||
switch (i2p::context.GetLanguage ())
|
||||
{
|
||||
case eEnglish:
|
||||
return i2p::i18n::english::GetString (arg);
|
||||
case eRussian:
|
||||
return i2p::i18n::russian::GetString (arg);
|
||||
default:
|
||||
return arg;
|
||||
}
|
||||
return i2p::context.GetLanguage ()->GetString (arg);
|
||||
}
|
||||
|
||||
template<typename inttype>
|
||||
std::string translate (const std::string& arg, inttype&& n)
|
||||
inline std::string translate (const std::string& arg, const int& n)
|
||||
{
|
||||
switch (i2p::context.GetLanguage ())
|
||||
{
|
||||
case eEnglish:
|
||||
return i2p::i18n::english::GetPlural (arg, (int) n);
|
||||
case eRussian:
|
||||
return i2p::i18n::russian::GetPlural (arg, (int) n);
|
||||
default:
|
||||
return arg;
|
||||
}
|
||||
return i2p::context.GetLanguage ()->GetPlural (arg, n);
|
||||
}
|
||||
|
||||
} // i18n
|
||||
} // i2p
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue