mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-06 03:20:33 +00:00
55 lines
1.0 KiB
C++
55 lines
1.0 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 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;
|
|
}
|
|
}
|
|
|
|
template<typename inttype>
|
|
std::string translate (const std::string& arg, inttype&& 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;
|
|
}
|
|
}
|
|
|
|
} // i18n
|
|
} // i2p
|
|
|
|
template<typename... TArgs>
|
|
std::string tr (TArgs&&... args)
|
|
{
|
|
return i2p::i18n::translate(std::forward<TArgs>(args)...);
|
|
}
|
|
|
|
#endif // __I18N_H__
|