Skip to content
Merged
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
1 change: 1 addition & 0 deletions ScreenTranslate.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
knownRegions = (
en,
Base,
"zh-Hans",
);
mainGroup = SC000004;
minimizedProjectReferenceProxies = 1;
Expand Down
3 changes: 3 additions & 0 deletions ScreenTranslate/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
Task {
await checkFirstLaunchAndShowOnboarding()
}

// Check PaddleOCR availability in background (non-blocking)
PaddleOCRChecker.checkAvailabilityAsync()

#if DEBUG
print("ScreenTranslate launched - settings loaded from: \(settings.saveLocation.path)")
Expand Down
28 changes: 14 additions & 14 deletions ScreenTranslate/Features/History/HistoryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private struct SearchBar: View {
Image(systemName: "magnifyingglass")
.foregroundStyle(.secondary)

TextField("Search history...", text: Binding(
TextField(String(localized: "history.search.placeholder"), text: Binding(
get: { store.searchQuery },
set: { store.search($0) }
))
Expand Down Expand Up @@ -94,7 +94,7 @@ private struct SearchBar: View {
.foregroundStyle(.secondary)
}
.buttonStyle(.plain)
.help("Clear all history")
.help(String(localized: "history.clear.all"))
}
}
.padding(12)
Expand Down Expand Up @@ -135,26 +135,26 @@ private struct EmptyStateView: View {
.foregroundStyle(.secondary)

if store.searchQuery.isEmpty {
Text("No Translation History")
Text("history.empty.title")
.font(.headline)
.foregroundStyle(.secondary)

Text("Your translated screenshots will appear here")
Text("history.empty.message")
.font(.body)
.foregroundStyle(.tertiary)
} else {
Text("No Results")
Text("history.no.results.title")
.font(.headline)
.foregroundStyle(.secondary)

Text("No entries match your search")
Text("history.no.results.message")
.font(.body)
.foregroundStyle(.tertiary)

Button {
store.search("")
} label: {
Text("Clear Search")
Text("history.clear.search")
}
.buttonStyle(.borderedProminent)
}
Expand Down Expand Up @@ -204,7 +204,7 @@ private struct HistoryEntryRow: View {
TextSection(
text: entry.sourcePreview,
isTruncated: entry.isSourceTruncated,
label: "Source"
label: String(localized: "history.source")
)

// Arrow separator
Expand All @@ -227,7 +227,7 @@ private struct HistoryEntryRow: View {
TextSection(
text: entry.translatedPreview,
isTruncated: entry.isTranslatedTruncated,
label: "Translation"
label: String(localized: "history.translation")
)
}

Expand Down Expand Up @@ -291,7 +291,7 @@ private struct TextSection: View {
HStack(spacing: 4) {
Image(systemName: "ellipsis")
.font(.caption2)
Text("truncated")
Text("history.truncated")
.font(.caption2)
}
.foregroundStyle(.tertiary)
Expand All @@ -312,27 +312,27 @@ private struct EntryContextMenu: View {
Button {
store.copyTranslation(entry)
} label: {
Label("Copy Translation", systemImage: "doc.on.doc")
Label(String(localized: "history.copy.translation"), systemImage: "doc.on.doc")
}

Button {
store.copySource(entry)
} label: {
Label("Copy Source", systemImage: "doc.on.doc")
Label(String(localized: "history.copy.source"), systemImage: "doc.on.doc")
}

Button {
store.copyBoth(entry)
} label: {
Label("Copy Both", systemImage: "doc.on.clipboard")
Label(String(localized: "history.copy.both"), systemImage: "doc.on.clipboard")
}

Divider()

Button(role: .destructive) {
store.remove(entry)
} label: {
Label("Delete", systemImage: "trash")
Label(String(localized: "history.delete"), systemImage: "trash")
}
}
}
Expand Down
31 changes: 23 additions & 8 deletions ScreenTranslate/Features/MenuBar/MenuBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ final class MenuBarController {
init(appDelegate: AppDelegate, recentCapturesStore: RecentCapturesStore) {
self.appDelegate = appDelegate
self.recentCapturesStore = recentCapturesStore

NotificationCenter.default.addObserver(
forName: LanguageManager.languageDidChangeNotification,
object: nil,
queue: .main
) { [weak self] _ in
Task { @MainActor in
self?.rebuildMenu()
}
}
}

// MARK: - Setup
Expand All @@ -46,6 +56,11 @@ final class MenuBarController {
statusItem = nil
}
}

/// Rebuilds the menu when language changes
func rebuildMenu() {
statusItem?.menu = buildMenu()
}

// MARK: - Menu Construction

Expand All @@ -55,7 +70,7 @@ final class MenuBarController {

// Capture Full Screen
let fullScreenItem = NSMenuItem(
title: NSLocalizedString("menu.capture.full.screen", comment: "Capture Full Screen"),
title: NSLocalizedString("menu.capture.full.screen", tableName: "Localizable", bundle: .main, comment: "Capture Full Screen"),
action: #selector(AppDelegate.captureFullScreen),
keyEquivalent: "3"
)
Expand All @@ -65,7 +80,7 @@ final class MenuBarController {

// Capture Selection
let selectionItem = NSMenuItem(
title: NSLocalizedString("menu.capture.selection", comment: "Capture Selection"),
title: NSLocalizedString("menu.capture.selection", tableName: "Localizable", bundle: .main, comment: "Capture Selection"),
action: #selector(AppDelegate.captureSelection),
keyEquivalent: "4"
)
Expand All @@ -77,7 +92,7 @@ final class MenuBarController {

// Recent Captures submenu
let recentItem = NSMenuItem(
title: NSLocalizedString("menu.recent.captures", comment: "Recent Captures"),
title: NSLocalizedString("menu.recent.captures", tableName: "Localizable", bundle: .main, comment: "Recent Captures"),
action: nil,
keyEquivalent: ""
)
Expand All @@ -89,7 +104,7 @@ final class MenuBarController {

// Translation History
let historyItem = NSMenuItem(
title: NSLocalizedString("menu.translation.history", comment: "Translation History"),
title: NSLocalizedString("menu.translation.history", tableName: "Localizable", bundle: .main, comment: "Translation History"),
action: #selector(AppDelegate.openHistory),
keyEquivalent: "h"
)
Expand All @@ -101,7 +116,7 @@ final class MenuBarController {

// Settings
let settingsItem = NSMenuItem(
title: NSLocalizedString("menu.settings", comment: "Settings..."),
title: NSLocalizedString("menu.settings", tableName: "Localizable", bundle: .main, comment: "Settings..."),
action: #selector(AppDelegate.openSettings),
keyEquivalent: ","
)
Expand All @@ -113,7 +128,7 @@ final class MenuBarController {

// Quit
let quitItem = NSMenuItem(
title: NSLocalizedString("menu.quit", comment: "Quit ScreenTranslate"),
title: NSLocalizedString("menu.quit", tableName: "Localizable", bundle: .main, comment: "Quit ScreenTranslate"),
action: #selector(NSApplication.terminate(_:)),
keyEquivalent: "q"
)
Expand Down Expand Up @@ -144,7 +159,7 @@ final class MenuBarController {

if captures.isEmpty {
let emptyItem = NSMenuItem(
title: NSLocalizedString("menu.recent.captures.empty", comment: "No Recent Captures"),
title: NSLocalizedString("menu.recent.captures.empty", tableName: "Localizable", bundle: .main, comment: "No Recent Captures"),
action: nil,
keyEquivalent: ""
)
Expand All @@ -161,7 +176,7 @@ final class MenuBarController {
menu.addItem(NSMenuItem.separator())

let clearItem = NSMenuItem(
title: NSLocalizedString("menu.recent.captures.clear", comment: "Clear Recent"),
title: NSLocalizedString("menu.recent.captures.clear", tableName: "Localizable", bundle: .main, comment: "Clear Recent"),
action: #selector(clearRecentCaptures),
keyEquivalent: ""
)
Expand Down
Loading