Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
LangChoiceDialog Class Referencefinal

A dialog used (at start up) to present the user with a choice of languages for Audacity. More...

Inheritance diagram for LangChoiceDialog:
Collaboration diagram for LangChoiceDialog:

Public Member Functions

 LangChoiceDialog (wxWindow *parent, wxWindowID id, const TranslatableString &title)
wxString GetLang ()
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
void SetTitle (const TranslatableString &title)
void SetLabel (const TranslatableString &title)
void SetName (const TranslatableString &title)
void SetName ()
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete

Private Member Functions

void OnOk (wxCommandEvent &event)

Private Attributes

wxChoice * mChoice
wxString mLang
int mNumLangs
wxArrayString mLangCodes
TranslatableStrings mLangNames

Detailed Description

A dialog used (at start up) to present the user with a choice of languages for Audacity.

Definition at line 31 of file LangChoice.cpp.

Constructor & Destructor Documentation

◆ LangChoiceDialog()

LangChoiceDialog::LangChoiceDialog ( wxWindow *  parent,
wxWindowID  id,
const TranslatableString title 

Definition at line 70 of file LangChoice.cpp.

72 :
73 wxDialogWrapper(parent, id, title)
75 SetName();
76 const auto &paths = FileNames::AudacityPathList();
79 .index( Languages::GetSystemLanguageCode(paths) );
83 S.StartVerticalLay(false);
84 {
85 S.StartHorizontalLay();
86 {
87 S.SetBorder(15);
88 mChoice = S.AddChoice(XXO("Choose Language for Audacity to use:"),
90 lang);
91 }
92 S.EndVerticalLay();
94 S.SetBorder(0);
95 S.AddStandardButtons(eOkButton);
96 }
97 S.EndVerticalLay();
99 Fit();
XXO("&Cut/Copy/Paste Toolbar")
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:431
static const auto title
@ eIsCreating
Definition: ShuttleGui.h:39
@ eOkButton
Definition: ShuttleGui.h:597
#define S(N)
Definition: ToChars.cpp:64
TranslatableStrings mLangNames
Definition: LangChoice.cpp:47
wxArrayString mLangCodes
Definition: LangChoice.cpp:46
wxChoice * mChoice
Definition: LangChoice.cpp:42
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
FILES_API const FilePaths & AudacityPathList()
A list of directories that should be searched for Audacity files (plug-ins, help files,...
wxString GetSystemLanguageCode(const FilePaths &pathList)
Definition: Languages.cpp:83
void GetLanguages(FilePaths pathList, wxArrayString &langCodes, TranslatableStrings &langNames)
Definition: Languages.cpp:140

References FileNames::AudacityPathList(), eIsCreating, eOkButton, Languages::GetLanguages(), Languages::GetSystemLanguageCode(), make_iterator_range(), S, and XXO().

Here is the call graph for this function:

Member Function Documentation

◆ GetLang()

wxString LangChoiceDialog::GetLang ( )

Definition at line 37 of file LangChoice.cpp.

37{ return mLang; }

References mLang.

Referenced by ChooseLanguage().

Here is the caller graph for this function:

◆ OnOk()

void LangChoiceDialog::OnOk ( wxCommandEvent &  event)

Definition at line 102 of file LangChoice.cpp.

104 int ndx = mChoice->GetSelection();
105 mLang = mLangCodes[ndx];
107 auto slang =
109 int sndx = make_iterator_range( mLangCodes ).index( slang );
110 wxString sname;
112 if (sndx == wxNOT_FOUND) {
113 const wxLanguageInfo *sinfo = wxLocale::FindLanguageInfo(slang);
114 if (sinfo) {
115 sname = sinfo->Description;
116 }
117 }
118 else {
119 sname = mLangNames[sndx].Translation();
120 }
122 if (mLang.Left(2) != slang.Left(2)) {
123 /* i18n-hint: The %s's are replaced by translated and untranslated
124 * versions of language names. */
125 auto msg = XO("The language you have chosen, %s (%s), is not the same as the system language, %s (%s).")
126 .Format(mLangNames[ndx],
127 mLang,
128 sname,
129 slang);
130 if ( wxNO == AudacityMessageBox( msg, XO("Confirm"), wxYES_NO ) ) {
131 return;
132 }
133 }
135 EndModal(true);
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)

References AudacityMessageBox(), FileNames::AudacityPathList(), Languages::GetSystemLanguageCode(), make_iterator_range(), mChoice, mLang, mLangCodes, mLangNames, and XO().

Here is the call graph for this function:

Member Data Documentation

◆ mChoice

wxChoice* LangChoiceDialog::mChoice

Definition at line 42 of file LangChoice.cpp.

Referenced by OnOk().

◆ mLang

wxString LangChoiceDialog::mLang

Definition at line 43 of file LangChoice.cpp.

Referenced by GetLang(), and OnOk().

◆ mLangCodes

wxArrayString LangChoiceDialog::mLangCodes

Definition at line 46 of file LangChoice.cpp.

Referenced by OnOk().

◆ mLangNames

TranslatableStrings LangChoiceDialog::mLangNames

Definition at line 47 of file LangChoice.cpp.

Referenced by OnOk().

◆ mNumLangs

int LangChoiceDialog::mNumLangs

Definition at line 45 of file LangChoice.cpp.

The documentation for this class was generated from the following file: