Skip to content
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
6 changes: 3 additions & 3 deletions apps/MTPLXApp/Sources/MTPLXAppHost/App/MTPLXApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ struct MTPLXApp: App {

CommandMenu("View") {
ForEach(Array(AppTab.allCases.enumerated()), id: \.element.id) { index, tab in
Button(tab.title) {
Button(tab.title.mtplxLocalized) {
router.select(tab)
}
.keyboardShortcut(KeyEquivalent(Character("\(index + 1)")), modifiers: [.command])
Expand All @@ -329,7 +329,7 @@ struct MTPLXApp: App {
Button("Previous Tab") { router.previousTab() }
.keyboardShortcut("[", modifiers: [.command])
Divider()
Button(router.benchmarkOverlayPresented ? "Close Benchmark" : "Open Benchmark") {
Button((router.benchmarkOverlayPresented ? "Close Benchmark" : "Open Benchmark").mtplxLocalized) {
if router.benchmarkOverlayPresented {
router.closeBenchmark()
} else {
Expand All @@ -355,7 +355,7 @@ struct MTPLXApp: App {
_ = chatViewModel.createNewConversation()
}
.keyboardShortcut("n", modifiers: [.command])
Button(router.chatSidebarCollapsed ? "Show Sidebar" : "Hide Sidebar") {
Button((router.chatSidebarCollapsed ? "Show Sidebar" : "Hide Sidebar").mtplxLocalized) {
withAnimation(.smooth(duration: 0.22)) {
router.chatSidebarCollapsed.toggle()
}
Expand Down
10 changes: 10 additions & 0 deletions apps/MTPLXApp/Sources/MTPLXAppHost/Helpers/Localization.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Foundation

extension String {
/// Looks up a runtime-provided UI label in the app's localization table.
/// SwiftUI localizes string literals automatically, but labels passed
/// through reusable components arrive as plain `String` values.
var mtplxLocalized: String {
Bundle.main.localizedString(forKey: self, value: self, table: nil)
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct BenchHeaderStat: View {

var body: some View {
VStack(alignment: .leading, spacing: 2) {
Text(label)
Text(label.mtplxLocalized)
.font(.system(size: 9, weight: .heavy, design: .monospaced))
.tracking(1.4)
.foregroundStyle(Brand.typeTertiary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct BenchPrimaryCTA: View {
HStack(spacing: 6) {
Image(systemName: icon)
.font(.system(size: 11, weight: .heavy))
Text(title)
Text(title.mtplxLocalized)
.lineLimit(1)
.contentTransition(.opacity)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct BenchSummaryCard: View {

private func metaRow(label: String, value: String) -> some View {
HStack(spacing: 10) {
Text(label)
Text(label.mtplxLocalized)
.font(.system(size: 9, weight: .heavy, design: .monospaced))
.tracking(1.4)
.foregroundStyle(Brand.typeTertiary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct BenchTelemetryCell: View {

var body: some View {
VStack(alignment: .leading, spacing: 2) {
Text(label)
Text(label.mtplxLocalized)
.font(.system(size: 9, weight: .heavy, design: .monospaced))
.tracking(1.4)
.foregroundStyle(Brand.typeTertiary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct SourcesFooterView: View {
HStack(spacing: 6) {
Image(systemName: "link")
.font(.system(size: 10, weight: .medium))
Text("\(sources.count) source\(sources.count == 1 ? "" : "s")")
Text(sourceCountLabel)
.font(.system(size: 12, weight: .medium, design: .rounded))
Image(systemName: "chevron.right")
.font(.system(size: 9, weight: .semibold))
Expand All @@ -68,12 +68,25 @@ struct SourcesFooterView: View {
.contentShape(Capsule())
}
.buttonStyle(.plain)
.help(isExpanded ? "Hide sources" : "Show all \(sources.count) sources")
.help(isExpanded ? "Hide sources".mtplxLocalized : showAllSourcesLabel)
.accessibilityLabel(
isExpanded ? "Hide sources" : "Show \(sources.count) sources"
isExpanded ? "Hide sources".mtplxLocalized : showSourcesLabel
)
}

private var sourceCountLabel: String {
let key = sources.count == 1 ? "%d source" : "%d sources"
return String(format: key.mtplxLocalized, sources.count)
}

private var showAllSourcesLabel: String {
String(format: "Show all %d sources".mtplxLocalized, sources.count)
}

private var showSourcesLabel: String {
String(format: "Show %d sources".mtplxLocalized, sources.count)
}

private func sourcePill(index: Int, source: SourceRecord) -> some View {
Button {
guard let url = URL(string: source.url) else { return }
Expand Down Expand Up @@ -102,6 +115,12 @@ struct SourcesFooterView: View {
}
.buttonStyle(.plain)
.help(source.title.isEmpty ? source.url : source.title)
.accessibilityLabel("Open source \(index): \(source.domain)")
.accessibilityLabel(
String(
format: "Open source %1$d: %2$@".mtplxLocalized,
index,
source.domain
)
)
}
}
10 changes: 5 additions & 5 deletions apps/MTPLXApp/Sources/MTPLXAppHost/Views/Chrome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ struct DaemonStatePill: View {
return HStack(spacing: 6) {
stateDot
.frame(width: 8, height: 8)
Text(kind.label.uppercased())
Text(kind.label.mtplxLocalized.uppercased())
.font(.system(size: 10, weight: .heavy, design: .monospaced))
.tracking(1.5)
if let detail {
Text("·")
.foregroundStyle(Brand.textHighlight.opacity(0.4))
Text(detail)
Text(detail.mtplxLocalized)
.font(.caption2)
.foregroundStyle(Brand.textHighlight.opacity(0.65))
.lineLimit(1)
Expand All @@ -37,7 +37,7 @@ struct DaemonStatePill: View {
)
)
.foregroundStyle(tint)
.help(helpText)
.help(helpText.mtplxLocalized)
}

private var tint: Color {
Expand Down Expand Up @@ -115,13 +115,13 @@ struct ConnectionDot: View {
}
}
.frame(width: 14, height: 14)
Text(label)
Text(label.mtplxLocalized)
.font(.system(size: 11, weight: .semibold, design: .monospaced))
.tracking(0.5)
.foregroundStyle(tint.opacity(0.95))
}
.onChange(of: stateKey) { _, _ in pulseKey &+= 1 }
.help(helpText)
.help(helpText.mtplxLocalized)
}

/// True only when both the daemon is `.running` and the SSE stream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private struct ARBaselineRow: View {

var body: some View {
HStack(spacing: 10) {
Text(row.label)
Text(row.label.mtplxLocalized)
.font(.system(size: 10, weight: .heavy, design: .monospaced))
.foregroundStyle(Brand.typeTertiary)
.frame(width: 24, alignment: .leading)
Expand All @@ -276,7 +276,7 @@ private struct AcceptanceBarRow: View {

var body: some View {
HStack(spacing: 10) {
Text(row.label)
Text(row.label.mtplxLocalized)
.font(.system(size: 10, weight: .heavy, design: .monospaced))
.foregroundStyle(row.isWinner ? Brand.typeHi : Brand.typeSecondary)
.frame(width: 24, alignment: .leading)
Expand Down
4 changes: 2 additions & 2 deletions apps/MTPLXApp/Sources/MTPLXAppHost/Views/Common/Card.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ struct Card<Content: View>: View {
HStack(alignment: .firstTextBaseline) {
VStack(alignment: .leading, spacing: 2) {
if let title {
Text(title)
Text(title.mtplxLocalized)
.font(.headline)
.foregroundStyle(.primary)
}
if let subtitle {
Text(subtitle)
Text(subtitle.mtplxLocalized)
.font(.caption)
.foregroundStyle(.secondary)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ struct EmptyStateView: View {
Image(systemName: symbol)
.font(.system(size: 36, weight: .light))
.foregroundStyle(Brand.typeBody.opacity(0.45))
Text(title)
Text(title.mtplxLocalized)
.font(.system(.title3, design: .rounded).weight(.bold))
.chromeText()
Text(message)
Text(message.mtplxLocalized)
.font(.callout)
.foregroundStyle(Brand.typeBody.opacity(0.7))
.multilineTextAlignment(.center)
.frame(maxWidth: 360, minHeight: 38)
if let action {
Button(actionLabel, action: action)
Button(actionLabel.mtplxLocalized, action: action)
.controlSize(.large)
.buttonStyle(.borderedProminent)
.tint(Brand.accentChrome)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ struct FormRow<Content: View>: View {
var body: some View {
HStack(alignment: .firstTextBaseline, spacing: 12) {
VStack(alignment: .leading, spacing: 3) {
Text(label)
Text(label.mtplxLocalized)
.font(.system(.callout))
.foregroundStyle(Brand.typeBody)
if let caption {
Text(caption)
Text(caption.mtplxLocalized)
.font(.caption2)
.foregroundStyle(Brand.typeTertiary)
.fixedSize(horizontal: false, vertical: true)
Expand All @@ -57,11 +57,11 @@ struct FormToggleRow: View {
var body: some View {
HStack(alignment: .firstTextBaseline, spacing: 12) {
VStack(alignment: .leading, spacing: 3) {
Text(label)
Text(label.mtplxLocalized)
.font(.system(.callout))
.foregroundStyle(Brand.typeBody)
if let caption {
Text(caption)
Text(caption.mtplxLocalized)
.font(.caption2)
.foregroundStyle(Brand.typeTertiary)
.fixedSize(horizontal: false, vertical: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct HBarRow: View {
var body: some View {
VStack(alignment: .leading, spacing: 4) {
HStack {
Text(label)
Text(label.mtplxLocalized)
.font(.system(.caption, design: .rounded).weight(.bold))
.foregroundStyle(Brand.typeBody)
Spacer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct MetricRow: View {

var body: some View {
HStack {
Text(label)
Text(label.mtplxLocalized)
.font(.callout)
.foregroundStyle(Brand.typeBody.opacity(0.75))
Spacer(minLength: 8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct MicroHeader: View {
.font(.system(size: 10, weight: .medium))
.foregroundStyle(Brand.typeTertiary)
}
Text(text.uppercased())
Text(text.uppercased().mtplxLocalized)
.font(.system(size: 10, weight: .heavy, design: .monospaced))
.tracking(1.5)
.foregroundStyle(Brand.typeTertiary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct PillBadge: View {
Image(systemName: systemImage)
.font(.caption2)
}
Text(text)
Text(text.mtplxLocalized)
.font(.caption.weight(.medium))
}
.foregroundStyle(emphasized ? tint : .primary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct StatTile: View {
.font(.system(size: 10, weight: .medium))
.foregroundStyle(Brand.typeTertiary)
}
Text(label.uppercased())
Text(label.uppercased().mtplxLocalized)
.font(.system(size: 10, weight: .heavy, design: .monospaced))
.tracking(1.5)
.foregroundStyle(Brand.typeTertiary)
Expand All @@ -48,7 +48,7 @@ struct StatTile: View {
}
}
if let caption {
Text(caption)
Text(caption.mtplxLocalized)
.font(.system(size: 10, weight: .medium, design: .monospaced))
.foregroundStyle(Brand.typeTertiary)
.lineLimit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct FanModeToggle: View {
Button {
apply(value)
} label: {
Text(label)
Text(label.mtplxLocalized)
.font(.system(size: 10, weight: .heavy, design: .monospaced))
.tracking(1)
.foregroundStyle(active == value ? Brand.bgOuter : Brand.textHighlight)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ struct ForgeStageShell<Content: View, Footer: View>: View {

private var header: some View {
VStack(alignment: .leading, spacing: 6) {
Text(title)
Text(title.mtplxLocalized)
.font(.system(.title2, design: .rounded).weight(.semibold))
.foregroundStyle(Brand.typeHi)
if let subtitle, !subtitle.isEmpty {
Text(subtitle)
Text(subtitle.mtplxLocalized)
.font(.system(size: 13))
.foregroundStyle(Brand.typeSecondary)
.fixedSize(horizontal: false, vertical: true)
Expand Down Expand Up @@ -275,6 +275,11 @@ struct ForgeStageShell<Content: View, Footer: View>: View {
private var progressCapsule: some View {
let allCases = ForgeStep.allCases
let stepIndex = allCases.firstIndex(of: step) ?? 0
let stepProgress = String(
format: "Step %d of %d".mtplxLocalized,
stepIndex + 1,
allCases.count
)
return VStack(spacing: 8) {
ZStack(alignment: .leading) {
Capsule()
Expand All @@ -286,12 +291,12 @@ struct ForgeStageShell<Content: View, Footer: View>: View {
.animation(.spring(response: 0.45, dampingFraction: 0.85), value: stepIndex)
}
.accessibilityHidden(true)
Text("\(progressLabel(for: step)) · Step \(stepIndex + 1) of \(allCases.count)")
Text("\(progressLabel(for: step).mtplxLocalized) · \(stepProgress)")
.font(.system(size: 11, weight: .medium, design: .monospaced))
.tracking(0.6)
.foregroundStyle(Brand.typeTertiary)
.contentTransition(.numericText())
.accessibilityLabel("Step \(stepIndex + 1) of \(allCases.count)")
.accessibilityLabel(stepProgress)
}
}

Expand Down Expand Up @@ -335,7 +340,7 @@ struct ForgePrimaryButton: View {
var body: some View {
Button(action: action) {
HStack(spacing: 7) {
Text(title)
Text(title.mtplxLocalized)
.font(.system(size: 13.5, weight: .semibold))
.contentTransition(.opacity)
if let icon {
Expand Down Expand Up @@ -382,7 +387,7 @@ struct ForgePrimaryButton: View {
}
.buttonStyle(.plain)
.disabled(!isEnabled)
.accessibilityLabel(title)
.accessibilityLabel(title.mtplxLocalized)
.onHover { hovering in isHovering = hovering && isEnabled }
.gesture(
DragGesture(minimumDistance: 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct ForgeTabHeader: View {
HStack(spacing: 5) {
Image(systemName: icon)
.font(.system(size: 10.5, weight: .semibold))
Text(label)
Text(label.mtplxLocalized)
.font(.system(size: 11.5, weight: .semibold))
}
.foregroundStyle(isActive ? Brand.typeHi : Brand.typeSecondary)
Expand Down Expand Up @@ -119,7 +119,7 @@ struct ForgeTabHeader: View {
HStack(spacing: 5) {
Image(systemName: isMidBuild ? "arrow.forward" : "plus")
.font(.system(size: 10.5, weight: .heavy))
Text(isMidBuild ? "Continue build" : "New build")
Text((isMidBuild ? "Continue build" : "New build").mtplxLocalized)
.font(.system(size: 11.5, weight: .semibold))
.lineLimit(1)
}
Expand All @@ -133,8 +133,8 @@ struct ForgeTabHeader: View {
.contentShape(Capsule())
}
.buttonStyle(.plain)
.help(isMidBuild
.help((isMidBuild
? "A build is in progress — jump back to it"
: "Start a new build")
: "Start a new build").mtplxLocalized)
}
}
Loading