Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #73 from stuartbreckenridge/i18n
Browse files Browse the repository at this point in the history
Localizes / Internationalizes RSCore to current standards
  • Loading branch information
brentsimmons authored Nov 20, 2023
2 parents cee6d96 + 2a1c168 commit fb18a16
Show file tree
Hide file tree
Showing 6 changed files with 750 additions and 44 deletions.
5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import PackageDescription

let package = Package(
name: "RSCore",
platforms: [.macOS(SupportedPlatform.MacOSVersion.v13), .iOS(SupportedPlatform.IOSVersion.v16)],
defaultLocalization: "en",
platforms: [.macOS(.v13), .iOS(.v16)],
products: [
.library(name: "RSCore", type: .dynamic, targets: ["RSCore"]),
.library(name: "RSCoreResources", type: .static, targets: ["RSCoreResources"])
],
targets: [
.target(
name: "RSCore",
dependencies: []),
dependencies: [], resources: [.process("Resources")]),
.target(
name: "RSCoreResources",
resources: [
Expand Down
10 changes: 6 additions & 4 deletions Sources/RSCore/AppKit/RSAppMovementMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ public class RSAppMovementMonitor: NSObject {
self.appTrackingURL = (Bundle.main.bundleURL as NSURL).fileReferenceURL() as NSURL?
self.originalAppURL = appTrackingURL?.absoluteURL

let appName = Bundle.main.infoDictionary?[kCFBundleNameKey as String] as? String ?? NSLocalizedString("This app", comment: "Backup name if the app name cannot be deduced from the bundle")
let informativeTextTemplate = NSLocalizedString("%@ was moved or renamed while open.", comment: "Message text for app moved while running alert")
let appName = Bundle.main.infoDictionary?[kCFBundleNameKey as String] as? String ?? String(localized: "label.text.this-app", bundle: .module, comment: "Backup name if the app name cannot be deduced from the bundle")
let informativeTextTemplate = String(localized: "label.text.\(appName)-moved-or-renamed", bundle: .module, comment: "<App Name> was moved or renamed while open.")

self.alertMessageText = String(format: informativeTextTemplate, arguments: [appName])
self.alertInformativeText = NSLocalizedString("Moving an open application can cause unexpected behavior. Relaunch the application to continue.", comment: "Informative text for app moved while running alert")
self.alertRelaunchButtonText = NSLocalizedString("Relaunch", comment: "Relaunch Button")
self.alertInformativeText = String(localized: "label.text.moving-open-application-informative-text", bundle: .module, comment: "Informative text for app moved while running alert")

self.alertRelaunchButtonText = String(localized: "label.text.relaunch", bundle: .module, comment: "Relaunch")

super.init()

Expand Down
68 changes: 34 additions & 34 deletions Sources/RSCore/CloudKit/CloudKitError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,73 +25,73 @@ public class CloudKitError: LocalizedError {

switch ckError.code {
case .alreadyShared:
return NSLocalizedString("Already Shared: a record or share cannot be saved because doing so would cause the same hierarchy of records to exist in multiple shares.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.already-shared", bundle: .module, comment: "Already Shared: a record or share cannot be saved because doing so would cause the same hierarchy of records to exist in multiple shares.")
case .assetFileModified:
return NSLocalizedString("Asset File Modified: the content of the specified asset file was modified while being saved.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.asset-file-modified", bundle: .module, comment: "Asset File Modified: the content of the specified asset file was modified while being saved.")
case .assetFileNotFound:
return NSLocalizedString("Asset File Not Found: the specified asset file is not found.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.asset-file-not-found", bundle: .module, comment: "Asset File Not Found: the specified asset file is not found.")
case .badContainer:
return NSLocalizedString("Bad Container: the specified container is unknown or unauthorized.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.bad-container", bundle: .module, comment: "Bad Container: the specified container is unknown or unauthorized.")
case .badDatabase:
return NSLocalizedString("Bad Database: the operation could not be completed on the given database.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.bad-database", bundle: .module, comment: "Bad Database: the operation could not be completed on the given database.")
case .batchRequestFailed:
return NSLocalizedString("Batch Request Failed: the entire batch was rejected.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.batch-request-failed", bundle: .module, comment: "Batch Request Failed: the entire batch was rejected.")
case .changeTokenExpired:
return NSLocalizedString("Change Token Expired: the previous server change token is too old.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.change-token-expired", bundle: .module, comment: "Change Token Expired: the previous server change token is too old.")
case .constraintViolation:
return NSLocalizedString("Constraint Violation: the server rejected the request because of a conflict with a unique field.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.constraint-violation", bundle: .module, comment: "Constraint Violation: the server rejected the request because of a conflict with a unique field.")
case .incompatibleVersion:
return NSLocalizedString("Incompatible Version: your app version is older than the oldest version allowed.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.incompatible-version", bundle: .module, comment: "Incompatible Version: your app version is older than the oldest version allowed.")
case .internalError:
return NSLocalizedString("Internal Error: a nonrecoverable error was encountered by CloudKit.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.internal-error", bundle: .module, comment: "Internal Error: a non-recoverable error was encountered by CloudKit.")
case .invalidArguments:
return NSLocalizedString("Invalid Arguments: the specified request contains bad information.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.invalid-arguments", bundle: .module, comment: "Invalid Arguments: the specified request contains bad information.")
case .limitExceeded:
return NSLocalizedString("Limit Exceeded: the request to the server is too large.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.limit-exceeded", bundle: .module, comment: "Limit Exceeded: the request to the server is too large.")
case .managedAccountRestricted:
return NSLocalizedString("Managed Account Restricted: the request was rejected due to a managed-account restriction.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.managed-account-restriction", bundle: .module, comment: "Managed Account Restricted: the request was rejected due to a managed-account restriction.")
case .missingEntitlement:
return NSLocalizedString("Missing Entitlement: the app is missing a required entitlement.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.missing-entitlement", bundle: .module, comment: "Missing Entitlement: the app is missing a required entitlement.")
case .networkUnavailable:
return NSLocalizedString("Network Unavailable: the internet connection appears to be offline.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.network-unavailable", bundle: .module, comment: "Network Unavailable: the internet connection appears to be offline.")
case .networkFailure:
return NSLocalizedString("Network Failure: the internet connection appears to be offline.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.network-failure", bundle: .module, comment: "Network Failure: the internet connection appears to be offline.")
case .notAuthenticated:
return NSLocalizedString("Not Authenticated: to use the iCloud account, you must enable iCloud Drive. Go to device Settings, sign in to iCloud, then in the app settings, be sure the iCloud Drive feature is enabled.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.not-authenticated", bundle: .module, comment: "Not Authenticated: to use the iCloud account, you must enable iCloud Drive. Go to device Settings, sign in to iCloud, then in the app settings, be sure the iCloud Drive feature is enabled.")
case .operationCancelled:
return NSLocalizedString("Operation Cancelled: the operation was explicitly canceled.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.operation-canceled", bundle: .module, comment: "Operation Canceled: the operation was explicitly canceled.")
case .partialFailure:
return NSLocalizedString("Partial Failure: some items failed, but the operation succeeded overall.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.partial-failure", bundle: .module, comment: "Partial Failure: some items failed, but the operation succeeded overall.")
case .participantMayNeedVerification:
return NSLocalizedString("Participant May Need Verification: you are not a member of the share.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.participant-may-need-verification", bundle: .module, comment: "Participant May Need Verification: you are not a member of the share.")
case .permissionFailure:
return NSLocalizedString("Permission Failure: to use this app, you must enable iCloud Drive. Go to device Settings, sign in to iCloud, then in the app settings, be sure the iCloud Drive feature is enabled.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.permission-failure", bundle: .module, comment: "Permission Failure: to use this app, you must enable iCloud Drive. Go to device Settings, sign in to iCloud, then in the app settings, be sure the iCloud Drive feature is enabled.")
case .quotaExceeded:
return NSLocalizedString("Quota Exceeded: saving would exceed your current iCloud storage quota.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.quota-exceeded", bundle: .module, comment: "Quota Exceeded: saving would exceed your current iCloud storage quota.")
case .referenceViolation:
return NSLocalizedString("Reference Violation: the target of a record's parent or share reference was not found.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.reference-violation", bundle: .module, comment: "Reference Violation: the target of a record's parent or share reference was not found.")
case .requestRateLimited:
return NSLocalizedString("Request Rate Limited: transfers to and from the server are being rate limited at this time.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.request-rate-limited", bundle: .module, comment: "Request Rate Limited: transfers to and from the server are being rate limited at this time.")
case .serverRecordChanged:
return NSLocalizedString("Server Record Changed: the record was rejected because the version on the server is different.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.server-record-changed", bundle: .module, comment: "Server Record Changed: the record was rejected because the version on the server is different.")
case .serverRejectedRequest:
return NSLocalizedString("Server Rejected Request", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.server-rejected-request", bundle: .module, comment: "Server Rejected Request")
case .serverResponseLost:
return NSLocalizedString("Server Response Lost", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.server-response-lost", bundle: .module, comment: "Server Response Lost")
case .serviceUnavailable:
return NSLocalizedString("Service Unavailable: Please try again.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.service-unavailable", bundle: .module, comment: "Service Unavailable: Please try again.")
case .tooManyParticipants:
return NSLocalizedString("Too Many Participants: a share cannot be saved because too many participants are attached to the share.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.too-many-participants", bundle: .module, comment: "Too Many Participants: a share cannot be saved because too many participants are attached to the share.")
case .unknownItem:
return NSLocalizedString("Unknown Item: the specified record does not exist.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.unknown-item", bundle: .module, comment: "Unknown Item: the specified record does not exist.")
case .userDeletedZone:
return NSLocalizedString("User Deleted Zone: the user has deleted this zone from the settings UI.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.user-deleted-zone", bundle: .module, comment: "User Deleted Zone: the user has deleted this zone from the settings UI.")
case .zoneBusy:
return NSLocalizedString("Zone Busy: the server is too busy to handle the zone operation.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.zone-busy", bundle: .module, comment: "Zone Busy: the server is too busy to handle the zone operation.")
case .zoneNotFound:
return NSLocalizedString("Zone Not Found: the specified record zone does not exist on the server.", comment: "Known iCloud Error")
return String(localized: "cloudkit.error.zone-not-found", bundle: .module, comment: "Zone Not Found: the specified record zone does not exist on the server.")
default:
return NSLocalizedString("Unhandled Error.", comment: "Unknown iCloud Error")
return String(localized: "cloudkit.error.unhandled-error", bundle: .module, comment: "Unhandled Error.")
}
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/RSCore/CloudKit/CloudKitZone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public enum CloudKitZoneError: LocalizedError {
public var errorDescription: String? {
switch self {
case .userDeletedZone:
return NSLocalizedString("The iCloud data was deleted. Please remove the application iCloud account and add it again to continue using the application's iCloud support.", comment: "User deleted zone.")
return String(localized: "cloudkit.error.icloud-data-deleted", bundle: .module, comment: "The iCloud data was deleted. Please remove the application iCloud account and add it again to continue using the application's iCloud support.")
case .corruptAccount:
return NSLocalizedString("There is an unrecoverable problem with your application iCloud account. Please make sure you have iCloud and iCloud Drive enabled in System Preferences. Then remove the application iCloud account and add it again.", comment: "Corrupt account.")
return String(localized: "cloudkit.error.corrupt-action", bundle: .module, comment: "There is an unrecoverable problem with your application iCloud account. Please make sure you have iCloud and iCloud Drive enabled in System Preferences. Then remove the application iCloud account and add it again.")
default:
return NSLocalizedString("An unexpected CloudKit error occurred.", comment: "An unexpected CloudKit error occurred.")
return String(localized: "cloudkit.error.unexpected-error", bundle: .module, comment: "An unexpected CloudKit error occurred.")
}
}
}
Expand Down
Loading

0 comments on commit fb18a16

Please sign in to comment.