This commit is contained in:
dr|z3d 2021-09-05 02:33:56 +00:00
commit feed4c8d4b
7 changed files with 24 additions and 20 deletions

View file

@ -472,7 +472,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;
// SAM // SAM
@ -1340,7 +1340,7 @@ namespace http {
s << "</form>\r\n</div>\r\n</th></tr>\r\n"; s << "</form>\r\n</div>\r\n</th></tr>\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 << "<tr class=\"sectiontitle\"><th colspan=\"2\"><span>" << tr("Console Display Language") << "</span>\r\n"; s << "<tr class=\"sectiontitle\"><th colspan=\"2\"><span>" << tr("Console Display Language") << "</span>\r\n";
s << "<div id=\"consolelang\" class=\"chrome\">\r\n"; s << "<div id=\"consolelang\" class=\"chrome\">\r\n";
s << "<form method=\"get\" action=\"" << webroot << "\">\r\n"; s << "<form method=\"get\" action=\"" << webroot << "\">\r\n";
@ -2123,7 +2123,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);

View file

@ -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

View file

@ -139,6 +139,7 @@ namespace client
void SetLeaseSetUpdated (); void SetLeaseSetUpdated ();
bool IsPublic () const { return m_IsPublic; }; bool IsPublic () const { return m_IsPublic; };
void SetPublic (bool pub) { m_IsPublic = pub; };
protected: protected:

View file

@ -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;

View file

@ -713,7 +713,10 @@ namespace client
std::shared_ptr<ClientDestination> localDestination = nullptr; std::shared_ptr<ClientDestination> localDestination = nullptr;
auto it = destinations.find (keys); auto it = destinations.find (keys);
if (it != destinations.end ()) if (it != destinations.end ())
{
localDestination = it->second; localDestination = it->second;
localDestination->SetPublic (true);
}
else else
{ {
i2p::data::PrivateKeys k; i2p::data::PrivateKeys k;
@ -725,6 +728,8 @@ namespace client
localDestination = CreateNewLocalDestination (k, true, &options); localDestination = CreateNewLocalDestination (k, true, &options);
destinations[keys] = localDestination; destinations[keys] = localDestination;
} }
else
localDestination->SetPublic (true);
} }
if (type == I2P_TUNNELS_SECTION_TYPE_UDPSERVER) if (type == I2P_TUNNELS_SECTION_TYPE_UDPSERVER)
{ {

View file

@ -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

View file

@ -1,7 +1,5 @@
CXXFLAGS += -Wall -Wno-unused-parameter -Wextra -pedantic -O0 -g -std=c++11 -D_GLIBCXX_USE_NANOSLEEP=1 -pthread -Wl,--unresolved-symbols=ignore-in-object-files CXXFLAGS += -Wall -Wno-unused-parameter -Wextra -pedantic -O0 -g -std=c++11 -D_GLIBCXX_USE_NANOSLEEP=1 -pthread -Wl,--unresolved-symbols=ignore-in-object-files
INCFLAGS += -I../libi2pd -I../i18n INCFLAGS += -I../libi2pd
LOCALESRC = ../i18n/Afrikaans.cpp ../i18n/English.cpp ../i18n/Russian.cpp ../i18n/Turkmen.cpp ../i18n/Ukrainian.cpp ../i18n/Uzbek.cpp
TESTS = test-gost test-gost-sig test-base-64 test-x25519 test-aeadchacha20poly1305 test-blinding test-elligator TESTS = test-gost test-gost-sig test-base-64 test-x25519 test-aeadchacha20poly1305 test-blinding test-elligator
@ -25,7 +23,7 @@ test-x25519: ../libi2pd/Ed25519.cpp ../libi2pd/I2PEndian.cpp ../libi2pd/Log.cpp
test-aeadchacha20poly1305: ../libi2pd/Crypto.cpp ../libi2pd/ChaCha20.cpp ../libi2pd/Poly1305.cpp test-aeadchacha20poly1305.cpp test-aeadchacha20poly1305: ../libi2pd/Crypto.cpp ../libi2pd/ChaCha20.cpp ../libi2pd/Poly1305.cpp test-aeadchacha20poly1305.cpp
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ -lcrypto -lssl -lboost_system $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ -lcrypto -lssl -lboost_system
test-blinding: ../libi2pd/Crypto.cpp ../libi2pd/Blinding.cpp ../libi2pd/Ed25519.cpp ../libi2pd/I2PEndian.cpp ../libi2pd/Log.cpp ../libi2pd/util.cpp ../libi2pd/Identity.cpp ../libi2pd/Signature.cpp ../libi2pd/Timestamp.cpp $(LOCALESRC) test-blinding.cpp test-blinding: ../libi2pd/Crypto.cpp ../libi2pd/Blinding.cpp ../libi2pd/Ed25519.cpp ../libi2pd/I2PEndian.cpp ../libi2pd/Log.cpp ../libi2pd/util.cpp ../libi2pd/Identity.cpp ../libi2pd/Signature.cpp ../libi2pd/Timestamp.cpp test-blinding.cpp
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ -lcrypto -lssl -lboost_system $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ -lcrypto -lssl -lboost_system
test-elligator: ../libi2pd/Elligator.cpp ../libi2pd/Crypto.cpp test-elligator.cpp test-elligator: ../libi2pd/Elligator.cpp ../libi2pd/Crypto.cpp test-elligator.cpp