91 lines
2.0 KiB
C++
Executable File
91 lines
2.0 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2010, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#ifndef headerfilecmslucorelocale
|
|
#define headerfilecmslucorelocale
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include "core/confparser.h"
|
|
|
|
|
|
|
|
class Locale
|
|
{
|
|
public:
|
|
|
|
// !! pozbyc sie tego enuma
|
|
// niech wybieranie ilosci locali (ile jezykow) bedzie w pliku konfiguracyjnym
|
|
enum Lang
|
|
{
|
|
lang_en = 0,
|
|
lang_pl,
|
|
|
|
lang_unknown // should be last
|
|
};
|
|
|
|
Locale();
|
|
|
|
void Read(const char * dir, const char * dir_def = 0);
|
|
void Read(const std::string & dir, const std::string & dir_def);
|
|
|
|
void Read(const wchar_t * dir, const wchar_t * dir_def = 0);
|
|
void Read(const std::wstring & dir, const std::wstring & dir_def);
|
|
|
|
bool IsKey(const std::wstring & key) const;
|
|
bool IsKey(const std::wstring & key, Lang lang) const;
|
|
const std::wstring & Get(const std::wstring & key) const;
|
|
const std::wstring & Get(const std::wstring & key, Lang lang) const;
|
|
|
|
// default is english
|
|
void SetLang(Lang lang);
|
|
Lang GetLang();
|
|
|
|
// which language is used instead if there is no a key in an other language
|
|
// default: lang_en
|
|
void SetLangDef(Lang lang);
|
|
|
|
|
|
static Lang StrToLang(const std::wstring & str);
|
|
static const wchar_t * LangToStr(Lang lang);
|
|
|
|
size_t Size();
|
|
void UTF8(bool utf);
|
|
|
|
wchar_t Subst(wchar_t c);
|
|
void Subst(std::wstring & str);
|
|
|
|
private:
|
|
|
|
void AddLocale(Lang lang);
|
|
void ReadFile(const char * dir, const char * dir_def, Lang lang, const char * file);
|
|
bool ReadFile(const char * dir, Lang lang, const char * file);
|
|
void ReadSubstTable(const char * dir, const char * dir_def);
|
|
bool ReadSubstTable(const char * dir);
|
|
|
|
// messages vector<via Lang>
|
|
std::vector<ConfParser::TableSingle> loc_tab;
|
|
|
|
// these tables are used to change url characters
|
|
std::wstring subst_original;
|
|
std::wstring subst_changeto;
|
|
|
|
|
|
ConfParser loc_parser;
|
|
std::string file_name;
|
|
std::wstring empty;
|
|
std::string adir1, adir2;
|
|
Lang default_lang;
|
|
Lang current_lang;
|
|
bool input_as_utf8;
|
|
};
|
|
|
|
|
|
#endif
|