mirror of
https://github.com/znc/znc.git
synced 2026-08-07 17:33:34 +02:00
Make list of languages installed discoverable at runtime.
Stop hardcoding Russian in webadmin. Limit the setting in controlpanel to the known languages, because untrusted language code might lead to some interesting vulnerabilities.
This commit is contained in:
@@ -15,11 +15,36 @@
|
||||
*/
|
||||
|
||||
#include <znc/Translation.h>
|
||||
#include <znc/FileUtils.h>
|
||||
|
||||
#ifdef HAVE_I18N
|
||||
#include <boost/locale.hpp>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
std::map<CString, CTranslationInfo> FillTranslations() {
|
||||
std::map<CString, CTranslationInfo> mTranslations;
|
||||
CDir Dir;
|
||||
Dir.Fill(_DATADIR_ "/translations");
|
||||
for (CFile* pFile : Dir) {
|
||||
CString sName = pFile->GetShortName();
|
||||
CTranslationInfo& translation = mTranslations[sName];
|
||||
MCString msData;
|
||||
// TODO: make the file format more sensible than this
|
||||
msData.ReadFromDisk(pFile->GetLongName());
|
||||
translation.sSelfName = msData["SelfName"];
|
||||
// TODO: right-to-left support
|
||||
}
|
||||
return mTranslations;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::map<CString, CTranslationInfo> CTranslationInfo::GetTranslations() {
|
||||
static std::map<CString, CTranslationInfo> mTranslations =
|
||||
FillTranslations();
|
||||
return mTranslations;
|
||||
}
|
||||
|
||||
CTranslation& CTranslation::Get() {
|
||||
static CTranslation translation;
|
||||
return translation;
|
||||
|
||||
Reference in New Issue
Block a user