Add initial locale support

This commit is contained in:
2010-07-04 19:39:39 +02:00
parent d29afc619e
commit dfe81f2b03
10 changed files with 873 additions and 7 deletions

View File

@@ -5,7 +5,7 @@ enum {ACCOUNT_NUMBER, ACCOUNT_NAME, ACCOUNT_INIT, ACCOUNT_CUR, ACCOUNT_FINAL, NU
enum {CUR_CREDIT, CUR_DEBIT, TOTAL_CREDIT, TOTAL_DEBIT, REMAINS, STATS_ROW, CATS_STATS};
enum {CALENDAR_TREE_ID=1, OPS_GRID_ID, CALENDAR_ID, ACCOUNTS_GRID_ID, MENU_GENERATE_ID, MENU_DELETE_ID};
static wxString colsName[] = {_("Description"), _("Date"), _("Debit"), _("Credit"), _("Category"), _("Account"), _(""), _("")};
static wxString colsName[] = {_("Description"), _("Date"), _("Debit"), _("Credit"), _("Category"), _("Account"), wxT(""), wxT("")};
BEGIN_EVENT_TABLE(AccountPanel, wxPanel)
EVT_GRID_CMD_CELL_CHANGE(OPS_GRID_ID, AccountPanel::OnOperationModified)

View File

@@ -1,10 +1,10 @@
#include "wxUI.h"
wxString months[12] = {_("january"), _("february"), _("march"), _("april"), _("may"), _("june"), _("july"), _("august"), _("september"), _("october"), _("november"), _("december")} ;
wxString months[12] ;
wxUI::wxUI(KissCount* kiss, const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(NULL, -1, title, pos, size), _kiss(kiss), _accountPanel(NULL), _preferencesPanel(NULL), _curPanel(NULL),
_needReload(false)
_locale(NULL), _needReload(false)
{
_hbox = new wxBoxSizer(wxVERTICAL);
ButtonPanel* buttons = new ButtonPanel(_kiss, this);
@@ -22,6 +22,19 @@ wxUI::wxUI(KissCount* kiss, const wxString& title, const wxPoint& pos, const wxS
// CreateStatusBar();
// SetStatusText( wxT("Welcome to wxWidgets!") );
months[0] = _("january");
months[1] = _("february");
months[2] = _("march");
months[3] = _("april");
months[4] = _("may");
months[5] = _("june");
months[6] = _("july");
months[7] = _("august");
months[8] = _("september");
months[9] = _("october");
months[10] = _("november");
months[11] = _("december") ;
SetSizer(_hbox);
_hbox->Add(buttons);
@@ -31,6 +44,35 @@ wxUI::~wxUI()
{
if (_accountPanel) delete _accountPanel;
if (_preferencesPanel) delete _preferencesPanel;
if (_locale) delete _locale;
}
bool wxUI::InitLanguage(long language)
{
if (_locale) delete _locale;
// load language if possible, fall back to english otherwise
if(wxLocale::IsAvailable(language))
{
_locale = new wxLocale( language, wxLOCALE_CONV_ENCODING );
#ifdef __WXGTK__
_locale->AddCatalogLookupPathPrefix(wxT("./ressources/po"));
#endif
_locale->AddCatalog(wxT("french"));
_locale->AddCatalog(wxT("kisscount"));
}
if ((_locale == NULL || !_locale->IsOk()) && wxLocale::IsAvailable(wxLANGUAGE_ENGLISH))
{
if (_locale) delete _locale;
_locale = new wxLocale( wxLANGUAGE_ENGLISH );
language = wxLANGUAGE_ENGLISH;
return false;
}
return true;
}
void wxUI::ShowAccount()

View File

@@ -22,8 +22,7 @@ class wxUI: public wxFrame
wxUI(KissCount* kiss, const wxString& title, const wxPoint& pos, const wxSize& size);
~wxUI();
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
bool InitLanguage(long language);
void ChangeUser();
void LoadUser();
@@ -42,7 +41,9 @@ class wxUI: public wxFrame
AccountPanel *_accountPanel;
PreferencesPanel *_preferencesPanel;
wxPanel *_curPanel;
wxLocale *_locale;
bool _needReload;
void ShowPanel(wxPanel* panel);
};