String localization implemented (missing some strings)
This commit is contained in:
@@ -196,12 +196,11 @@ void PreferencesPanel::InitCategories(User* user)
|
||||
void PreferencesPanel::InitLanguage(User* user)
|
||||
{
|
||||
int i, select=0;
|
||||
wxLanguage pref = user->GetLanguage();
|
||||
|
||||
for (i=0; i<NB_SUPPORTED_LANGUAGES; i++)
|
||||
{
|
||||
_language->Append(languages[i].name, wxBitmap(languages[i].icon));
|
||||
if (languages[i].language == pref)
|
||||
if (languages[i].language == _wxUI->_language)
|
||||
select = i;
|
||||
}
|
||||
|
||||
@@ -478,7 +477,15 @@ void PreferencesPanel::OnChangePassword(wxCommandEvent& event)
|
||||
void PreferencesPanel::OnLanguageChange(wxCommandEvent& event)
|
||||
{
|
||||
wxLanguage language = languages[_language->GetSelection()].language;
|
||||
_wxUI->SetLanguage(language);
|
||||
if (_wxUI->SetLanguage(language) || language == wxLANGUAGE_ENGLISH)
|
||||
{
|
||||
_wxUI->NeedReload();
|
||||
_kiss->SetLanguage(language);
|
||||
wxMessageBox(_("Language successfully changed, please go to another panel"), _("KissCount"), wxICON_INFORMATION | wxOK);
|
||||
}
|
||||
else
|
||||
wxMessageBox(_("Language not changed"), _("KissCount"), wxICON_ERROR | wxOK);
|
||||
|
||||
}
|
||||
|
||||
void PreferencesPanel::OnShow(wxShowEvent& event)
|
||||
|
||||
7
src/view/SupportedLanguages.cpp
Normal file
7
src/view/SupportedLanguages.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "SupportedLanguages.h"
|
||||
|
||||
language languages[NB_SUPPORTED_LANGUAGES] = {
|
||||
{ wxT("English"), wxT(ICONS_PATH "/United Kingdom.png"), wxLANGUAGE_ENGLISH},
|
||||
{ wxT("Français"), wxT(ICONS_PATH "/France.png"), wxLANGUAGE_FRENCH}
|
||||
};
|
||||
|
||||
17
src/view/SupportedLanguages.h
Normal file
17
src/view/SupportedLanguages.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef SUPPORTEDLANGUAGES_H
|
||||
#define SUPPORTEDLANGUAGES_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
typedef struct {
|
||||
wxString name;
|
||||
wxString icon;
|
||||
wxLanguage language;
|
||||
} language ;
|
||||
|
||||
#define NB_SUPPORTED_LANGUAGES 2
|
||||
#define ICONS_PATH "./ressources/icons"
|
||||
|
||||
extern language languages[NB_SUPPORTED_LANGUAGES];
|
||||
|
||||
#endif
|
||||
@@ -22,19 +22,6 @@ 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);
|
||||
@@ -49,6 +36,8 @@ wxUI::~wxUI()
|
||||
|
||||
bool wxUI::SetLanguage(long language)
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
if (_locale) delete _locale;
|
||||
_locale = NULL;
|
||||
|
||||
@@ -63,16 +52,39 @@ bool wxUI::SetLanguage(long language)
|
||||
|
||||
_locale->AddCatalog(wxT("french"));
|
||||
_locale->AddCatalog(wxT("kisscount"));
|
||||
|
||||
_language = (wxLanguage) language;
|
||||
}
|
||||
|
||||
if ((_locale == NULL || !_locale->IsOk()) && wxLocale::IsAvailable(wxLANGUAGE_ENGLISH))
|
||||
if (_locale == NULL || !_locale->IsOk())
|
||||
{
|
||||
if (_locale) delete _locale;
|
||||
_locale = new wxLocale( wxLANGUAGE_ENGLISH );
|
||||
return false;
|
||||
_locale = new wxLocale();
|
||||
|
||||
#ifdef __WXGTK__
|
||||
_locale->AddCatalogLookupPathPrefix(wxT("./ressources/po"));
|
||||
#endif
|
||||
|
||||
_locale->AddCatalog(wxT("kisscount"));
|
||||
|
||||
_language = wxLANGUAGE_ENGLISH;
|
||||
res = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
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") ;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void wxUI::ShowAccount()
|
||||
@@ -93,6 +105,8 @@ void wxUI::ChangeUser()
|
||||
|
||||
void wxUI::LoadUser()
|
||||
{
|
||||
User* user = _kiss->GetUser();
|
||||
|
||||
if (_curPanel)
|
||||
{
|
||||
_hbox->Detach(_curPanel);
|
||||
@@ -105,6 +119,9 @@ void wxUI::LoadUser()
|
||||
if (_preferencesPanel)
|
||||
delete _preferencesPanel;
|
||||
|
||||
if (user->_preferences[wxT("language")] != wxT(""))
|
||||
SetLanguage(user->GetLanguage());
|
||||
|
||||
_preferencesPanel = new PreferencesPanel(_kiss, this);
|
||||
_accountPanel = new AccountPanel(_kiss, this);
|
||||
|
||||
@@ -113,7 +130,8 @@ void wxUI::LoadUser()
|
||||
|
||||
void wxUI::ShowPanel(wxPanel* panel)
|
||||
{
|
||||
int month, year;
|
||||
int month, year, account=0, preferences=0;
|
||||
wxShowEvent event;
|
||||
|
||||
if (!panel) return;
|
||||
|
||||
@@ -122,14 +140,40 @@ void wxUI::ShowPanel(wxPanel* panel)
|
||||
_hbox->Detach(_curPanel);
|
||||
_curPanel->Hide();
|
||||
}
|
||||
|
||||
if (panel == _accountPanel && _needReload)
|
||||
|
||||
if (_needReload)
|
||||
{
|
||||
month = _accountPanel->_curMonth;
|
||||
year = _accountPanel->_curYear;
|
||||
delete _accountPanel;
|
||||
panel = _accountPanel = new AccountPanel(_kiss, this);
|
||||
_accountPanel->ShowMonth(month, year);
|
||||
if (panel == _accountPanel)
|
||||
{
|
||||
account = 1;
|
||||
month = _accountPanel->_curMonth;
|
||||
year = _accountPanel->_curYear;
|
||||
}
|
||||
|
||||
if (panel == _preferencesPanel)
|
||||
{
|
||||
preferences = 1;
|
||||
}
|
||||
|
||||
delete _accountPanel;
|
||||
delete _preferencesPanel;
|
||||
|
||||
_accountPanel = new AccountPanel(_kiss, this);
|
||||
if (year != -1)
|
||||
_accountPanel->ShowMonth(month, year);
|
||||
_preferencesPanel = new PreferencesPanel(_kiss, this);
|
||||
|
||||
if (account)
|
||||
{
|
||||
_accountPanel->OnShow(event);
|
||||
panel = _accountPanel;
|
||||
}
|
||||
if (preferences)
|
||||
{
|
||||
_preferencesPanel->OnShow(event);
|
||||
panel = _preferencesPanel;
|
||||
}
|
||||
|
||||
_needReload = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,11 @@ class wxUI: public wxFrame
|
||||
|
||||
void KillMe();
|
||||
|
||||
void ShowPanel(wxPanel* panel);
|
||||
void NeedReload();
|
||||
|
||||
wxLanguage _language;
|
||||
|
||||
private:
|
||||
KissCount *_kiss;
|
||||
wxBoxSizer *_hbox;
|
||||
@@ -43,8 +46,6 @@ class wxUI: public wxFrame
|
||||
wxPanel *_curPanel;
|
||||
wxLocale *_locale;
|
||||
bool _needReload;
|
||||
|
||||
void ShowPanel(wxPanel* panel);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user