Skip to content

Commit

Permalink
feat: support English language
Browse files Browse the repository at this point in the history
  • Loading branch information
iHTCboy committed Mar 19, 2023
1 parent 7997908 commit e916363
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 23 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ OpenAI ChatGPT app for iOS, iPadOS, macoS
#### 更新说明

最新版本 v2.1:
- support GPT-4 Model
- support GPT-4 Model(支持 GPT-4 模型)
- support English language(支持英文语言)
- display configured API Key(显示已配置的 API Key)


v2.0:
Expand All @@ -38,9 +40,9 @@ v2.0:

* ~~显示个人头像~~
* ~~请求失败重试等~~
* ~~支持多语言,如英文~~
* 保存对话
* 代码没有高亮
* 支持多语言,如英文
* 悬浮窗模式
* 保存 pdf 文件
* 自由的选择和复制文本
Expand Down
25 changes: 19 additions & 6 deletions iChatGPT.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
6D37A73B29C6D76800EF1F7B /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6D37A73D29C6D76800EF1F7B /* Localizable.strings */; };
6D5C556B2944408700FCF891 /* ImageLoaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5C556A2944408700FCF891 /* ImageLoaderView.swift */; };
6DAA91802943448D004ACD01 /* MarkdownText in Frameworks */ = {isa = PBXBuildFile; productRef = 6DAA917F2943448D004ACD01 /* MarkdownText */; };
6DAA9182294346D8004ACD01 /* MarkdownStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DAA9181294346D8004ACD01 /* MarkdownStyles.swift */; };
Expand Down Expand Up @@ -46,6 +47,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
6D37A73C29C6D76800EF1F7B /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
6D37A73E29C6D76B00EF1F7B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
6D5C55682944317300FCF891 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6D5C556A2944408700FCF891 /* ImageLoaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageLoaderView.swift; sourceTree = "<group>"; };
6D7C1A202945809C008EB1CA /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
Expand Down Expand Up @@ -132,6 +135,7 @@
6DC88B122942C8E000DA6C55 /* Extensions */,
6DC88AE12942C8AE00DA6C55 /* Assets.xcassets */,
6D5C55682944317300FCF891 /* Info.plist */,
6D37A73D29C6D76800EF1F7B /* Localizable.strings */,
6DC88AE32942C8AE00DA6C55 /* Preview Content */,
);
path = iChatGPT;
Expand Down Expand Up @@ -298,6 +302,7 @@
buildActionMask = 2147483647;
files = (
6DC88AE52942C8AE00DA6C55 /* Preview Assets.xcassets in Resources */,
6D37A73B29C6D76800EF1F7B /* Localizable.strings in Resources */,
6DC88AE22942C8AE00DA6C55 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -370,6 +375,18 @@
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
6D37A73D29C6D76800EF1F7B /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
6D37A73C29C6D76800EF1F7B /* zh-Hans */,
6D37A73E29C6D76B00EF1F7B /* en */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
6DC88AFC2942C8AE00DA6C55 /* Debug */ = {
isa = XCBuildConfiguration;
Expand Down Expand Up @@ -499,7 +516,6 @@
CURRENT_PROJECT_VERSION = 2023.3.19;
DEVELOPMENT_ASSET_PATHS = "\"iChatGPT/Preview Content\"";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = "";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = iChatGPT/Info.plist;
Expand All @@ -515,11 +531,10 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0;
MARKETING_VERSION = 2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.37iOS.iChatGPT;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
Expand All @@ -541,7 +556,6 @@
CURRENT_PROJECT_VERSION = 2023.3.19;
DEVELOPMENT_ASSET_PATHS = "\"iChatGPT/Preview Content\"";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = "";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = iChatGPT/Info.plist;
Expand All @@ -557,11 +571,10 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0;
MARKETING_VERSION = 2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.37iOS.iChatGPT;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
Expand Down
2 changes: 1 addition & 1 deletion iChatGPT/AIChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct AIChatView: View {
MarkdownText(item.answer ?? "")
} else {
ProgressView()
Text("请求中..")
Text("Loading..".localized())
.padding(.leading, 10)
}
}
Expand Down
14 changes: 7 additions & 7 deletions iChatGPT/ChatContextMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,38 @@ struct ChatContextMenu: View {
//
var body: some View {
VStack {
CreateMenuItem(text: "重新提问", imgName: "arrow.up.message") {
CreateMenuItem(text: "Re-question".localized(), imgName: "arrow.up.message") {
chatModel.getChatResponse(prompt: item.issue)
}
CreateMenuItem(text: "复制问题", imgName: "doc.on.doc") {
CreateMenuItem(text: "Copy Question".localized(), imgName: "doc.on.doc") {
item.issue.copyToClipboard()
}

CreateMenuItem(text: "复制答案", imgName: "doc.on.doc") {
CreateMenuItem(text: "Copy Answer".localized(), imgName: "doc.on.doc") {
item.answer!.copyToClipboard()
}
.disabled(item.answer == nil)

CreateMenuItem(text: "复制问题和答案", imgName: "doc.on.doc.fill") {
CreateMenuItem(text: "Copy Question and Answer".localized(), imgName: "doc.on.doc.fill") {
"\(item.issue)\n-----------\n\(item.answer ?? "")".copyToClipboard()
}
.disabled(item.answer == nil)

CreateMenuItem(text: "复制问题到输入框", imgName: "keyboard.badge.ellipsis") {
CreateMenuItem(text: "Copy Question to Inputbox".localized(), imgName: "keyboard.badge.ellipsis") {
searchText = item.issue
}

// remove item
let isWait = chatModel.contents.filter({ $0.isResponse == false })
CreateMenuItem(text: "删除问题", imgName: "trash", isDestructive: true) {
CreateMenuItem(text: "Delete Question".localized(), imgName: "trash", isDestructive: true) {
if let index = chatModel.contents.firstIndex(where: { $0.datetime == item.datetime })
{
chatModel.contents.remove(at: index)
}
}.disabled(isWait.count > 0)


CreateMenuItem(text: "删除全部", imgName: "trash", isDestructive: true) {
CreateMenuItem(text: "Delete All".localized(), imgName: "trash", isDestructive: true) {
chatModel.contents.removeAll()
}.disabled(isWait.count > 0)
}
Expand Down
2 changes: 1 addition & 1 deletion iChatGPT/ChatInputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct ChatInputView: View {
.padding(.trailing, 5)
}

let serachBar = TextField("随便问..", text: $searchText, onEditingChanged: changedSearch, onCommit: fetchSearch)
let serachBar = TextField("Just ask..".localized(), text: $searchText, onEditingChanged: changedSearch, onCommit: fetchSearch)
.textFieldStyle(.plain)
.padding(.trailing, 8)

Expand Down
4 changes: 4 additions & 0 deletions iChatGPT/Extensions/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ extension String {
#endif
}

public func localized() -> String {
let string = NSLocalizedString(self, comment: self)
return string
}
}
12 changes: 6 additions & 6 deletions iChatGPT/TokenSettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct TokenSettingView: View {
HStack {
Spacer().frame(width: 50)
Spacer()
Text("设置访问密钥").font(.headline).fontWeight(.bold).padding([.top, .leading], 12)
Text("Settings".localized()).font(.headline).fontWeight(.bold).padding([.top, .leading], 12)
Spacer()
Button {
isAddPresented = false
Expand Down Expand Up @@ -105,13 +105,13 @@ struct TokenSettingView: View {
Text("OpenAI Key:")
.padding(.top, 15)
if #available(iOS 15.0, *) {
TextField(" 请输入 OpenAI Key", text: $OpenAIKey)
TextField("Please enter OpenAI Key".localized(), text: $OpenAIKey)
.frame(height: 40)
.overlay(RoundedRectangle(cornerRadius: 5)
.stroke(Color.secondary))
.submitLabel(.done)
} else {
TextField(" 请输入 OpenAI Key", text: $OpenAIKey)
TextField("Please enter OpenAI Key".localized(), text: $OpenAIKey)
.frame(height: 40)
.overlay(RoundedRectangle(cornerRadius: 5)
.stroke(Color.secondary))
Expand All @@ -135,15 +135,15 @@ struct TokenSettingView: View {
Spacer()
Button(action: {
guard !OpenAIKey.isEmpty else{
kError = "OpenAI Key 不能为空"
kError = "OpenAI Key cannot be empty".localized()
return
}

UserDefaults.standard.set(OpenAIKey, forKey: ChatGPTOpenAIKey)
isAddPresented = false
chatModel.isRefreshSession = true
}) {
Text("保存")
Text("Save Key".localized())
.font(.title3)
.foregroundColor(.blue)
.padding([.leading, .trailing], 20)
Expand All @@ -159,7 +159,7 @@ struct TokenSettingView: View {
.foregroundColor(.gray)
.padding(.bottom, 10)

Text("开发者:37手游iOS技术运营团队\nGitHub 开源:https://github.com/37iOS/iChatGPT")
Text("Developer: 37 Mobile iOS Tech Team\nGitHub: https://github.com/37iOS/iChatGPT".localized())
.font(.footnote)
.foregroundColor(.secondary)
.multilineTextAlignment(.center)
Expand Down
22 changes: 22 additions & 0 deletions iChatGPT/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Localizable.strings
iChatGPT

Created by HTC on 2023/3/19.
Copyright © 2023 37 Mobile Games. All rights reserved.
*/

"Loading.." = "Loading..";
"Just ask.." = "Just ask..";
"Re-question" = "Re-question";
"Copy Question" = "Copy Question";
"Copy Answer" = "Copy Answer";
"Copy Question and Answer" = "Copy Question and Answer";
"Copy Question to Inputbox" = "Copy Question to Inputbox";
"Delete Question" = "Delete Question";
"Delete All" = "Delete All";
"Settings" = "Settings";
"Please enter OpenAI Key" = " Please enter OpenAI Key";
"OpenAI Key cannot be empty" = "OpenAI Key cannot be empty";
"Save Key" = "Save Key";
"Developer: 37 Mobile iOS Tech Team\nGitHub: https://github.com/37iOS/iChatGPT" = "Developer: 37 Mobile iOS Tech Team\nGitHub: https://github.com/37iOS/iChatGPT";
22 changes: 22 additions & 0 deletions iChatGPT/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Localizable.strings
iChatGPT

Created by HTC on 2023/3/19.
Copyright © 2023 37 Mobile Games. All rights reserved.
*/

"Loading.." = "请求中..";
"Just ask.." = "随便问..";
"Re-question" = "重新提问";
"Copy Question" = "复制问题";
"Copy Answer" = "复制答案";
"Copy Question and Answer" = "复制问题和答案";
"Copy Question to Inputbox" = "复制问题到输入框";
"Delete Question" = "删除问题";
"Delete All" = "删除全部";
"Settings" = "设置";
"Please enter OpenAI Key" = " 请输入 OpenAI Key";
"OpenAI Key cannot be empty" = "OpenAI Key 不能为空";
"Save Key" = "保存 Key";
"Developer: 37 Mobile iOS Tech Team\nGitHub: https://github.com/37iOS/iChatGPT" = "开发者:37手游iOS技术运营团队\nGitHub 开源:https://github.com/37iOS/iChatGPT";

0 comments on commit e916363

Please sign in to comment.