Display all available translations in options dialog

This commit is contained in:
Zane U. Ji 2012-08-03 20:09:59 +08:00
parent 2b826f1b59
commit 33b2e3c57c
2 changed files with 20 additions and 113 deletions

View File

@ -186,63 +186,24 @@ MyPropertySheet::MyPropertySheet (
generalPanel, generalPanel,
wxID_ANY ); wxID_ANY );
languageBox->Insert ( _T ( "Catalan" ), INDEX_CATALAN ); wxTranslations *t = wxTranslations::Get();
languageBox->Insert ( _T ( "Chinese Simplified" ), INDEX_CHINESE_SIMPLIFIED ); if ( t != NULL )
languageBox->Insert ( _T ( "Chinese Traditional" ), INDEX_CHINESE_TRADITIONAL );
languageBox->Insert ( _T ( "Dutch" ), INDEX_DUTCH );
languageBox->Insert ( _T ( "English (US)" ), INDEX_ENGLISH_US );
languageBox->Insert ( _T ( "French" ), INDEX_FRENCH );
languageBox->Insert ( _T ( "German" ), INDEX_GERMAN );
languageBox->Insert ( _T ( "Italian" ), INDEX_ITALIAN );
languageBox->Insert ( _T ( "Russian" ), INDEX_RUSSIAN );
languageBox->Insert ( _T ( "Slovak" ), INDEX_SLOVAK );
languageBox->Insert ( _T ( "Spanish" ), INDEX_SPANISH );
languageBox->Insert ( _T ( "Swedish" ), INDEX_SWEDISH );
languageBox->Insert ( _T ( "Ukrainian" ), INDEX_UKRAINIAN );
switch ( lang )
{ {
case wxLANGUAGE_CATALAN: int index;
languageBox->SetSelection ( INDEX_CATALAN ); const wxLanguageInfo *info;
break; wxArrayString langs = t->GetAvailableTranslations ( _T ( "messages" ) );
case wxLANGUAGE_GERMAN: for ( size_t i = 0; i < langs.Count(); i++ )
languageBox->SetSelection ( INDEX_GERMAN ); {
break; info = wxLocale::FindLanguageInfo ( langs[i] );
case wxLANGUAGE_DUTCH: if ( info == NULL ) continue;
languageBox->SetSelection ( INDEX_DUTCH );
break; index = languageBox->Append ( info->Description, (void*)info->Language );
case wxLANGUAGE_FRENCH: if (lang == info->Language)
languageBox->SetSelection ( INDEX_FRENCH ); languageBox->SetSelection ( index );
break; }
case wxLANGUAGE_ITALIAN:
languageBox->SetSelection ( INDEX_ITALIAN );
break;
case wxLANGUAGE_SLOVAK:
languageBox->SetSelection ( INDEX_SLOVAK );
break;
case wxLANGUAGE_SWEDISH:
languageBox->SetSelection ( INDEX_SWEDISH );
break;
case wxLANGUAGE_RUSSIAN:
languageBox->SetSelection ( INDEX_RUSSIAN );
break;
case wxLANGUAGE_CHINESE_SIMPLIFIED:
languageBox->SetSelection ( INDEX_CHINESE_SIMPLIFIED );
break;
case wxLANGUAGE_CHINESE_TRADITIONAL:
languageBox->SetSelection ( INDEX_CHINESE_TRADITIONAL );
break;
case wxLANGUAGE_UKRAINIAN:
languageBox->SetSelection ( INDEX_UKRAINIAN );
break;
case wxLANGUAGE_SPANISH:
languageBox->SetSelection ( INDEX_SPANISH );
break;
default:
languageBox->SetSelection ( INDEX_ENGLISH_US );
break;
} }
libxmlNetAccessBox = new wxCheckBox ( libxmlNetAccessBox = new wxCheckBox (
generalPanel, wxID_ANY, _ ( "&Enable network access for DTD validation" ) ); generalPanel, wxID_ANY, _ ( "&Enable network access for DTD validation" ) );
libxmlNetAccessBox->SetValue ( libxmlNetAccessParameter ); libxmlNetAccessBox->SetValue ( libxmlNetAccessParameter );
@ -343,48 +304,11 @@ void MyPropertySheet::OnOk ( wxCommandEvent& e )
showFullPathOnFrame = fullPathBox->GetValue(); showFullPathOnFrame = fullPathBox->GetValue();
int languageChoice = languageBox->GetSelection(); int languageChoice = languageBox->GetSelection();
switch ( languageChoice ) if ( languageChoice != wxNOT_FOUND )
{ lang = (int)languageBox->GetClientData(languageChoice);
case INDEX_CATALAN: else
lang = wxLANGUAGE_CATALAN; lang = wxLANGUAGE_ENGLISH_US;
break;
case INDEX_DUTCH:
lang = wxLANGUAGE_DUTCH;
break;
case INDEX_ITALIAN:
lang = wxLANGUAGE_ITALIAN;
break;
case INDEX_GERMAN:
lang = wxLANGUAGE_GERMAN;
break;
case INDEX_CHINESE_SIMPLIFIED:
lang = wxLANGUAGE_CHINESE_SIMPLIFIED;
break;
case INDEX_CHINESE_TRADITIONAL:
lang = wxLANGUAGE_CHINESE_TRADITIONAL;
break;
case INDEX_RUSSIAN:
lang = wxLANGUAGE_RUSSIAN;
break;
case INDEX_FRENCH:
lang = wxLANGUAGE_FRENCH;
break;
case INDEX_SLOVAK:
lang = wxLANGUAGE_SLOVAK;
break;
case INDEX_SPANISH:
lang = wxLANGUAGE_SPANISH;
break;
case INDEX_SWEDISH:
lang = wxLANGUAGE_SWEDISH;
break;
case INDEX_UKRAINIAN:
lang = wxLANGUAGE_UKRAINIAN;
break;
default:
lang = wxLANGUAGE_ENGLISH_US;
break;
}
e.Skip(); e.Skip();
} }

View File

@ -32,23 +32,6 @@ enum
FONT_BROWSE FONT_BROWSE
}; };
enum langIndex
{
INDEX_CATALAN = 0,
INDEX_CHINESE_SIMPLIFIED,
INDEX_CHINESE_TRADITIONAL,
INDEX_DUTCH,
INDEX_ENGLISH_US,
INDEX_FRENCH,
INDEX_GERMAN,
INDEX_ITALIAN,
INDEX_RUSSIAN,
INDEX_SLOVAK,
INDEX_SPANISH,
INDEX_SWEDISH,
INDEX_UKRAINIAN
};
class MyPropertySheet : public wxPropertySheetDialog class MyPropertySheet : public wxPropertySheetDialog
{ {
public: public: