translate wxMessageDialog labels to the language of the current locale (closes #10962)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61319 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-07-05 11:48:01 +00:00
parent 60c4147a07
commit 42c097b83e
3 changed files with 50 additions and 2 deletions

View File

@@ -30,6 +30,7 @@
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/intl.h"
#include "wx/utils.h"
#include "wx/dialog.h"
#if wxUSE_MSGBOX_HOOK
@@ -445,6 +446,34 @@ int wxMessageDialog::ShowModal()
m_parent = GetParentForModalDialog();
HWND hWnd = m_parent ? GetHwndOf(m_parent) : NULL;
#if wxUSE_INTL
// native message box always uses the current user locale but the program
// may be using a different one and in this case we need to manually
// translate the button labels to avoid mismatch between the language of
// the message box text and its buttons
wxLocale * const loc = wxGetLocale();
if ( loc && loc->GetLanguage() != wxLocale::GetSystemLanguage() )
{
if ( m_dialogStyle & wxYES_NO )
{
// use the strings with mnemonics here as the native message box
// does
SetYesNoLabels(_("&Yes"), _("&No"));
}
// we may or not have the Ok/Cancel buttons but either we do have them
// or we already made the labels custom because we called
// SetYesNoLabels() above so doing this does no harm -- and is
// necessary in wxYES_NO | wxCANCEL case
//
// note that we don't use mnemonics here for consistency with the
// native message box (which probably doesn't use them because
// Enter/Esc keys can be already used to dismiss the message box
// using keyboard)
SetOKCancelLabels(_("OK"), _("Cancel"));
}
#endif // wxUSE_INTL
// translate wx style in MSW
unsigned int msStyle;
const long wxStyle = GetMessageDialogStyle();