Show using wxNumberFormatter in the internat sample too

This shows that C and UI (or OS) locales can be different.
This commit is contained in:
Vadim Zeitlin
2021-08-06 00:47:15 +02:00
parent 1f74e7cd1b
commit 7dc6462561

View File

@@ -33,6 +33,7 @@
#include "wx/file.h" #include "wx/file.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/cmdline.h" #include "wx/cmdline.h"
#include "wx/numformatter.h"
#include "wx/platinfo.h" #include "wx/platinfo.h"
#include "wx/spinctrl.h" #include "wx/spinctrl.h"
@@ -392,7 +393,23 @@ MyFrame::MyFrame(wxLocale& locale)
topSizer->Add(new wxCalendarCtrl(this, wxID_ANY), topSizer->Add(new wxCalendarCtrl(this, wxID_ANY),
wxSizerFlags().Center().Border()); wxSizerFlags().Center().Border());
SetSizer(topSizer); // show the difference between wxString::Format() and wxNumberFormatter:
// the former uses the current C locale, while the latter uses the UI
// locale
topSizer->Add(new wxStaticText
(
this,
wxID_ANY,
wxString::Format
(
_("Number in UI locale: %s; in C locale: %.2f"),
wxNumberFormatter::ToString(5.67, 2),
5.67
)
),
wxSizerFlags().Center().Border());
SetSizerAndFit(topSizer);
} }
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) ) void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )