mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 11:04:00 +01:00
moved current language from RouterContext to ClientContext
This commit is contained in:
parent
bce8469e59
commit
e8f4c42bfb
|
@ -240,7 +240,7 @@ namespace http {
|
||||||
std::string webroot; i2p::config::GetOption("http.webroot", webroot);
|
std::string webroot; i2p::config::GetOption("http.webroot", webroot);
|
||||||
|
|
||||||
// Page language
|
// Page language
|
||||||
std::string currLang = i2p::context.GetLanguage ()->GetLanguage(); // get current used language
|
std::string currLang = i2p::client::context.GetLanguage ()->GetLanguage(); // get current used language
|
||||||
auto it = i2p::i18n::languages.find(currLang);
|
auto it = i2p::i18n::languages.find(currLang);
|
||||||
std::string langCode = it->second.ShortCode;
|
std::string langCode = it->second.ShortCode;
|
||||||
|
|
||||||
|
@ -766,7 +766,7 @@ namespace http {
|
||||||
s << " <button type=\"submit\">" << tr("Change") << "</button>\r\n";
|
s << " <button type=\"submit\">" << tr("Change") << "</button>\r\n";
|
||||||
s << "</form>\r\n<br>\r\n";
|
s << "</form>\r\n<br>\r\n";
|
||||||
|
|
||||||
std::string currLang = i2p::context.GetLanguage ()->GetLanguage(); // get current used language
|
std::string currLang = i2p::client::context.GetLanguage ()->GetLanguage(); // get current used language
|
||||||
s << "<b>" << tr("Change language") << "</b><br>\r\n";
|
s << "<b>" << tr("Change language") << "</b><br>\r\n";
|
||||||
s << "<form method=\"get\" action=\"" << webroot << "\">\r\n";
|
s << "<form method=\"get\" action=\"" << webroot << "\">\r\n";
|
||||||
s << " <input type=\"hidden\" name=\"cmd\" value=\"" << HTTP_COMMAND_SETLANGUAGE << "\">\r\n";
|
s << " <input type=\"hidden\" name=\"cmd\" value=\"" << HTTP_COMMAND_SETLANGUAGE << "\">\r\n";
|
||||||
|
@ -1382,7 +1382,7 @@ namespace http {
|
||||||
else if (cmd == HTTP_COMMAND_SETLANGUAGE)
|
else if (cmd == HTTP_COMMAND_SETLANGUAGE)
|
||||||
{
|
{
|
||||||
std::string lang = params["lang"];
|
std::string lang = params["lang"];
|
||||||
std::string currLang = i2p::context.GetLanguage ()->GetLanguage();
|
std::string currLang = i2p::client::context.GetLanguage ()->GetLanguage();
|
||||||
|
|
||||||
if (currLang.compare(lang) != 0)
|
if (currLang.compare(lang) != 0)
|
||||||
i2p::i18n::SetLanguage(lang);
|
i2p::i18n::SetLanguage(lang);
|
||||||
|
|
10
i18n/I18N.h
10
i18n/I18N.h
|
@ -9,7 +9,7 @@
|
||||||
#ifndef __I18N_H__
|
#ifndef __I18N_H__
|
||||||
#define __I18N_H__
|
#define __I18N_H__
|
||||||
|
|
||||||
#include "RouterContext.h"
|
#include "ClientContext.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
|
@ -19,19 +19,19 @@ namespace i18n
|
||||||
{
|
{
|
||||||
const auto it = i2p::i18n::languages.find(lang);
|
const auto it = i2p::i18n::languages.find(lang);
|
||||||
if (it == i2p::i18n::languages.end()) // fallback
|
if (it == i2p::i18n::languages.end()) // fallback
|
||||||
i2p::context.SetLanguage (i2p::i18n::english::GetLocale());
|
i2p::client::context.SetLanguage (i2p::i18n::english::GetLocale());
|
||||||
else
|
else
|
||||||
i2p::context.SetLanguage (it->second.LocaleFunc());
|
i2p::client::context.SetLanguage (it->second.LocaleFunc());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string translate (const std::string& arg)
|
inline std::string translate (const std::string& arg)
|
||||||
{
|
{
|
||||||
return i2p::context.GetLanguage ()->GetString (arg);
|
return i2p::client::context.GetLanguage ()->GetString (arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string translate (const std::string& arg, const std::string& arg2, const int& n)
|
inline std::string translate (const std::string& arg, const std::string& arg2, const int& n)
|
||||||
{
|
{
|
||||||
return i2p::context.GetLanguage ()->GetPlural (arg, arg2, n);
|
return i2p::client::context.GetLanguage ()->GetPlural (arg, arg2, n);
|
||||||
}
|
}
|
||||||
} // i18n
|
} // i18n
|
||||||
} // i2p
|
} // i2p
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
#include "RouterInfo.h"
|
#include "RouterInfo.h"
|
||||||
#include "Garlic.h"
|
#include "Garlic.h"
|
||||||
#include "I18N_langs.h"
|
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
|
@ -146,10 +145,6 @@ namespace garlic
|
||||||
void ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg);
|
void ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg);
|
||||||
void ProcessDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg);
|
void ProcessDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg);
|
||||||
|
|
||||||
// i18n
|
|
||||||
std::shared_ptr<const i2p::i18n::Locale> GetLanguage () { return m_Language; };
|
|
||||||
void SetLanguage (const std::shared_ptr<const i2p::i18n::Locale> language) { m_Language = language; };
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// implements GarlicDestination
|
// implements GarlicDestination
|
||||||
|
@ -186,9 +181,6 @@ namespace garlic
|
||||||
std::unique_ptr<i2p::crypto::X25519Keys> m_StaticKeys;
|
std::unique_ptr<i2p::crypto::X25519Keys> m_StaticKeys;
|
||||||
// for ECIESx25519
|
// for ECIESx25519
|
||||||
i2p::crypto::NoiseSymmetricState m_InitialNoiseState, m_CurrentNoiseState;
|
i2p::crypto::NoiseSymmetricState m_InitialNoiseState, m_CurrentNoiseState;
|
||||||
|
|
||||||
// i18n
|
|
||||||
std::shared_ptr<const i2p::i18n::Locale> m_Language;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern RouterContext context;
|
extern RouterContext context;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "BOB.h"
|
#include "BOB.h"
|
||||||
#include "I2CP.h"
|
#include "I2CP.h"
|
||||||
#include "AddressBook.h"
|
#include "AddressBook.h"
|
||||||
|
#include "I18N_langs.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
|
@ -102,6 +103,10 @@ namespace client
|
||||||
|
|
||||||
std::vector<std::shared_ptr<DatagramSessionInfo> > GetForwardInfosFor(const i2p::data::IdentHash & destination);
|
std::vector<std::shared_ptr<DatagramSessionInfo> > GetForwardInfosFor(const i2p::data::IdentHash & destination);
|
||||||
|
|
||||||
|
// i18n
|
||||||
|
std::shared_ptr<const i2p::i18n::Locale> GetLanguage () { return m_Language; };
|
||||||
|
void SetLanguage (const std::shared_ptr<const i2p::i18n::Locale> language) { m_Language = language; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void ReadTunnels ();
|
void ReadTunnels ();
|
||||||
|
@ -149,6 +154,9 @@ namespace client
|
||||||
|
|
||||||
std::unique_ptr<boost::asio::deadline_timer> m_CleanupUDPTimer;
|
std::unique_ptr<boost::asio::deadline_timer> m_CleanupUDPTimer;
|
||||||
|
|
||||||
|
// i18n
|
||||||
|
std::shared_ptr<const i2p::i18n::Locale> m_Language;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// for HTTP
|
// for HTTP
|
||||||
|
|
Loading…
Reference in a new issue