+void MyFrame::OnTestLocaleAvail(wxCommandEvent& WXUNUSED(event))
+{
+ static wxString s_locale;
+ wxString locale = wxGetTextFromUser
+ (
+ _("Enter the locale to test"),
+ wxGetTextFromUserPromptStr,
+ s_locale,
+ this
+ );
+ if ( locale.empty() )
+ return;
+
+ s_locale = locale;
+ const wxLanguageInfo * const info = wxLocale::FindLanguageInfo(s_locale);
+ if ( !info )
+ {
+ wxLogError(_("Locale \"%s\" is unknown."), s_locale.c_str());
+ return;
+ }
+
+ if ( wxLocale::IsAvailable(info->Language) )
+ {
+ wxLogMessage(_("Locale \"%s\" is available."), s_locale.c_str());
+ }
+ else
+ {
+ wxLogWarning(_("Locale \"%s\" is not available."), s_locale.c_str());
+ }
+}
+
+void MyFrame::OnOpen(wxCommandEvent& WXUNUSED(event))
+{
+ // open a bogus file -- the error message should be also translated if
+ // you've got wxstd.mo somewhere in the search path (see MyApp::OnInit)
+ wxFile file("NOTEXIST.ING");
+}
+
+void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event))
+{
+ const wxString& title = _("Testing _() (gettext)");
+
+ // NOTE: using the wxTRANSLATE() macro here we won't show a localized
+ // string in the text entry dialog; we'll simply show the un-translated
+ // string; however if the user press "ok" without altering the text,
+ // since the "default value" string has been extracted by xgettext
+ // the wxGetTranslation call later will manage to return a localized
+ // string
+ wxTextEntryDialog d(this, _("Please enter text to translate"),
+ title, wxTRANSLATE("default value"));
+
+ if (d.ShowModal() == wxID_OK)
+ {
+ wxString v = d.GetValue();
+ wxString s(title);
+ s << "\n" << v << " -> "
+ << wxGetTranslation(v.c_str()) << "\n";
+ wxMessageBox(s);
+ }
+}
+
+void MyFrame::OnTest2(wxCommandEvent& WXUNUSED(event))
+{
+ const wxString& title = _("Testing _N() (ngettext)");
+ wxTextEntryDialog d(this,
+ _("Please enter range for plural forms of \"n files deleted\" phrase"),
+ title, "0-10");
+
+ if (d.ShowModal() == wxID_OK)
+ {
+ int first, last;
+ wxSscanf(d.GetValue(), "%d-%d", &first, &last);
+ wxString s(title);
+ s << "\n";
+ for (int n = first; n <= last; ++n)
+ {
+ s << n << " " <<
+ wxPLURAL("file deleted", "files deleted", n) <<
+ "\n";
+ }
+ wxMessageBox(s);
+ }
+}
+
+void MyFrame::OnTest3(wxCommandEvent& WXUNUSED(event))
+{
+ const char* lines[] =
+ {
+ wxTRANSLATE("line 1"),
+ wxTRANSLATE("line 2"),
+ wxTRANSLATE("line 3"),
+ };
+
+ wxString s(_("Testing wxTRANSLATE() (gettext_noop)"));
+ s << "\n";
+ for (size_t i = 0; i < WXSIZEOF(lines); ++i)
+ {
+ s << lines[i] << " -> " << wxGetTranslation(lines[i]) << "\n";
+ }
+ wxMessageBox(s);
+}
+
+void MyFrame::OnTestMsgBox(wxCommandEvent& WXUNUSED(event))