Skip to content

Commit

Permalink
feat: 🎸 Localize untranslated strings
Browse files Browse the repository at this point in the history
  • Loading branch information
yk4to committed Aug 19, 2023
1 parent 55e3da1 commit 2f1b5d8
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 41 deletions.
8 changes: 4 additions & 4 deletions EjectKey/Commands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension AppModel {
// Succeeded
if Defaults[.sendWhenVolumeIsEjected] {
self.sendNotification(
title: L10n.volWasSuccessfullyEjected(volume.name ?? "Unknown"),
title: L10n.volWasSuccessfullyEjected(volume.name ?? L10n.unknown),
body: device.isVirtual ? L10n.thisVolumeIsAVirtualInterface : L10n.safelyRemoved,
sound: .default,
identifier: UUID().uuidString
Expand All @@ -33,7 +33,7 @@ extension AppModel {
// Failed
if Defaults[.sendWhenVolumeIsEjected] {
self.sendNotification(
title: L10n.failedToEjectVol(volume.name ?? "Unknown"),
title: L10n.failedToEjectVol(volume.name ?? L10n.unknown),
body: error!.localizedDescription,
sound: .defaultCritical,
identifier: UUID().uuidString
Expand Down Expand Up @@ -62,7 +62,7 @@ extension AppModel {
DispatchQueue.main.async {
self.alert(
alertStyle: .warning,
messageText: L10n.theFollowingApplicationsAreUsingVol(volume.name ?? "Unknown"),
messageText: L10n.theFollowingApplicationsAreUsingVol(volume.name ?? L10n.unknown),
informativeText: infoText,
buttonTitle: L10n.quit,
showCancelButton: true,
Expand Down Expand Up @@ -141,7 +141,7 @@ extension AppModel {
DispatchQueue.main.async {
self.sendNotification(
title: L10n.volumeConnected,
body: device.isVirtual ? L10n.volIsAVirtualInterface(volume.name ?? "Unknown") : L10n.volIsAPhysicalDevice(volume.name ?? "Unknown"),
body: device.isVirtual ? L10n.volIsAVirtualInterface(volume.name ?? L10n.unknown) : L10n.volIsAPhysicalDevice(volume.name ?? L10n.unknown),
sound: .default,
identifier: UUID().uuidString
)
Expand Down
6 changes: 3 additions & 3 deletions EjectKey/MenuBar/MenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct MenuView: View {
Menu {
ForEach(device.units.sorted(by: { $0.number < $1.number }), id: \.number) { unit in
if !unit.isApfs {
Text("\(unit.name ?? "Unknown") (\(unit.bsdName))")
Text("\(unit.name ?? L10n.unknown) (\(unit.bsdName))")
Button(L10n.ejectNumVolumes(unit.volumes.count)) {
model.ejectAllVolumeInDisk(unit)
}
Expand All @@ -47,14 +47,14 @@ struct MenuView: View {
}
if showDetailedInformation {
Divider()
Text("Protocol: \(device.deviceProtocol ?? "Unknown")")
Text("\(L10n.connection): \(device.deviceProtocol ?? L10n.unknown)")
}
} label: {
// if showDetailedInformation {
if device.isDiskImage {
Text(L10n.diskImage)
} else {
Text("\(device.vendor ?? "Unknown") \(device.model ?? "Unknown")")
Text("\(device.vendor ?? L10n.unknown) \(device.model ?? L10n.unknown)")
}
/*} else {
let numbersStr = device.units.map({ String($0.number) }).joined(separator: ", ")
Expand Down
20 changes: 10 additions & 10 deletions EjectKey/MenuBar/VolumeList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ struct VolumeList: View {
if showDetailedInformation {
Divider()
Text(volume.type.displayName())
Text("\(L10n.size): \(volume.size?.formatted(.byteCount(style: .file)) ?? "Unknown")")
Text("Physical Store: \(volume.bsdName)")
Text("\(L10n.size): \(volume.size?.formatted(.byteCount(style: .file)) ?? L10n.unknown)")
Text("\(L10n.physicalStores): \(volume.bsdName)")
}
} label: {
Image(systemSymbol: .shippingbox)
Text("APFS Container (\(contentUnit.bsdName))")
Text("\(L10n.container) (\(contentUnit.bsdName))")
}
}
}
Expand All @@ -52,7 +52,7 @@ struct VolumeList: View {
model.eject(volume)
}
} else {
Button("Mount") {
Button(L10n.mount) {
// model.eject(volume)
}
}
Expand All @@ -65,20 +65,20 @@ struct VolumeList: View {
Divider()
Text(volume.type.displayName())
if unit.isApfs {
Text("\(L10n.size): \(volume.size?.formatted(.byteCount(style: .file)) ?? "Unknown") (Shared)")
Text("\(L10n.size): \(volume.size?.formatted(.byteCount(style: .file)) ?? L10n.unknown)\(L10n.shared)")
} else {
Text("\(L10n.size): \(volume.size?.formatted(.byteCount(style: .file)) ?? "Unknown")")
Text("\(L10n.size): \(volume.size?.formatted(.byteCount(style: .file)) ?? L10n.unknown)")
}
Text("ID: \(volume.bsdName)")
Text(volume.isMounted ? "Mounted" : "Not Mounted")
Text("\(L10n.device): \(volume.bsdName)")
Text(volume.isMounted ? L10n.mounted : L10n.notMounted)
}
} label: {
if let icon = volume.icon {
Image(nsImage: icon)
} else {
Image(systemSymbol: .externaldrive)
}
Text(volume.name ?? "Unknown")
Text(volume.name ?? L10n.unknown)
}
}
}
Expand All @@ -91,7 +91,7 @@ struct VolumeList: View {
} else {
Image(systemSymbol: .externaldrive)
}
Text(volume.name ?? "Unknown")
Text(volume.name ?? L10n.unknown)
}
}*/
}
Expand Down
38 changes: 19 additions & 19 deletions EjectKey/Objects/VolumeType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

enum VolumeType {
case efi
case apfsContainer, apfs, apfsSnapshot, apfsCaseSensitive, apfsEncrypted, apfsCaseSensitiveEncrypted
case apfsContainer, apfs, apfsSnapshot, apfsEncrypted, apfsCaseSensitive, apfsCaseSensitiveEncrypted
case hfsPlus, hfsPlusCaseSensitive, hfsPlusJournaled, hfsPlusCaseSensitiveJournaled
case linuxFilesystem, linuxSwap
case windowsBasicData, windowsRecovery
Expand All @@ -29,10 +29,10 @@ enum VolumeType {
case "41504653-0000-11AA-AA11-00306543ECAC":
// APFS
switch type {
case "APFS (Case-sensitive)":
self = .apfsCaseSensitive
case "APFS (Encrypted)":
self = .apfsEncrypted
case "APFS (Case-sensitive)":
self = .apfsCaseSensitive
case "APFS (Case-sensitive, Encrypted)":
self = .apfsCaseSensitiveEncrypted
case nil:
Expand Down Expand Up @@ -78,39 +78,39 @@ enum VolumeType {
case .efi:
return "EFI"
case .apfsContainer:
return "APFS Container"
return L10n.apfsContainer
case .apfs:
return "APFS"
case .apfsSnapshot:
return "APFS Snapshot"
case .apfsCaseSensitive:
return "APFS (Case-sensitive)"
return L10n.apfsSnapshot
case .apfsEncrypted:
return "APFS (Encrypted)"
return L10n.apfsEncrypted
case .apfsCaseSensitive:
return L10n.apfsCaseSensitive
case .apfsCaseSensitiveEncrypted:
return "APFS (Case-sensitive, Encrypted)"
return L10n.apfsCaseSensitiveEncrypted
case .hfsPlus:
return "Mac OS Extended"
return L10n.macOsExtended
case .hfsPlusCaseSensitive:
return "Mac OS Extended (Case-sensitive)"
return L10n.macOsExtendedCaseSensitive
case .hfsPlusJournaled:
return "Mac OS Extended (Journaled)"
return L10n.macOsExtendedJournaled
case .hfsPlusCaseSensitiveJournaled:
return "Mac OS Extended (Case-sensitive, Journaled)"
return L10n.macOsExtendedCaseSensitiveJournaled
case .linuxFilesystem:
return "Linux Filesystem"
return L10n.linuxFilesystem
case .linuxSwap:
return "Linux Swap"
return L10n.linuxSwap
case .windowsBasicData:
return "Windows Basic Data"
return L10n.windowsBasicData
case .windowsRecovery:
return "Windows Recovery"
return L10n.windowsRecovery
case .dosFat32:
return "MS-DOS (FAT32)"
case .partitionMap:
return "Partition Map"
return L10n.partitionMap
case .unknown:
return "Unknown"
return L10n.unknown
}
}
// swiftlint:enable cyclomatic_complexity
Expand Down
2 changes: 1 addition & 1 deletion EjectKey/Settings/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct AboutView: View {
.font(.largeTitle)
Spacer()
.frame(height: 0.4)
Text("\(L10n.version) \(version ?? "unknown") (\(build ?? "unknown"))")
Text("\(L10n.version) \(version ?? L10n.unknown) (\(build ?? L10n.unknown))")
.foregroundColor(Color.secondary)
.textSelection(.enabled)
Spacer()
Expand Down
4 changes: 2 additions & 2 deletions EjectKey/Settings/GeneralView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ struct GeneralView: View {
Section {
Defaults.Toggle(L10n.showEjectAllVolumesButton, key: .showEjectAllVolumesButton)
Defaults.Toggle(L10n.showEjectAllVolumesInDiskButtons, key: .showEjectAllVolumesInDiskButtons)
Defaults.Toggle("Show Internal Volumes", key: .showInternalVolumes)
Defaults.Toggle("Show Unmounted Volumes", key: .showUnmountedVolumes)
Defaults.Toggle(L10n.showInternalVolumes, key: .showInternalVolumes)
Defaults.Toggle(L10n.showUnmountedVolumes, key: .showUnmountedVolumes)
Defaults.Toggle(L10n.showActionMenu, key: .showActionMenu)
Defaults.Toggle(L10n.showDetailedInformation, key: .showDetailedInformation)
}
Expand Down
75 changes: 75 additions & 0 deletions EjectKey/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@
"action_when_button_is_pressed" = "Action when button is pressed";


"apfs_case_sensitive" = "\"APFS (Case-sensitive)\"";


"apfs_case_sensitive_encrypted" = "APFS (Case-sensitive, Encrypted)";


"apfs_container" = "APFS Container";


"apfs_encrypted" = "APFS (Encrypted)";


"apfs_snapshot" = "APFS Snapshot";


"cancel" = "Cancel";


Expand All @@ -27,6 +42,15 @@
"check_prerelease_versions" = "Check prerelease versions";


"connection" = "Connection";


"container" = "Container";


"device" = "Device";


"disk_image" = "Disk Image";


Expand Down Expand Up @@ -78,15 +102,42 @@
"license" = "License";


"linux_filesystem" = "Linux Filesystem";


"linux_swap" = "Linux Swap";


"mac_os_extended" = "Mac OS Extended";


"mac_os_extended_case_sensitive" = "Mac OS Extended (Case-sensitive)";


"mac_os_extended_case_sensitive_journaled" = "Mac OS Extended (Case-sensitive, Journaled)";


"mac_os_extended_journaled" = "Mac OS Extended (Journaled)";


"menu_bar" = "Menu Bar";


"mount" = "Mount";


"mounted" = "Mounted";


"move_to_trash" = "Move to Trash";


"no_external_volume_connected" = "No external volume connected";


"not_mounted" = "Not mounted";


"notifications" = "Notifications";


Expand All @@ -96,6 +147,12 @@
"open_settings" = "Open Settings...";


"partition_map" = "Partition Map";


"physical_stores" = "Physical stores";


"quit" = "Quit";


Expand All @@ -108,6 +165,9 @@
"settings" = "Settings...";


"shared" = " (Shared)";


"shortcuts" = "Shortcuts";


Expand All @@ -129,6 +189,9 @@
"show_in_finder" = "Show in Finder";


"show_internal_volumes" = "Show internal volumes";


"show_move_to_trash_dialog" = "Show \"Move to Trash\" dialog when ejecting a virtual disk image if associated .dmg files exist in the Downloads folder";


Expand All @@ -138,6 +201,9 @@
"show_quit_dialog_when_ejection_fails" = "Show a dialog to quit applications using the volume when ejection fails";


"show_unmounted_volumes" = "Show unmounted volumes";


"size" = "Size";


Expand All @@ -153,6 +219,9 @@
"touch_bar" = "Touch Bar";


"unknown" = "Unknown";


"version" = "Version";


Expand All @@ -172,3 +241,9 @@


"when_volume_is_ejected" = "When volume is ejected";


"windows_basic_data" = "Windows Basic Data";


"windows_recovery" = "Windows Recovery";
Loading

0 comments on commit 2f1b5d8

Please sign in to comment.