2010-01-28 16:39:01 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2010-01-28 16:39:01 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef headerfilecmslucorelocale
|
|
|
|
#define headerfilecmslucorelocale
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
#include "confparser.h"
|
2010-01-28 16:39:01 +01:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
// !! locale nie powinny byc w templates?
|
2010-01-28 16:39:01 +01:00
|
|
|
class Locale
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
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);
|
2010-02-28 01:08:10 +01:00
|
|
|
|
|
|
|
bool IsKey(const std::string & key) const;
|
|
|
|
bool IsKey(const std::string & key, Lang lang) const;
|
2010-01-28 16:39:01 +01:00
|
|
|
const std::string & Get(const std::string & key) const;
|
2010-02-28 01:08:10 +01:00
|
|
|
const std::string & Get(const std::string & key, Lang lang) const;
|
2010-01-28 16:39:01 +01:00
|
|
|
|
|
|
|
// 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::string & str);
|
|
|
|
static const char * LangToStr(Lang lang);
|
|
|
|
|
|
|
|
size_t Size();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void AddLocale(Lang lang);
|
|
|
|
void ReadFile(const char * dir, const char * dir_def, Lang lang, const char * file);
|
2010-07-21 19:24:16 +02:00
|
|
|
bool ReadFile(const char * dir, Lang lang, const char * file);
|
2010-01-28 16:39:01 +01:00
|
|
|
|
|
|
|
|
2010-07-21 19:24:16 +02:00
|
|
|
std::vector<ConfParser::TableSingle> loc_tab;
|
2010-01-28 16:39:01 +01:00
|
|
|
ConfParser loc_parser;
|
|
|
|
std::string file_name;
|
|
|
|
std::string empty;
|
|
|
|
Lang default_lang;
|
|
|
|
Lang current_lang;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|