@@ -73,19 +73,16 @@ struct OpenAIView: View {
7373 Text ( " ChatGPT Server " )
7474 } . textFieldStyle ( . roundedBorder)
7575
76- Picker ( selection: $settings. chatGPTLanguage) {
77- if !settings. chatGPTLanguage. isEmpty,
78- !OpenAIViewSettings. availableLocalizedLocales. contains ( settings. chatGPTLanguage)
79- {
80- Text ( settings. chatGPTLanguage) . tag ( settings. chatGPTLanguage)
76+ if #available( macOS 13 . 0 , * ) {
77+ LabeledContent ( " Reply in Language " ) {
78+ languagePicker
8179 }
82- Text ( " Auto-detected by ChatGPT " ) . tag ( " " )
83- ForEach ( OpenAIViewSettings . availableLocalizedLocales, id: \. self) { localizedLocales in
84- Text ( localizedLocales) . tag ( localizedLocales)
80+ } else {
81+ HStack {
82+ Text ( " Reply in Language " )
83+ languagePicker
8584 }
86- } label: {
87- Text ( " Reply in Language " )
88- } . pickerStyle ( . menu)
85+ }
8986
9087 if let model = ChatGPTModel ( rawValue: settings. chatGPTModel) {
9188 let binding = Binding (
@@ -119,6 +116,39 @@ struct OpenAIView: View {
119116 }
120117 }
121118 }
119+
120+ var languagePicker : some View {
121+ Menu {
122+ if !settings. chatGPTLanguage. isEmpty,
123+ !OpenAIViewSettings. availableLocalizedLocales
124+ . contains ( settings. chatGPTLanguage)
125+ {
126+ Button (
127+ settings. chatGPTLanguage,
128+ action: { self . settings. chatGPTLanguage = settings. chatGPTLanguage }
129+ )
130+ }
131+ Button (
132+ " Auto-detected by ChatGPT " ,
133+ action: { self . settings. chatGPTLanguage = " " }
134+ )
135+ ForEach (
136+ OpenAIViewSettings . availableLocalizedLocales,
137+ id: \. self
138+ ) { localizedLocales in
139+ Button (
140+ localizedLocales,
141+ action: { self . settings. chatGPTLanguage = localizedLocales }
142+ )
143+ }
144+ } label: {
145+ Text (
146+ settings. chatGPTLanguage. isEmpty
147+ ? " Auto-detected by ChatGPT "
148+ : settings. chatGPTLanguage
149+ )
150+ }
151+ }
122152}
123153
124154struct OpenAIView_Previews : PreviewProvider {
0 commit comments