Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement NSLocalizedString #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions MeoAsstMac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@
92EB82862A0CD315006DD9D2 /* SystemSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemSettingsView.swift; sourceTree = "<group>"; };
92F78D4C2A0A7B2E00999BD0 /* TaskTimerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskTimerView.swift; sourceTree = "<group>"; };
92F78D4E2A0B361C00999BD0 /* TaskTimerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskTimerManager.swift; sourceTree = "<group>"; };
CE8977262C9707250075E1C6 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; };
CE8977272C9707300075E1C6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -470,9 +472,9 @@
developmentRegion = "zh-Hans";
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
"zh-Hans",
ko,
en,
);
mainGroup = 833786C228F188D800D39D6F;
packageReferences = (
Expand Down Expand Up @@ -579,6 +581,8 @@
isa = PBXVariantGroup;
children = (
832985A529EE0D6F009F7ED5 /* zh-Hans */,
CE8977262C9707250075E1C6 /* ko */,
CE8977272C9707300075E1C6 /* en */,
);
name = Localizable.strings;
sourceTree = "<group>";
Expand Down
12 changes: 6 additions & 6 deletions MeoAsstMac/Configuration Views/AwardSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ struct AwardSettingsView: View {

var body: some View {
Form {
Toggle("领取每日/每周任务奖励", isOn: config.award)
Toggle(NSLocalizedString("领取每日/每周任务奖励", comment: ""), isOn: config.award)

Toggle("领取所有邮件奖励", isOn: config.mail)
Toggle(NSLocalizedString("领取所有邮件奖励", comment: ""), isOn: config.mail)

Toggle("进行每日免费单抽", isOn: config.recruit)
Toggle(NSLocalizedString("进行每日免费单抽", comment: ""), isOn: config.recruit)

Toggle("领取幸运墙合成玉奖励", isOn: config.orundum)
Toggle(NSLocalizedString("领取幸运墙合成玉奖励", comment: ""), isOn: config.orundum)

Toggle("领取限时开采许可合成玉奖励", isOn: config.mining)
Toggle(NSLocalizedString("领取限时开采许可合成玉奖励", comment: ""), isOn: config.mining)

Toggle("领取五周年赠送月卡奖励", isOn: config.specialaccess)
Toggle(NSLocalizedString("领取五周年赠送月卡奖励", comment: ""), isOn: config.specialaccess)
}
.padding()
}
Expand Down
6 changes: 3 additions & 3 deletions MeoAsstMac/Configuration Views/FightSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ struct FightSettingsView: View {
Section {
HStack(spacing: 20) {
if useCustomStage || stageNotListed {
TextField("关卡名", text: config.stage)
TextField(NSLocalizedString("关卡名", comment: ""), text: config.stage)
} else {
Picker("关卡选择", selection: config.stage) {
Text("当前/上次").tag("")
Picker(NSLocalizedString("关卡选择", comment: ""), selection: config.stage) {
Text(NSLocalizedString("当前/上次", comment: "")).tag("")
Text("1-7").tag("1-7")
Text("CE-6").tag("CE-6")
Text("AP-5").tag("AP-5")
Expand Down
6 changes: 3 additions & 3 deletions MeoAsstMac/Configuration Views/InfrastSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ struct InfrastSettingsView: View {
config.facility.wrappedValue.move(fromOffsets: source, toOffset: destination)
}
} header: {
Text("已启用")
Text(NSLocalizedString("已启用", comment: ""))
}

Section {
ForEach(disabledFacilities) { facility in
Toggle(facility.description, isOn: facilityBinding(for: facility))
}
} header: {
Text("未启用")
Text(NSLocalizedString("未启用", comment: ""))
}
}
.animation(.default, value: config.facility.wrappedValue)
Expand All @@ -59,7 +59,7 @@ struct InfrastSettingsView: View {
@ViewBuilder private var preferenceForm: some View {
Form {
Section {
Text("无人机用途:")
Text(NSLocalizedString("无人机用途:", comment: ""))
Picker("", selection: config.drones) {
ForEach(MAAInfrastDroneUsage.allCases, id: \.self) { usage in
Text(usage.description).tag(usage)
Expand Down
12 changes: 6 additions & 6 deletions MeoAsstMac/Configuration Views/MallSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ struct MallSettingsView: View {
VStack(spacing: 30) {
HStack(spacing: 10) {
Spacer()
Toggle("信用购物", isOn: config.shopping)
Toggle("信用溢出时无视黑名单", isOn: config.force_shopping_if_credit_full)
Toggle("借助战赚信用", isOn: .constant(false))
Toggle(NSLocalizedString("信用购物", comment: ""), isOn: config.shopping)
Toggle(NSLocalizedString("信用溢出时无视黑名单", comment: ""), isOn: config.force_shopping_if_credit_full)
Toggle(NSLocalizedString("借助战赚信用", comment: ""), isOn: .constant(false))
Spacer()
}

HStack(spacing: 20) {
EditableTextList(title: "优先购买", texts: config.buy_first)
EditableTextList(title: "黑名单", texts: config.blacklist)
EditableTextList(title: NSLocalizedString("优先购买", comment: ""), texts: config.buy_first)
EditableTextList(title: NSLocalizedString("黑名单", comment: ""), texts: config.blacklist)
}
.frame(height: 12 * rowHeight)
}
Expand All @@ -46,7 +46,7 @@ struct MallSettingsView_Previews: PreviewProvider {
// MARK: - EditableTextList

private struct EditableTextList: View {
let title: LocalizedStringKey
let title: String
@Binding var texts: [String]

private struct TextEntry: Equatable, Identifiable {
Expand Down
10 changes: 5 additions & 5 deletions MeoAsstMac/Configuration Views/ReclamationSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ struct ReclamationSettingsView: View {

var body: some View {
Form {
Picker("主题:", selection: config.theme) {
Picker(NSLocalizedString("主题:", comment: ""), selection: config.theme) {
ForEach(ReclamationTheme.allCases, id: \.rawValue) { theme in
Text("\(theme.description)").tag(theme)
}
}

Picker("策略:", selection: config.mode) {
Picker(NSLocalizedString("策略:", comment: ""), selection: config.mode) {
ForEach(config.wrappedValue.modes.sorted(by: <), id: \.key) { mode, desc in
Text(desc).tag(mode)
}
}

if config.wrappedValue.toolToCraftEnabled {
TextField("支援道具:", text: config.tool_to_craft)
TextField("组装批次数:", value: config.num_craft_batches, format: .number)
Picker("组装数量增加模式:", selection: config.increment_mode) {
TextField(NSLocalizedString("支援道具:", comment: ""), text: config.tool_to_craft)
TextField(NSLocalizedString("组装批次数:", comment: ""), value: config.num_craft_batches, format: .number)
Picker(NSLocalizedString("组装数量增加模式:", comment: ""), selection: config.increment_mode) {
ForEach(config.wrappedValue.increment_modes.sorted(by: <), id: \.key) { increment_mode, desc in
Text(desc).tag(increment_mode)
}
Expand Down
4 changes: 2 additions & 2 deletions MeoAsstMac/Configuration Views/RecruitSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ struct RecruitSettingsView: View {

var body: some View {
VStack(alignment: .leading) {
Toggle("自动刷新3星Tags", isOn: config.refresh)
Toggle(NSLocalizedString("自动刷新3星Tags", comment: ""), isOn: config.refresh)

Toggle("自动使用加急许可", isOn: config.expedite)
Toggle(NSLocalizedString("自动使用加急许可", comment: ""), isOn: config.expedite)

Toggle("3星设置7:40而非9:00", isOn: level3UseShortTime)

Expand Down
16 changes: 8 additions & 8 deletions MeoAsstMac/Configuration Views/RoguelikeSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ struct RoguelikeSettingsView: View {
}

@ViewBuilder private func generalSettings() -> some View {
Picker("肉鸽主题:", selection: config.theme) {
Picker(NSLocalizedString("肉鸽主题:", comment: ""), selection: config.theme) {
ForEach(RoguelikeTheme.allCases, id: \.rawValue) { theme in
Text("\(theme.description)").tag(theme)
}
}

Picker("策略:", selection: config.mode) {
Picker(NSLocalizedString("策略:", comment: ""), selection: config.mode) {
ForEach(roguelikeModes[nil] ?? [], id: \.0) { pair in
Text(pair.1).tag(pair.0)
}
Expand All @@ -44,19 +44,19 @@ struct RoguelikeSettingsView: View {
}
}

TextField("最多探索次数:", value: config.starts_count, format: .number)
TextField(NSLocalizedString("最多探索次数:", comment: ""), value: config.starts_count, format: .number)
}

@ViewBuilder private func goldSettings() -> some View {
Toggle("投资源石锭", isOn: config.investment_enabled)
Toggle("刷新商店(指路鳞)", isOn: config.refresh_trader_with_dice)
Toggle("储备源石锭达到上限时停止", isOn: config.stop_when_investment_full)
Toggle(NSLocalizedString("投资源石锭", comment: ""), isOn: config.investment_enabled)
Toggle(NSLocalizedString("刷新商店(指路鳞)", comment: ""), isOn: config.refresh_trader_with_dice)
Toggle(NSLocalizedString("储备源石锭达到上限时停止", comment: ""), isOn: config.stop_when_investment_full)

TextField("最多投资源石锭数量:", value: config.investments_count, format: .number)
TextField(NSLocalizedString("最多投资源石锭数量:", comment: ""), value: config.investments_count, format: .number)
}

@ViewBuilder private func squadSettings() -> some View {
Picker("开局分队:", selection: config.squad) {
Picker(NSLocalizedString("开局分队:", comment: ""), selection: config.squad) {
ForEach(roguelikeSquads[config.theme.wrappedValue] ?? [], id: \.self) { squad in
Text(squad).tag(squad)
}
Expand Down
4 changes: 2 additions & 2 deletions MeoAsstMac/Configuration Views/StartupSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ struct StartupSettingsView: View {
Form {
VStack(alignment: .leading, spacing: 3) {
Text("客户端类型:\(config.client_type.wrappedValue.description)")
Text("请在“设置” > “游戏设置” 中选择客户端类型。")
Text(NSLocalizedString("请在“设置” > “游戏设置” 中选择客户端类型。", comment: ""))
.font(.caption)
.foregroundColor(.secondary)
}
.padding(.bottom)

Toggle("自动启动客户端", isOn: config.start_game_enabled)
Toggle(NSLocalizedString("自动启动客户端", comment: ""), isOn: config.start_game_enabled)
.disabled(config.client_type.wrappedValue == .default)
}
.padding()
Expand Down
2 changes: 1 addition & 1 deletion MeoAsstMac/Core/MaaMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ extension MAAViewModel {
logError("TouchModeNotAvaiable")

case "UnsupportedPlayTools":
logError("不支持此版本 PlayCover")
logError(NSLocalizedString("不支持此版本 PlayCover", comment: ""))

default:
break
Expand Down
2 changes: 1 addition & 1 deletion MeoAsstMac/Main Menu/CheckForUpdatesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct CheckForUpdatesView: View {
}

var body: some View {
Button("检查更新…", action: updater.checkForUpdates)
Button(NSLocalizedString("检查更新…", comment: ""), action: updater.checkForUpdates)
.disabled(!viewModel.canCheckForUpdates)
}
}
Expand Down
4 changes: 2 additions & 2 deletions MeoAsstMac/Main Menu/OpenLogFileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SwiftUI

struct OpenLogFileView: View {
var body: some View {
Button("打开日志文件夹…") {
Button(NSLocalizedString("打开日志文件夹…", comment: "")) {
guard let userDirectory else {
return
}
Expand All @@ -23,7 +23,7 @@ struct OpenLogFileView: View {
}
}

Button("PlayCover 链接…") {
Button(NSLocalizedString("PlayCover 链接…", comment: "")) {
NSWorkspace.shared.open(URL(string: "https://github.com/hguandl/PlayCover/releases")!)
}
}
Expand Down
2 changes: 1 addition & 1 deletion MeoAsstMac/Main Menu/TaskCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct TaskCommands: Commands {
@ObservedObject var viewModel: MAAViewModel

var body: some Commands {
CommandMenu("任务") {
CommandMenu(NSLocalizedString("任务", comment: "")) {
TaskButtons(viewModel: viewModel)
}
}
Expand Down
8 changes: 4 additions & 4 deletions MeoAsstMac/MeoAsstMacApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ struct MeoAsstMacApp: App {
TabView {
ConnectionSettingsView()
.tabItem {
Label("连接设置", systemImage: "rectangle.connected.to.line.below")
Label(NSLocalizedString("连接设置", comment: ""), systemImage: "rectangle.connected.to.line.below")
}

GameSettingsView()
.tabItem {
Label("游戏设置", systemImage: "gamecontroller")
Label(NSLocalizedString("游戏设置", comment: ""), systemImage: "gamecontroller")
}

UpdaterSettingsView(updater: updaterController.updater)
.tabItem {
Label("更新设置", systemImage: "square.and.arrow.down")
Label(NSLocalizedString("更新设置", comment: ""), systemImage: "square.and.arrow.down")
}

SystemSettingsView()
.tabItem {
Label("系统设置", systemImage: "wrench.adjustable")
Label(NSLocalizedString("系统设置", comment: ""), systemImage: "wrench.adjustable")
}
}
.environmentObject(appViewModel)
Expand Down
16 changes: 8 additions & 8 deletions MeoAsstMac/Navigation/CopilotContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct CopilotContent: View {
Text(url.lastPathComponent)
}
} header: {
Text("内置作业")
Text(NSLocalizedString("内置作业", comment: ""))
}

Section {
Expand All @@ -30,7 +30,7 @@ struct CopilotContent: View {
}
} header: {
HStack {
Text("外部作业(可拖入文件)")
Text(NSLocalizedString("外部作业(可拖入文件)", comment: ""))
if downloading {
Spacer()
ProgressView().controlSize(.small)
Expand All @@ -57,9 +57,9 @@ struct CopilotContent: View {
@ToolbarContentBuilder private func listToolbar() -> some ToolbarContent {
ToolbarItemGroup {
Button(action: deleteSelectedCopilot) {
Label("移除", systemImage: "trash")
Label(NSLocalizedString("移除", comment: ""), systemImage: "trash")
}
.help("移除作业")
.help(NSLocalizedString("移除作业", comment: ""))
.disabled(shouldDisableDeletion)
}

Expand All @@ -72,14 +72,14 @@ struct CopilotContent: View {
.disabled(true)
case .busy:
Button(action: stop) {
Label("停止", systemImage: "stop.fill")
Label(NSLocalizedString(NSLocalizedString("停止", comment: ""), comment: ""), systemImage: "stop.fill")
}
.help("停止")
.help(NSLocalizedString(NSLocalizedString("停止", comment: ""), comment: ""))
case .idle:
Button(action: start) {
Label("开始", systemImage: "play.fill")
Label(NSLocalizedString(NSLocalizedString("开始", comment: ""), comment: ""), systemImage: "play.fill")
}
.help("开始")
.help(NSLocalizedString(NSLocalizedString("开始", comment: ""), comment: ""))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion MeoAsstMac/Navigation/MAAContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct MAAContent: View {
case .utility:
UtilityContent(selection: $selection.utility)
case .none:
Text("请从边栏选择功能")
Text(NSLocalizedString("请从边栏选择功能", comment: ""))
}
}
.frame(minWidth: 260)
Expand Down
2 changes: 1 addition & 1 deletion MeoAsstMac/Navigation/MAADetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct MAADetail: View {
case .utility:
UtilityDetail(entry: selection.utility)
case .none:
Text("请选择内容项目")
Text(NSLocalizedString("请选择内容项目", comment: ""))
}
}
.frame(minWidth: 450, minHeight: 360)
Expand Down
6 changes: 3 additions & 3 deletions MeoAsstMac/Navigation/Sidebar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct Sidebar: View {
Spacer()

SettingsLink {
Label("设置", systemImage: "gear")
Label(NSLocalizedString("设置", comment: ""), systemImage: "gear")
}
.buttonStyle(.borderless)
.frame(maxWidth: .infinity, alignment: .leading)
Expand All @@ -30,9 +30,9 @@ struct Sidebar: View {
Button {
toggleSideBar()
} label: {
Label("显示/隐藏边栏", systemImage: "sidebar.left")
Label(NSLocalizedString(NSLocalizedString("显示/隐藏边栏", comment: ""), comment: ""), systemImage: "sidebar.left")
}
.help("显示/隐藏边栏")
.help(NSLocalizedString(NSLocalizedString("显示/隐藏边栏", comment: ""), comment: ""))
}
}
.frame(minWidth: 150)
Expand Down
4 changes: 2 additions & 2 deletions MeoAsstMac/Navigation/TaskDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ struct TaskDetail: View {
}
}
} label: {
Label("添加", systemImage: "plus")
Label(NSLocalizedString("添加", comment: ""), systemImage: "plus")
}
.help("添加任务")
.help(NSLocalizedString("添加任务", comment: ""))
}

ToolbarItemGroup {
Expand Down
Loading