summaryrefslogtreecommitdiff
path: root/src/language.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/language.cpp')
-rw-r--r--src/language.cpp57
1 files changed, 43 insertions, 14 deletions
diff --git a/src/language.cpp b/src/language.cpp
index 7fd63c756..bbcef2844 100644
--- a/src/language.cpp
+++ b/src/language.cpp
@@ -1,12 +1,20 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2017 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2003-2017 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
#include "services.h"
@@ -14,6 +22,7 @@
#include "commands.h"
#include "config.h"
#include "language.h"
+#include "modules/nickserv.h"
#if GETTEXT_FOUND
# include <libintl.h>
@@ -25,33 +34,33 @@ std::vector<Anope::string> Language::Domains;
void Language::InitLanguages()
{
#if GETTEXT_FOUND
- Log(LOG_DEBUG) << "Initializing Languages...";
+ Anope::Logger.Debug("Initializing Languages...");
Languages.clear();
if (!bindtextdomain("anope", Anope::LocaleDir.c_str()))
- Log() << "Error calling bindtextdomain, " << Anope::LastError();
+ Anope::Logger.Log("Error calling bindtextdomain, {0}", Anope::LastError());
else
- Log(LOG_DEBUG) << "Successfully bound anope to " << Anope::LocaleDir;
+ Anope::Logger.Debug("Successfully bound anope to {0}", Anope::LocaleDir);
setlocale(LC_ALL, "");
- spacesepstream sep(Config->GetBlock("options")->Get<const Anope::string>("languages"));
+ spacesepstream sep(Config->GetBlock("options")->Get<Anope::string>("languages"));
Anope::string language;
while (sep.GetToken(language))
{
const Anope::string &lang_name = Translate(language.c_str(), _("English"));
if (lang_name == "English")
{
- Log() << "Unable to use language " << language;
+ Anope::Logger.Log("Unable to use language {0}", language);
continue;
}
- Log(LOG_DEBUG) << "Found language " << language;
+ Anope::Logger.Debug("Found language {0}", language);
Languages.push_back(language);
}
#else
- Log() << "Unable to initialize languages, gettext is not installed";
+ Anope::Logger.Log("Unable to initialize languages, gettext is not installed");
#endif
}
@@ -60,6 +69,11 @@ const char *Language::Translate(const char *string)
return Translate("", string);
}
+const char *Language::Translate(const Anope::string &string)
+{
+ return Translate("", string.c_str());
+}
+
const char *Language::Translate(User *u, const char *string)
{
if (u && u->Account())
@@ -68,9 +82,19 @@ const char *Language::Translate(User *u, const char *string)
return Translate("", string);
}
-const char *Language::Translate(const NickCore *nc, const char *string)
+const char *Language::Translate(User *u, const Anope::string &string)
+{
+ return Translate(u, string.c_str());
+}
+
+const char *Language::Translate(NickServ::Account *nc, const char *string)
{
- return Translate(nc ? nc->language.c_str() : "", string);
+ return Translate(nc ? nc->GetLanguage().c_str() : "", string);
+}
+
+const char *Language::Translate(NickServ::Account *nc, const Anope::string &string)
+{
+ return Translate(nc, string.c_str());
}
#if GETTEXT_FOUND
@@ -85,7 +109,12 @@ const char *Language::Translate(const char *lang, const char *string)
return "";
if (!lang || !*lang)
+ {
+ if (Config == nullptr)
+ return string;
+
lang = Config->DefLanguage.c_str();
+ }
#ifdef __USE_GNU_GETTEXT
++_nl_msg_cat_cntr;