Configure user language in controlpanel and webadmin

This commit is contained in:
Alexey Sokolov
2016-01-31 15:29:31 +00:00
parent 8863bed13d
commit 0459f67b1d
3 changed files with 44 additions and 0 deletions
+13
View File
@@ -105,6 +105,9 @@ class CAdminMod : public CModule {
{"TimestampFormat", str},
{"DCCBindHost", str},
{"StatusPrefix", str},
#ifdef HAVE_I18N
{"Language", str},
#endif
#ifdef HAVE_ICU
{"ClientEncoding", str},
#endif
@@ -266,6 +269,10 @@ class CAdminMod : public CModule {
PutModule("Admin = " + CString(pUser->IsAdmin()));
else if (sVar == "statusprefix")
PutModule("StatusPrefix = " + pUser->GetStatusPrefix());
#ifdef HAVE_I18N
else if (sVar == "language")
PutModule("Language = " + pUser->GetLanguage());
#endif
#ifdef HAVE_ICU
else if (sVar == "clientencoding")
PutModule("ClientEncoding = " + pUser->GetClientEncoding());
@@ -430,6 +437,12 @@ class CAdminMod : public CModule {
PutModule("That would be a bad idea!");
}
}
#ifdef HAVE_I18N
else if (sVar == "language") {
pUser->SetLanguage(sValue);
PutModule("Language = " + pUser->GetLanguage());
}
#endif
#ifdef HAVE_ICU
else if (sVar == "clientencoding") {
pUser->SetClientEncoding(sValue);
@@ -364,6 +364,21 @@
<? ENDIF ?>
</div>
<div class="subsection">
<div class="inputlabel">Language:</div>
<? IF HaveI18N ?>
<select name="language">
<? LOOP LanguageLoop ?>
<option value="<? VAR Code ?>" <? IF Language TOP == *Code ?>selected="selected"<? ENDIF ?>><? VAR Name ?></option>
<? ENDLOOP ?>
</select>
<? ELSE ?>
ZNC is compiled without i18n support
<? ENDIF ?>
</div>
<div style="clear: both;"></div>
</div>
</div>
+16
View File
@@ -306,6 +306,9 @@ class CWebAdminMod : public CModule {
pNewUser->SetMaxQueryBuffers(
WebSock.GetParam("maxquerybuffers").ToUInt());
#ifdef HAVE_I18N
pNewUser->SetLanguage(WebSock.GetParam("language"));
#endif
#ifdef HAVE_ICU
CString sEncodingUtf = WebSock.GetParam("encoding_utf");
if (sEncodingUtf == "legacy") {
@@ -1298,6 +1301,7 @@ class CWebAdminMod : public CModule {
Tmpl["MaxNetworks"] = CString(pUser->MaxNetworks());
Tmpl["MaxJoins"] = CString(pUser->MaxJoins());
Tmpl["MaxQueryBuffers"] = CString(pUser->MaxQueryBuffers());
Tmpl["Language"] = pUser->GetLanguage();
const set<CString>& ssAllowedHosts = pUser->GetAllowedHosts();
for (const CString& sHost : ssAllowedHosts) {
@@ -1337,6 +1341,18 @@ class CWebAdminMod : public CModule {
l["TZ"] = sTZ;
}
#ifdef HAVE_I18N
Tmpl["HaveI18N"] = "true";
// TODO don't have them hardcoded here
CTemplate& l_en = Tmpl.AddRow("LanguageLoop");
l_en["Code"] = "";
l_en["Name"] = "English";
CTemplate& l_ru = Tmpl.AddRow("LanguageLoop");
l_ru["Code"] = "ru_RU";
l_ru["Name"] = "Russian";
#else
Tmpl["HaveI18N"] = "false";
#endif
#ifdef HAVE_ICU
for (const CString& sEncoding : CUtils::GetEncodings()) {
CTemplate& l = Tmpl.AddRow("EncodingLoop");