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 28 of file LangChoice.cpp.

Constructor & Destructor Documentation

◆ LangChoiceDialog()

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

Definition at line 67 of file LangChoice.cpp.

69 :
70 wxDialogWrapper(parent, id, title)
72 SetName();
73 const auto &paths = FileNames::AudacityPathList();
76 .index( Languages::GetSystemLanguageCode(paths) );
80 S.StartVerticalLay(false);
81 {
82 S.StartHorizontalLay();
83 {
84 S.SetBorder(15);
85 mChoice = S.AddChoice(XXO("Choose Language for Audacity to use:"),
87 lang);
88 }
89 S.EndVerticalLay();
91 S.SetBorder(0);
92 S.AddStandardButtons(eOkButton);
93 }
94 S.EndVerticalLay();
96 Fit();
XXO("&Cut/Copy/Paste Toolbar")
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: IteratorX.h:210
static const auto title
@ eIsCreating
Definition: ShuttleGui.h:37
@ eOkButton
Definition: ShuttleGui.h:609
#define S(N)
Definition: ToChars.cpp:64
TranslatableStrings mLangNames
Definition: LangChoice.cpp:44
wxArrayString mLangCodes
Definition: LangChoice.cpp:43
wxChoice * mChoice
Definition: LangChoice.cpp:39
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
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 34 of file LangChoice.cpp.

34{ return mLang; }

References mLang.

Referenced by ChooseLanguage().

Here is the caller graph for this function:

◆ OnOk()

void LangChoiceDialog::OnOk ( wxCommandEvent &  event)

Definition at line 99 of file LangChoice.cpp.

101 int ndx = mChoice->GetSelection();
102 mLang = mLangCodes[ndx];
104 auto slang =
106 int sndx = make_iterator_range( mLangCodes ).index( slang );
107 wxString sname;
109 if (sndx == wxNOT_FOUND) {
110 const wxLanguageInfo *sinfo = wxLocale::FindLanguageInfo(slang);
111 if (sinfo) {
112 sname = sinfo->Description;
113 }
114 }
115 else {
116 sname = mLangNames[sndx].Translation();
117 }
119 if (mLang.Left(2) != slang.Left(2)) {
120 /* i18n-hint: The %s's are replaced by translated and untranslated
121 * versions of language names. */
122 auto msg = XO("The language you have chosen, %s (%s), is not the same as the system language, %s (%s).")
123 .Format(mLangNames[ndx],
124 mLang,
125 sname,
126 slang);
127 if ( wxNO == AudacityMessageBox( msg, XO("Confirm"), wxYES_NO ) ) {
128 return;
129 }
130 }
132 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 39 of file LangChoice.cpp.

Referenced by OnOk().

◆ mLang

wxString LangChoiceDialog::mLang

Definition at line 40 of file LangChoice.cpp.

Referenced by GetLang(), and OnOk().

◆ mLangCodes

wxArrayString LangChoiceDialog::mLangCodes

Definition at line 43 of file LangChoice.cpp.

Referenced by OnOk().

◆ mLangNames

TranslatableStrings LangChoiceDialog::mLangNames

Definition at line 44 of file LangChoice.cpp.

Referenced by OnOk().

◆ mNumLangs

int LangChoiceDialog::mNumLangs

Definition at line 42 of file LangChoice.cpp.

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