i2pd/i18n/I18N.h
R4SAS 954711e980 [i18n] pull afrikaans translation from crowdin
Signed-off-by: R4SAS <r4sas@i2pmail.org>
2021-06-16 17:57:20 +03:00

51 lines
1.2 KiB
C++

/*
* 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__
#include "RouterContext.h"
namespace i2p
{
namespace i18n
{
inline void SetLanguage(const std::string &lang)
{
if (!lang.compare("afrikaans"))
i2p::context.SetLanguage (i2p::i18n::afrikaans::GetLocale());
else if (!lang.compare("russian"))
i2p::context.SetLanguage (i2p::i18n::russian::GetLocale());
else if (!lang.compare("turkmen"))
i2p::context.SetLanguage (i2p::i18n::turkmen::GetLocale());
else if (!lang.compare("ukrainian"))
i2p::context.SetLanguage (i2p::i18n::ukrainian::GetLocale());
else // fallback
i2p::context.SetLanguage (i2p::i18n::english::GetLocale());
}
inline std::string translate (const std::string& arg)
{
return i2p::context.GetLanguage ()->GetString (arg);
}
inline std::string translate (const std::string& arg, const std::string& arg2, const int& n)
{
return i2p::context.GetLanguage ()->GetPlural (arg, arg2, n);
}
} // i18n
} // i2p
template<typename... TArgs>
std::string tr (TArgs&&... args)
{
return i2p::i18n::translate(std::forward<TArgs>(args)...);
}
#endif // __I18N_H__