From ba63c8c66104797b9947c288360bf21a0d7ddcf8 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Thu, 24 Feb 2011 17:06:12 +0000 Subject: [PATCH] changed: removed Languages::Land enum now we set the languages in the config file: option locale_files, sample: locale_files = ( en, pl ) it represents the name of locale files (those from locale_dir directory) renamed config option: locale to locale_default git-svn-id: svn://ttmath.org/publicrep/winix/trunk@722 e52654a7-88a9-db11-a3e9-0013d4bc506e --- core/config.cpp | 40 +++++++- core/config.h | 19 +++- notify/notify.cpp | 4 +- notify/notifypool.h | 2 +- notify/notifythread.cpp | 9 +- notify/notifythread.h | 2 +- templates/Makefile.dep | 1 + templates/indexpatterns.cpp | 16 ++-- templates/indexpatterns.h | 2 +- templates/locale.cpp | 184 +++++++++++++++++++++--------------- templates/locale.h | 87 ++++++++++------- templates/localefilter.cpp | 2 +- templates/localefilter.h | 4 +- templates/misc.cpp | 18 ---- templates/misc.h | 3 +- templates/templates.cpp | 41 +++++--- templates/templates.h | 3 +- templates/winix.cpp | 10 +- 18 files changed, 268 insertions(+), 179 deletions(-) diff --git a/core/config.cpp b/core/config.cpp index 6a5c0de..4b2c33c 100755 --- a/core/config.cpp +++ b/core/config.cpp @@ -2,7 +2,7 @@ * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2008-2010, Tomasz Sowa + * Copyright (c) 2008-2011, Tomasz Sowa * All rights reserved. * */ @@ -164,9 +164,10 @@ void Config::AssignValues(bool stdout_is_closed) html_filter_orphans_lang_str = AText(L"html_filter_orphans_lang", L"pl"); html_filter_orphans_mode_str = AText(L"html_filter_orphans_mode_str", L"nbsp"); - locale_str = Text(L"locale", L"en"); locale_dir = Text(L"locale_dir"); locale_dir_default = Text(L"locale_dir_default"); + locale_default = Text(L"locale_default"); + ListText(L"locale_files", locale_files); title_separator = Text(L"title_separator", L" / "); @@ -179,7 +180,7 @@ void Config::AssignValues(bool stdout_is_closed) plugins_dir = Text(L"plugins_dir", L"/usr/local/winix/plugins"); NoLastSlash(plugins_dir); - parser.ListText(L"plugins", plugin_file); + ListText(L"plugins", plugin_file); time_zone_offset = Int(L"time_zone_offset", 0); time_zone_offset_guest = Int(L"time_zone_offset_guest", 0); @@ -191,6 +192,9 @@ void Config::AssignValues(bool stdout_is_closed) } + + + void Config::SetAdditionalVariables() { SetHttpHost(base_url, base_url_http_host); @@ -210,10 +214,40 @@ void Config::SetAdditionalVariables() html_filter_orphans_mode = HTMLFilter::orphan_160space; else html_filter_orphans_mode = HTMLFilter::orphan_nbsp; + + CheckLocale(); } +void Config::CheckLocale() +{ +bool found = false; + + if( locale_files.empty() ) + locale_files.push_back(L"en"); + + if( locale_default.empty() ) + locale_default = locale_files[0]; + + for(size_t i=0 ; i locale_files; + + // default locale + // default: the first item from locale_files + std::wstring locale_default; + + // default locale - index to locale_files + // not available in config -- set automatically based on locale_default + size_t locale_default_index; + // the main address of the server (e.g. someserver.com) (without the 'www' part etc) std::wstring base_server; @@ -337,6 +345,7 @@ private: void AssignValues(bool stdout_is_closed); void SetHttpHost(const std::wstring & in, std::wstring & out); void SetAdditionalVariables(); + void CheckLocale(); ConfParser parser; diff --git a/notify/notify.cpp b/notify/notify.cpp index 7b505ec..56de037 100755 --- a/notify/notify.cpp +++ b/notify/notify.cpp @@ -79,7 +79,7 @@ void Notify::ReadTemplates() return; } - patterns.resize(static_cast(Locale::lang_unknown)); + patterns.resize(TemplatesFunctions::locale.Size()); for(size_t i=0 ; itxt_templates_dir, config->txt_templates_dir_default); patterns[i][a].ParseFile(templates_names[a]); - TemplatesFunctions::locale_filter.Filter(patterns[i][a], TemplatesFunctions::locale, static_cast(i)); + TemplatesFunctions::locale_filter.Filter(patterns[i][a], TemplatesFunctions::locale, i); } } diff --git a/notify/notifypool.h b/notify/notifypool.h index 74f25b6..38e28b6 100755 --- a/notify/notifypool.h +++ b/notify/notifypool.h @@ -50,7 +50,7 @@ struct NotifyUserMsg { std::wstring name; std::wstring email; - Locale::Lang lang; + size_t lang; }; diff --git a/notify/notifythread.cpp b/notify/notifythread.cpp index 81bc990..4e9b082 100755 --- a/notify/notifythread.cpp +++ b/notify/notifythread.cpp @@ -2,7 +2,7 @@ * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2008-2010, Tomasz Sowa + * Copyright (c) 2008-2011, Tomasz Sowa * All rights reserved. * */ @@ -100,10 +100,7 @@ bool res = false; { msg.name = i->name; msg.email = i->email; - msg.lang = Locale::StrToLang(config->locale_str); // !! bedzie osobno dla kazdego uzytkownika - - if( msg.lang == Locale::lang_unknown ) - msg.lang = Locale::lang_en; + msg.lang = config->locale_default_index; // !! bedzie osobno dla kazdego uzytkownika notify_user.insert(notify_user.end(), msg); res = true; @@ -163,7 +160,7 @@ void NotifyThread::SendMail() { notify_stream.Clear(); - size_t lang_index = static_cast(TemplatesNotifyFunctions::notify_user_msg.lang); + size_t lang_index = TemplatesNotifyFunctions::notify_user_msg.lang; size_t template_index = TemplatesNotifyFunctions::notify_msg.template_index; if( lang_index >= patterns.size() ) diff --git a/notify/notifythread.h b/notify/notifythread.h index 778d49b..8df3021 100755 --- a/notify/notifythread.h +++ b/notify/notifythread.h @@ -2,7 +2,7 @@ * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2008-2010, Tomasz Sowa + * Copyright (c) 2008-2011, Tomasz Sowa * All rights reserved. * */ diff --git a/templates/Makefile.dep b/templates/Makefile.dep index e8c46c2..1e9da8e 100755 --- a/templates/Makefile.dep +++ b/templates/Makefile.dep @@ -175,6 +175,7 @@ last.o: ../core/basethread.h ../core/sessionmanager.h last.o: ../core/sessioncontainer.h ../core/system.h ../core/lastcontainer.h last.o: ../core/request.h ../core/misc.h locale.o: locale.h ../core/confparser.h ../core/log.h ../core/textstream.h +locale.o: ../../ezc/src/utf8.h localefilter.o: localefilter.h locale.h ../core/confparser.h localefilter.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h localefilter.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h diff --git a/templates/indexpatterns.cpp b/templates/indexpatterns.cpp index 88ee0cf..9536182 100755 --- a/templates/indexpatterns.cpp +++ b/templates/indexpatterns.cpp @@ -23,27 +23,27 @@ void IndexPatterns::SetConfig(Config * pconfig) config = pconfig; } + void IndexPatterns::SetEzcFunctions(TemplatesFunctions::EzcFun * fun) { ezc_fun = fun; } -Ezc::Pattern * IndexPatterns::GetPattern(const std::wstring & file, Locale::Lang lang) + +Ezc::Pattern * IndexPatterns::GetPattern(const std::wstring & file, size_t lang) { Tab::iterator i = tab.find(file); if( i == tab.end() ) return 0; - size_t index = static_cast(lang); - - if( index >= i->second.patterns.size() ) + if( lang >= i->second.patterns.size() ) { - log << log1 << "IndexPatterns: there is no a pattern: " << file << ", for lang: " << index << logend; + log << log1 << "IndexPatterns: there is no a pattern: " << file << ", for lang: " << lang << logend; return 0; } -return &i->second.patterns[index]; +return &i->second.patterns[lang]; } @@ -81,7 +81,7 @@ void IndexPatterns::AddFileName(const std::wstring & file) void IndexPatterns::ReadPattern(Tab::iterator & iter, Locale & locale, LocaleFilter & locale_filter, bool delete_white) { size_t i; - size_t len = Locale::lang_unknown; + size_t len = locale.Size(); Template & templ = iter->second; templ.patterns.resize(len); @@ -96,7 +96,7 @@ void IndexPatterns::ReadPattern(Tab::iterator & iter, Locale & locale, LocaleFil if( ezc_fun ) templ.patterns[i].CacheFunctions(*ezc_fun); - locale_filter.Filter(templ.patterns[i], locale, static_cast(i)); + locale_filter.Filter(templ.patterns[i], locale, i); } } diff --git a/templates/indexpatterns.h b/templates/indexpatterns.h index 008435b..bd406ed 100755 --- a/templates/indexpatterns.h +++ b/templates/indexpatterns.h @@ -30,7 +30,7 @@ public: void SetEzcFunctions(TemplatesFunctions::EzcFun * fun); // can return null pointer if there is not such a pattern - Ezc::Pattern * GetPattern(const std::wstring & file, Locale::Lang lang); + Ezc::Pattern * GetPattern(const std::wstring & file, size_t lang); void AddPattern(const std::wstring & file, Locale & locale, LocaleFilter & locale_filter, bool delete_white); void AddPatternIfNotExists(const std::wstring & file, Locale & locale, LocaleFilter & locale_filter, bool delete_white); diff --git a/templates/locale.cpp b/templates/locale.cpp index c6458fc..e33477a 100755 --- a/templates/locale.cpp +++ b/templates/locale.cpp @@ -2,42 +2,46 @@ * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2010, Tomasz Sowa + * Copyright (c) 2010-2011, Tomasz Sowa * All rights reserved. * */ #include "locale.h" #include "core/log.h" +#include "utf8.h" + Locale::Locale() { - loc_tab.resize(lang_unknown); - default_lang = lang_en; - current_lang = lang_en; + locale_files.push_back(L"en"); + loc_tab.resize(locale_files.size()); + + default_lang = 0; + current_lang = 0; input_as_utf8 = false; } - -void Locale::AddLocale(Lang lang) +void Locale::SetLocaleFiles(const std::vector & files) { - ConfParser::TableSingle::iterator i = loc_parser.table_single.begin(); + locale_files = files; - for( ; i != loc_parser.table_single.end() ; ++i) - loc_tab[lang][i->first] = i->second; + if( locale_files.empty() ) + locale_files.push_back(L"en"); + + loc_tab.resize(locale_files.size()); } -void Locale::ReadFile(const char * dir, const char * dir_def, Lang lang, const char * file) + + +void Locale::ReadFile(const char * dir, const char * dir_def, size_t lang, const char * file) { - if( static_cast(lang) >= loc_tab.size() ) - { - // ops, something wrong + if( lang >= loc_tab.size() ) return; - } loc_tab[lang].clear(); bool read = false; @@ -53,13 +57,13 @@ void Locale::ReadFile(const char * dir, const char * dir_def, Lang lang, const c } -bool Locale::ReadFile(const char * dir, Lang lang, const char * file) +bool Locale::ReadFile(const char * dir, size_t lang, const char * file) { bool read = false; file_name = dir; file_name += '/'; - file_name += file; + file_name += file; // !! dodac sprawdzenie poprawnosci nazwy pliku (czy nie zawiera specjalnych znakow) loc_parser.SplitSingle(true); loc_parser.UTF8(input_as_utf8); @@ -75,6 +79,16 @@ return read; } + +void Locale::AddLocale(size_t lang) +{ + ConfParser::TableSingle::iterator i = loc_parser.table_single.begin(); + + for( ; i != loc_parser.table_single.end() ; ++i) + loc_tab[lang][i->first] = i->second; +} + + void Locale::ReadSubstTable(const char * dir, const char * dir_def) { bool read = false; @@ -119,8 +133,11 @@ return read; void Locale::Read(const char * dir, const char * dir_def) { - ReadFile(dir, dir_def, lang_pl, "pl"); - ReadFile(dir, dir_def, lang_en, "en"); + for(size_t i=0 ; i= loc_tab.size() ) + current_lang = loc_tab.size() - 1; } -Locale::Lang Locale::GetLang() +size_t Locale::GetLang() const { return current_lang; } -void Locale::SetLangDef(Lang lang) +void Locale::SetLangDef(size_t lang) { - default_lang = lang_en; + default_lang = lang; + + if( default_lang >= loc_tab.size() ) + default_lang = loc_tab.size() - 1; } +size_t Locale::GetLangDef() const +{ + return default_lang; +} + + +bool Locale::IsKey(const wchar_t * key) +{ + key_str = key; + return IsKey(key_str); +} + + +bool Locale::IsKey(const wchar_t * key, size_t lang) +{ + key_str = key; + return IsKey(key_str, lang); +} + + bool Locale::IsKey(const std::wstring & key) const { @@ -185,15 +231,12 @@ bool Locale::IsKey(const std::wstring & key) const } -bool Locale::IsKey(const std::wstring & key, Lang lang) const +bool Locale::IsKey(const std::wstring & key, size_t lang) const { - if( static_cast(lang) >= loc_tab.size() ) - { - // ops, something wrong + if( lang >= loc_tab.size() ) return false; - } - // looking in the lang language + // looking in the 'lang' language ConfParser::TableSingle::const_iterator i = loc_tab[lang].find(key); if( i != loc_tab[lang].end() ) @@ -203,11 +246,8 @@ bool Locale::IsKey(const std::wstring & key, Lang lang) const return false; - if( static_cast(default_lang) >= loc_tab.size() ) - { - // ops, something wrong + if( default_lang >= loc_tab.size() ) return false; - } // looking in a default language i = loc_tab[default_lang].find(key); @@ -220,6 +260,21 @@ bool Locale::IsKey(const std::wstring & key, Lang lang) const } +const std::wstring & Locale::Get(const wchar_t * key) +{ + key_str = key; + return Get(key_str); +} + + +const std::wstring & Locale::Get(const wchar_t * key, size_t lang) +{ + key_str = key; + return Get(key_str, lang); +} + + + const std::wstring & Locale::Get(const std::wstring & key) const { return Get(key, current_lang); @@ -227,15 +282,12 @@ const std::wstring & Locale::Get(const std::wstring & key) const -const std::wstring & Locale::Get(const std::wstring & key, Lang lang) const +const std::wstring & Locale::Get(const std::wstring & key, size_t lang) const { - if( static_cast(lang) >= loc_tab.size() ) - { - // ops, something wrong + if( lang >= loc_tab.size() ) return empty; - } - // looking in the lang language + // looking in the 'lang' language ConfParser::TableSingle::const_iterator i = loc_tab[lang].find(key); if( i != loc_tab[lang].end() ) @@ -245,11 +297,8 @@ const std::wstring & Locale::Get(const std::wstring & key, Lang lang) const return empty; - if( static_cast(default_lang) >= loc_tab.size() ) - { - // ops, something wrong + if( default_lang >= loc_tab.size() ) return empty; - } // looking in a default language i = loc_tab[default_lang].find(key); @@ -262,44 +311,29 @@ const std::wstring & Locale::Get(const std::wstring & key, Lang lang) const } -Locale::Lang Locale::StrToLang(const std::wstring & str) +size_t Locale::FileNameToLang(const std::wstring & str) const { - if( str == L"en" ) - return lang_en; - else - if( str == L"pl" ) - return lang_pl; - -return lang_unknown; -} - - - -const wchar_t * Locale::LangToStr(Lang lang) -{ -static wchar_t buffer[30]; -size_t buffer_len = sizeof(buffer) / sizeof(wchar_t); - - switch(lang) + for(size_t i=0 ; i=locale_files.size() ) + return empty; + +return locale_files[lang]; +} + + size_t Locale::Size() { return loc_tab.size(); diff --git a/templates/locale.h b/templates/locale.h index 4cfca0b..6ffea9b 100755 --- a/templates/locale.h +++ b/templates/locale.h @@ -2,7 +2,7 @@ * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2010, Tomasz Sowa + * Copyright (c) 2010-2011, Tomasz Sowa * All rights reserved. * */ @@ -20,56 +20,77 @@ 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); + // locale files + // those files will be reading from directories specified in Read() method + // default one item: en + void SetLocaleFiles(const std::vector & files); - void Read(const wchar_t * dir, const wchar_t * dir_def = 0); - void Read(const std::wstring & dir, const std::wstring & dir_def); + // reading locales + // you should call SetLocaleFiles() beforehand + 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); + // checking whether there is a 'key' in the current language (or in 'lang' language) + bool IsKey(const wchar_t * key); + bool IsKey(const wchar_t * key, size_t lang); 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; + bool IsKey(const std::wstring & key, size_t lang) const; - // default is english - void SetLang(Lang lang); - Lang GetLang(); + // returning specific 'key' + const std::wstring & Get(const wchar_t * key); + const std::wstring & Get(const wchar_t * key, size_t lang); + const std::wstring & Get(const std::wstring & key) const; + const std::wstring & Get(const std::wstring & key, size_t lang) const; + + // setting/getting current language + // default: 0 + void SetLang(size_t lang); + size_t GetLang() const; // which language is used instead if there is no a key in an other language - // default: lang_en - void SetLangDef(Lang lang); + // default: 0 + void SetLangDef(size_t lang); + size_t GetLangDef() const; + // return an index of a language file's name + // those set by SetLocaleFiles() + // or 0 if there is no such a file name + size_t FileNameToLang(const std::wstring & str) const; - static Lang StrToLang(const std::wstring & str); - static const wchar_t * LangToStr(Lang lang); + // return a file name for the 'lang' + const std::wstring & LangToFileName(size_t lang) const; + // returning how many locale files (languages) there are size_t Size(); + + // it sets whether we should parse locale files as utf-8 files + // default: false void UTF8(bool utf); + // substitution characters + // !! w przyszlosci bedzie zmiana nazw tych metod i bedzie ich wiecej + // !! bedzie zmiana do url, do wielkosci liter (male/duze) i moze inne 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 AddLocale(size_t lang); + void ReadFile(const char * dir, const char * dir_def, size_t lang, const char * file); + bool ReadFile(const char * dir, size_t lang, const char * file); void ReadSubstTable(const char * dir, const char * dir_def); bool ReadSubstTable(const char * dir); - // messages vector + // locale files + // we have at least one item "en" + std::vector locale_files; + + // messages vector + // this table has the same size as locale_files (at least one item) std::vector loc_tab; // these tables are used to change url characters @@ -78,11 +99,13 @@ private: ConfParser loc_parser; + std::string locale_filea; std::string file_name; - std::wstring empty; + std::wstring key_str; + const std::wstring empty; // used when returning a non existing key from loc_tab (or in LangToFileName) std::string adir1, adir2; - Lang default_lang; - Lang current_lang; + size_t default_lang; // index to loc_tab + size_t current_lang; // index to loc_tab bool input_as_utf8; }; diff --git a/templates/localefilter.cpp b/templates/localefilter.cpp index b3a4cfc..6bab240 100755 --- a/templates/localefilter.cpp +++ b/templates/localefilter.cpp @@ -110,7 +110,7 @@ void LocaleFilter::FilterText(Ezc::Item & item) -void LocaleFilter::Filter(Ezc::Pattern & pattern, const Locale & locale, Locale::Lang lang_) +void LocaleFilter::Filter(Ezc::Pattern & pattern, const Locale & locale, size_t lang_) { plocale = &locale; lang = lang_; diff --git a/templates/localefilter.h b/templates/localefilter.h index 8857c02..962b5d9 100755 --- a/templates/localefilter.h +++ b/templates/localefilter.h @@ -21,7 +21,7 @@ class LocaleFilter public: LocaleFilter(); - void Filter(Ezc::Pattern & pattern, const Locale & locale, Locale::Lang lang_); + void Filter(Ezc::Pattern & pattern, const Locale & locale, size_t lang_); private: void ReadKey(); @@ -33,7 +33,7 @@ private: wchar_t closing_mark; // default '}' const Locale * plocale; - Locale::Lang lang; + size_t lang; std::wstring res; std::wstring key; std::wstring value; diff --git a/templates/misc.cpp b/templates/misc.cpp index 77e8793..505b6f2 100755 --- a/templates/misc.cpp +++ b/templates/misc.cpp @@ -172,24 +172,6 @@ return ckeditor_getparser.fun_num; -// those functions from here are used in the second thread too - - -void ClearPatterns(Patterns & patterns, size_t len) -{ -size_t loc, pat; - - patterns.resize(Locale::lang_unknown); - - for(loc=0 ; loc < static_cast(Locale::lang_unknown) ; ++loc) - { - patterns[loc].resize(len); - - for(pat=0 ; pat(i)); + locale_filter.Filter(patterns[i][pat], locale, i); } } } -void ClearPatterns(Patterns & patterns, size_t len); diff --git a/templates/templates.cpp b/templates/templates.cpp index 047723d..3dab55e 100755 --- a/templates/templates.cpp +++ b/templates/templates.cpp @@ -2,7 +2,7 @@ * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2008-2010, Tomasz Sowa + * Copyright (c) 2008-2011, Tomasz Sowa * All rights reserved. * */ @@ -54,7 +54,7 @@ Ezc::Pattern * content_for_function() return 0; } - const size_t loc_index = static_cast(locale.GetLang()); + const size_t loc_index = locale.GetLang(); const size_t fun_id = static_cast(cur->request->function->id); if( loc_index >= patterns_fun.size() || fun_id >= patterns_fun[loc_index].size() ) @@ -72,7 +72,7 @@ void content(Info & i) { Ezc::Pattern * p = 0; - if( static_cast(locale.GetLang()) >= patterns.size() ) + if( locale.GetLang() >= patterns.size() ) { log << log1 << "Templates: there is no such a language in patterns" << logend; return; @@ -464,14 +464,11 @@ void Templates::SetLocale() { using namespace TemplatesFunctions; - Locale::Lang lang = Locale::StrToLang(config->locale_str); - - if( lang != Locale::lang_unknown ) - locale.SetLang(lang); - else - locale.SetLang(Locale::lang_en); - locale.UTF8(config->utf8); + locale.SetLocaleFiles(config->locale_files); + // !! tutaj nie potrzeba ustawiac locali SetLang/SetLangDef (nie odczytujemy kluczy) + locale.SetLang(config->locale_default_index); // !! w przyszlosci locale beda ustawiane dla kazdego uzytkownika osobno + locale.SetLangDef(config->locale_default_index); locale.Read(config->locale_dir, config->locale_dir_default); } @@ -575,13 +572,31 @@ using namespace TemplatesFunctions; } + +void Templates::ClearPatterns(TemplatesFunctions::Patterns & patterns, size_t len) +{ +using namespace TemplatesFunctions; +size_t loc, pat; + + patterns.resize(locale.Size()); + + for(loc=0 ; loc < patterns.size() ; ++loc) + { + patterns[loc].resize(len); + + for(pat=0 ; patFunctionsSize()); + ClearPatterns(patterns, pat_last); + ClearPatterns(patterns_fun, functions->FunctionsSize()); } @@ -590,7 +605,7 @@ void Templates::Generate() using namespace TemplatesFunctions; // !! locale beda w zaleznosci od uzytkownika - if( static_cast(locale.GetLang()) >= patterns.size() ) + if( locale.GetLang() >= patterns.size() ) return; Ezc::Pattern * index = 0; diff --git a/templates/templates.h b/templates/templates.h index e62add4..ce3c3ba 100755 --- a/templates/templates.h +++ b/templates/templates.h @@ -2,7 +2,7 @@ * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2008-2010, Tomasz Sowa + * Copyright (c) 2008-2011, Tomasz Sowa * All rights reserved. * */ @@ -397,6 +397,7 @@ private: void ReadFileFun(size_t index, const wchar_t * file); void ReadFunctionsTemplates(); void SetLocale(); + void ClearPatterns(TemplatesFunctions::Patterns & patterns, size_t len); TemplatesFunctions::EzcGen generator; std::wstring temp; diff --git a/templates/winix.cpp b/templates/winix.cpp index f99729f..a6837ab 100755 --- a/templates/winix.cpp +++ b/templates/winix.cpp @@ -181,8 +181,6 @@ void winix_err_code(Info & i) -static std::wstring winix_error_key; - void winix_is_err_in_locales(Info & i) { @@ -190,9 +188,7 @@ wchar_t buff[40]; size_t buff_len = sizeof(buff) / sizeof(wchar_t); swprintf(buff, buff_len, L"winix_err_%d", cur->request->status); - winix_error_key = buff; - - i.res = locale.IsKey(winix_error_key); + i.res = locale.IsKey(buff); } @@ -202,9 +198,7 @@ wchar_t buff[40]; size_t buff_len = sizeof(buff) / sizeof(wchar_t); swprintf(buff, buff_len, L"winix_err_%d", cur->request->status); - winix_error_key = buff; - - i.out << locale.Get(winix_error_key); + i.out << locale.Get(buff); }