/* * 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 "confparser.h" #include #include // !! locale nie powinny byc w templates? 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); bool IsKey(const std::string & key) const; bool IsKey(const std::string & key, Lang lang) const; const std::string & Get(const std::string & key) const; const std::string & Get(const std::string & 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::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); bool ReadFile(const char * dir, Lang lang, const char * file); std::vector loc_tab; ConfParser loc_parser; std::string file_name; std::string empty; Lang default_lang; Lang current_lang; }; #endif