Skip to content

Commit f72bd66

Browse files
committed
Update prompt to code to reply in user preferred language
1 parent c4c1f42 commit f72bd66

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Core/Sources/PromptToCodeService/PromptToCodeService.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ final class OpenAIPromptToCodeAPI: PromptToCodeAPI {
128128
usesTabsForIndentation: Bool,
129129
requirement: String
130130
) async throws -> AsyncThrowingStream<(code: String, description: String), Error> {
131+
let userPreferredLanguage = UserDefaults.shared.value(for: \.chatGPTLanguage)
132+
let textLanguage = userPreferredLanguage.isEmpty ? "" : "in \(userPreferredLanguage)"
133+
131134
let prompt = {
132135
let indentRule = usesTabsForIndentation ? "\(indentSize) tabs" : "\(indentSize) spaces"
133136
if code.isEmpty {
@@ -138,7 +141,7 @@ final class OpenAIPromptToCodeAPI: PromptToCodeAPI {
138141
indentRule
139142
).
140143
141-
Please reply to me start with the code block, followed by a short description in 1-3 sentences about what you did.
144+
Please reply to me start with the code block, followed by a short description in 1-3 sentences about what you did \(textLanguage).
142145
"""
143146
} else {
144147
return """
@@ -148,7 +151,7 @@ final class OpenAIPromptToCodeAPI: PromptToCodeAPI {
148151
indentRule
149152
).
150153
151-
Please reply to me start with the code block followed by a short description about what you did in 1-3 sentences.
154+
Please reply to me start with the code block followed by a short description about what you did in 1-3 sentences \(textLanguage).
152155
153156
```
154157
\(code)

0 commit comments

Comments
 (0)