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:
[legend]
Collaboration diagram for LangChoiceDialog:
[legend]

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)
71{
72 SetName();
73 const auto &paths = FileNames::AudacityPathList();
76 .index( Languages::GetSystemLanguageCode(paths) );
77
79
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();
90
91 S.SetBorder(0);
92 S.AddStandardButtons(eOkButton);
93 }
94 S.EndVerticalLay();
95
96 Fit();
97}
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 ( )
inline

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)
private

Definition at line 99 of file LangChoice.cpp.

100{
101 int ndx = mChoice->GetSelection();
102 mLang = mLangCodes[ndx];
103
104 auto slang =
106 int sndx = make_iterator_range( mLangCodes ).index( slang );
107 wxString sname;
108
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 }
118
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 }
131
132 EndModal(true);
133}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
XO("Cut/Copy/Paste")

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
private

Definition at line 39 of file LangChoice.cpp.

Referenced by OnOk().

◆ mLang

wxString LangChoiceDialog::mLang
private

Definition at line 40 of file LangChoice.cpp.

Referenced by GetLang(), and OnOk().

◆ mLangCodes

wxArrayString LangChoiceDialog::mLangCodes
private

Definition at line 43 of file LangChoice.cpp.

Referenced by OnOk().

◆ mLangNames

TranslatableStrings LangChoiceDialog::mLangNames
private

Definition at line 44 of file LangChoice.cpp.

Referenced by OnOk().

◆ mNumLangs

int LangChoiceDialog::mNumLangs
private

Definition at line 42 of file LangChoice.cpp.


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