Fix string detection issues and complete pt-BR localization (100% done, as far as I can tell)

This commit is contained in:
Felipe Giacomini Cocco 2026-02-05 22:55:25 -03:00
commit f6f6321def
14 changed files with 402 additions and 77 deletions

View file

@ -456,16 +456,16 @@ struct ClipboardPanelItemRow: View {
let interval = Date().timeIntervalSince(date)
if interval < 60 {
return "Just now"
return String(localized: "Just now")
} else if interval < 3600 {
let minutes = Int(interval / 60)
return "\(minutes)m ago"
return String(localized: "\(minutes)m ago")
} else if interval < 86400 {
let hours = Int(interval / 3600)
return "\(hours)h ago"
return String(localized: "\(hours)h ago")
} else {
let days = Int(interval / 86400)
return "\(days)d ago"
return String(localized: "\(days)d ago")
}
}
}

View file

@ -28,6 +28,13 @@ enum ClipboardTab: String, CaseIterable {
case .favorites: return "heart.fill"
}
}
var localizedName: String {
switch self {
case .history: return String(localized: "History")
case .favorites: return String(localized: "Favorites")
}
}
}
struct ClipboardTabButton: View {
@ -51,7 +58,7 @@ struct ClipboardTabButton: View {
Image(systemName: tab.icon)
.font(.system(size: 11))
Text(tab.rawValue)
Text(tab.localizedName)
.font(.system(size: 11, weight: .medium))
if itemCount > 0 {

View file

@ -530,16 +530,16 @@ struct ColorListRow: View {
let interval = Date().timeIntervalSince(date)
if interval < 60 {
return "Just now"
return String(localized: "Just now")
} else if interval < 3600 {
let minutes = Int(interval / 60)
return "\(minutes)m ago"
return String(localized: "\(minutes)m ago")
} else if interval < 86400 {
let hours = Int(interval / 3600)
return "\(hours)h ago"
return String(localized: "\(hours)h ago")
} else {
let days = Int(interval / 86400)
return "\(days)d ago"
return String(localized: "\(days)d ago")
}
}
}
@ -589,16 +589,16 @@ struct ColorDetailsView: View {
let interval = Date().timeIntervalSince(date)
if interval < 60 {
return "just now"
return String(localized: "just now")
} else if interval < 3600 {
let minutes = Int(interval / 60)
return "\(minutes) minute\(minutes == 1 ? "" : "s") ago"
return String(localized: "\(minutes) minute\(minutes == 1 ? "" : "s") ago")
} else if interval < 86400 {
let hours = Int(interval / 3600)
return "\(hours) hour\(hours == 1 ? "" : "s") ago"
return String(localized: "\(hours) hour\(hours == 1 ? "" : "s") ago")
} else {
let days = Int(interval / 86400)
return "\(days) day\(days == 1 ? "" : "s") ago"
return String(localized: "\(days) day\(days == 1 ? "" : "s") ago")
}
}
}

View file

@ -432,17 +432,17 @@ struct InlineHUD: View {
func Type2Name(_ type: SneakContentType) -> String {
switch(type) {
case .volume:
return "Volume"
return String(localized: "Volume")
case .brightness:
return "Brightness"
return String(localized: "Brightness")
case .backlight:
return "Backlight"
return String(localized: "Backlight")
case .mic:
return "Mic"
return String(localized: "Mic")
case .bluetoothAudio:
return BluetoothAudioManager.shared.lastConnectedDevice?.name ?? "Bluetooth"
case .capsLock:
return "Caps Lock"
return String(localized: "Caps Lock")
default:
return ""
}

View file

@ -193,16 +193,16 @@ struct ClipboardItemRow: View {
let interval = Date().timeIntervalSince(date)
if interval < 60 {
return "Just now"
return String(localized: "Just now")
} else if interval < 3600 {
let minutes = Int(interval / 60)
return "\(minutes)m ago"
return String(localized: "\(minutes)m ago")
} else if interval < 86400 {
let hours = Int(interval / 3600)
return "\(hours)h ago"
return String(localized: "\(hours)h ago")
} else {
let days = Int(interval / 86400)
return "\(days)d ago"
return String(localized: "\(days)d ago")
}
}
}

View file

@ -288,16 +288,16 @@ struct ColorInfoPopup: View {
let interval = Date().timeIntervalSince(date)
if interval < 60 {
return "Just now"
return String(localized: "Just now")
} else if interval < 3600 {
let minutes = Int(interval / 60)
return "\(minutes)m ago"
return String(localized: "\(minutes)m ago")
} else if interval < 86400 {
let hours = Int(interval / 3600)
return "\(hours)h ago"
return String(localized: "\(hours)h ago")
} else {
let days = Int(interval / 86400)
return "\(days)d ago"
return String(localized: "\(days)d ago")
}
}
}

View file

@ -527,9 +527,9 @@ struct NotchClipboardItemRow: View {
private func timeAgoString(from date: Date) -> String {
let interval = Date().timeIntervalSince(date)
if interval < 60 { return "Just now" }
if interval < 3600 { return "\(Int(interval/60))m" }
return "\(Int(interval/3600))h"
if interval < 60 { return String(localized: "Just now") }
if interval < 3600 { return String(localized: "\(Int(interval/60))m") }
return String(localized: "\(Int(interval/3600))h")
}
}
@ -936,9 +936,9 @@ struct NoteRow: View {
private func timeAgoString(from date: Date) -> String {
let interval = Date().timeIntervalSince(date)
if interval < 60 { return "Just now" }
if interval < 3600 { return "\(Int(interval/60))m" }
if interval < 86400 { return "\(Int(interval/3600))h" }
if interval < 60 { return String(localized: "Just now") }
if interval < 3600 { return String(localized: "\(Int(interval/60))m") }
if interval < 86400 { return String(localized: "\(Int(interval/3600))h") }
return date.formatted(.dateTime.day().month())
}
}

View file

@ -82,7 +82,7 @@ struct NotchStatsView: View {
if showCpuGraph {
graphs.append(SingleGraphData(
title: "CPU",
title: String(localized: "CPU"),
value: statsManager.cpuUsageString,
data: statsManager.cpuHistory,
color: .blue,
@ -92,7 +92,7 @@ struct NotchStatsView: View {
if showMemoryGraph {
graphs.append(SingleGraphData(
title: "Memory",
title: String(localized: "Memory"),
value: statsManager.memoryUsageString,
data: statsManager.memoryHistory,
color: .green,
@ -102,7 +102,7 @@ struct NotchStatsView: View {
if showGpuGraph {
graphs.append(SingleGraphData(
title: "GPU",
title: String(localized: "GPU"),
value: statsManager.gpuUsageString,
data: statsManager.gpuHistory,
color: .purple,
@ -112,7 +112,7 @@ struct NotchStatsView: View {
if showNetworkGraph {
graphs.append(DualGraphData(
title: "Network",
title: String(localized: "Network"),
positiveValue: "↓" + statsManager.networkDownloadString,
negativeValue: "↑" + statsManager.networkUploadString,
positiveData: statsManager.networkDownloadHistory,
@ -126,9 +126,9 @@ struct NotchStatsView: View {
if showDiskGraph {
graphs.append(DualGraphData(
title: "Disk",
positiveValue: "R " + statsManager.diskReadString,
negativeValue: "W " + statsManager.diskWriteString,
title: String(localized: "Disk"),
positiveValue: String(localized: "R ") + statsManager.diskReadString,
negativeValue: String(localized: "W ") + statsManager.diskWriteString,
positiveData: statsManager.diskReadHistory,
negativeData: statsManager.diskWriteHistory,
positiveColor: .cyan,

View file

@ -461,7 +461,7 @@ struct NotchTimerView: View {
private var startButton: some View {
Button {
withAnimation(.smooth) {
timerManager.startTimer(duration: customDurationInSeconds, name: "Custom Timer")
timerManager.startTimer(duration: customDurationInSeconds, name: String(localized: "Custom Timer"))
if !enableMinimalisticUI {
coordinator.currentView = .timer
}

View file

@ -2427,13 +2427,13 @@ private struct DevicesSettingsView: View {
var body: some View {
Form {
Section {
Defaults.Toggle("Show Bluetooth device connections", key: .showBluetoothDeviceConnections)
Defaults.Toggle(String(localized: "Show Bluetooth device connections"), key: .showBluetoothDeviceConnections)
.settingsHighlight(id: highlightID("Show Bluetooth device connections"))
Defaults.Toggle("Use circular battery indicator", key: .useCircularBluetoothBatteryIndicator)
Defaults.Toggle(String(localized: "Use circular battery indicator"), key: .useCircularBluetoothBatteryIndicator)
.settingsHighlight(id: highlightID("Use circular battery indicator"))
Defaults.Toggle("Show battery percentage text in HUD", key: .showBluetoothBatteryPercentageText)
Defaults.Toggle(String(localized: "Show battery percentage text in HUD"), key: .showBluetoothBatteryPercentageText)
.settingsHighlight(id: highlightID("Show battery percentage text in HUD"))
Defaults.Toggle("Scroll device name in HUD", key: .showBluetoothDeviceNameMarquee)
Defaults.Toggle(String(localized: "Scroll device name in HUD"), key: .showBluetoothDeviceNameMarquee)
.settingsHighlight(id: highlightID("Scroll device name in HUD"))
} header: {
Text("Bluetooth Audio Devices")
@ -2444,7 +2444,7 @@ private struct DevicesSettingsView: View {
}
Section {
Defaults.Toggle("Color-coded battery display", key: .useColorCodedBatteryDisplay)
Defaults.Toggle(String(localized: "Color-coded battery display"), key: .useColorCodedBatteryDisplay)
.disabled(colorCodingDisabled)
.settingsHighlight(id: highlightID("Color-coded battery display"))
} header: {
@ -2643,7 +2643,7 @@ struct Media: View {
Section {
Picker("Music Source", selection: $mediaController) {
ForEach(availableMediaControllers) { controller in
Text(controller.rawValue).tag(controller)
Text(controller.localizedName).tag(controller)
}
}
.onChange(of: mediaController) { _, _ in
@ -2672,7 +2672,7 @@ struct Media: View {
}
}
Section {
Defaults.Toggle("Show media controls in Dynamic Island", key: .showStandardMediaControls)
Defaults.Toggle(String(localized: "Show media controls in Dynamic Island"), key: .showStandardMediaControls)
.disabled(enableMinimalisticUI)
.settingsHighlight(id: highlightID("Show media controls in Dynamic Island"))
@ -2696,7 +2696,7 @@ struct Media: View {
}
}
if showShuffleAndRepeat {
Defaults.Toggle("Show \"Change Media Output\" control", key: .showMediaOutputControl)
Defaults.Toggle(String(localized: "Show \"Change Media Output\" control"), key: .showMediaOutputControl)
.settingsHighlight(id: highlightID("Show Change Media Output control"))
.help("Adds the AirPlay/route picker button back to the customizable controls palette.")
MusicSlotConfigurationView()
@ -2711,7 +2711,7 @@ struct Media: View {
}
Section(header: Text("Lock Screen Media")) {
Defaults.Toggle("Enable album art parallax", key: .lockScreenMusicAlbumParallaxEnabled)
Defaults.Toggle(String(localized: "Enable album art parallax"), key: .lockScreenMusicAlbumParallaxEnabled)
.settingsHighlight(id: highlightID("Enable album art parallax"))
Text("Applies the notch-style parallax effect to the lock screen media widget album art.")
.font(.caption)
@ -2741,18 +2741,16 @@ struct Media: View {
)
.disabled(standardControlsSuppressed)
.help(standardControlsSuppressed ? "Standard notch media controls are hidden while this toggle is off." : "")
Defaults.Toggle(
"Show floating media controls",
key: .musicControlWindowEnabled
)
Defaults.Toggle(String(localized: "Show floating media controls"),
key: .musicControlWindowEnabled)
.disabled(!coordinator.musicLiveActivityEnabled || standardControlsSuppressed)
.help("Displays play/pause and skip buttons beside the notch while music is active. Disabled by default.")
Toggle("Enable sneak peek", isOn: $enableSneakPeek)
Toggle("Show sneak peek on playback changes", isOn: $showSneakPeekOnTrackChange)
.disabled(!enableSneakPeek)
Defaults.Toggle("Enable lyrics", key: .enableLyrics)
Defaults.Toggle(String(localized: "Enable lyrics"), key: .enableLyrics)
.settingsHighlight(id: highlightID("Enable lyrics"))
Defaults.Toggle("Enable album art parallax effect", key: .enableParallaxEffect)
Defaults.Toggle(String(localized: "Enable album art parallax effect"), key: .enableParallaxEffect)
.settingsHighlight(id: highlightID("Enable album art parallax effect"))
Picker("Sneak Peek Style", selection: $sneakPeekStyles){
ForEach(SneakPeekStyle.allCases) { style in
@ -2789,10 +2787,10 @@ struct Media: View {
}
Section {
Defaults.Toggle("Show lock screen media panel", key: .enableLockScreenMediaWidget)
Defaults.Toggle("Show media app icon", key: .lockScreenShowAppIcon)
Defaults.Toggle(String(localized: "Show lock screen media panel"), key: .enableLockScreenMediaWidget)
Defaults.Toggle(String(localized: "Show media app icon"), key: .lockScreenShowAppIcon)
.disabled(!enableLockScreenMediaWidget)
Defaults.Toggle("Show panel border", key: .lockScreenPanelShowsBorder)
Defaults.Toggle(String(localized: "Show panel border"), key: .lockScreenPanelShowsBorder)
.disabled(!enableLockScreenMediaWidget)
if lockScreenGlassCustomizationMode == .customLiquid {
customLiquidBlurRow
@ -6346,7 +6344,7 @@ struct ScreenAssistantSettings: View {
}
}
.pickerStyle(.menu)
.frame(width: 100)
.frame(width: 150)
}
.settingsHighlight(id: highlightID("Display Mode"))
@ -6473,7 +6471,7 @@ struct ColorPickerSettings: View {
}
}
.pickerStyle(.menu)
.frame(width: 100)
.frame(width: 150)
}
.settingsHighlight(id: highlightID("Display Mode"))
@ -6487,7 +6485,7 @@ struct ColorPickerSettings: View {
Text("20 colors").tag(20)
}
.pickerStyle(.menu)
.frame(width: 100)
.frame(width: 150)
}
.settingsHighlight(id: highlightID("History Size"))

View file

@ -100,7 +100,7 @@ struct TimerPopover: View {
let duration = customDurationInSeconds
guard duration > 0 else { return }
withAnimation(.smooth) {
timerManager.startTimer(duration: duration, name: "Custom Timer")
timerManager.startTimer(duration: duration, name: String(localized: "Custom Timer"))
}
dismiss()
}