2021-05-22 08:39:05 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, The PurpleI2P Project
|
|
|
|
*
|
|
|
|
* This file is part of Purple i2pd project and licensed under BSD3
|
|
|
|
*
|
|
|
|
* See full license text in LICENSE file at top of project tree
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __I18N_H__
|
|
|
|
#define __I18N_H__
|
|
|
|
|
2021-05-22 18:29:05 +03:00
|
|
|
#include "RouterContext.h"
|
|
|
|
|
2021-05-25 22:03:29 +03:00
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace i18n
|
|
|
|
{
|
|
|
|
inline void SetLanguage(const std::string &lang)
|
|
|
|
{
|
|
|
|
if (!lang.compare("russian"))
|
|
|
|
i2p::context.SetLanguage (i2p::i18n::russian::GetLocale());
|
2021-05-26 13:27:13 +03:00
|
|
|
else if (!lang.compare("ukrainian"))
|
2021-05-26 10:50:02 +03:00
|
|
|
i2p::context.SetLanguage (i2p::i18n::ukrainian::GetLocale());
|
|
|
|
else // fallback
|
2021-05-25 22:03:29 +03:00
|
|
|
i2p::context.SetLanguage (i2p::i18n::english::GetLocale());
|
|
|
|
}
|
2021-05-22 08:39:05 +03:00
|
|
|
|
2021-05-23 15:52:27 +03:00
|
|
|
inline std::string translate (const std::string& arg)
|
2021-05-22 08:39:05 +03:00
|
|
|
{
|
2021-05-25 22:03:29 +03:00
|
|
|
return i2p::context.GetLanguage ()->GetString (arg);
|
2021-05-22 08:39:05 +03:00
|
|
|
}
|
|
|
|
|
2021-05-25 22:03:29 +03:00
|
|
|
inline std::string translate (const std::string& arg, const int& n)
|
2021-05-22 08:39:05 +03:00
|
|
|
{
|
2021-05-25 22:03:29 +03:00
|
|
|
return i2p::context.GetLanguage ()->GetPlural (arg, n);
|
2021-05-22 08:39:05 +03:00
|
|
|
}
|
|
|
|
} // i18n
|
|
|
|
} // i2p
|
|
|
|
|
|
|
|
template<typename... TArgs>
|
2021-05-23 06:06:04 +03:00
|
|
|
std::string tr (TArgs&&... args)
|
|
|
|
{
|
2021-05-22 08:39:05 +03:00
|
|
|
return i2p::i18n::translate(std::forward<TArgs>(args)...);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __I18N_H__
|