Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline: Localize OfflineMapAreasView #882

Draft
wants to merge 3 commits into
base: OfflineMapAreasView
Choose a base branch
from
Draft
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
58 changes: 52 additions & 6 deletions Sources/ArcGISToolkit/Components/Offline/OfflineMapAreasView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ public struct OfflineMapAreasView: View {
}
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("Done") { dismiss() }
Button {
dismiss()
} label: {
Text.done
}
}
}
.navigationTitle("Map Areas")
.navigationTitle(mapAreasLabel)
.navigationBarTitleDisplayMode(.inline)
}
.refreshable {
Expand Down Expand Up @@ -100,9 +104,9 @@ public struct OfflineMapAreasView: View {

@ViewBuilder private var emptyPreplannedMapAreasView: some View {
VStack(alignment: .center) {
Text("No map areas")
Text(noMapAreasTitleLabel)
.bold()
Text("You don't have any map areas yet.")
Text(noMapAreasSubtitleLabel)
.font(.subheadline)
.foregroundStyle(.secondary)
}
Expand All @@ -111,9 +115,9 @@ public struct OfflineMapAreasView: View {

private var offlineDisabledView: some View {
VStack(alignment: .center) {
Text("Offline disabled")
Text(offlineDisabledTitleLabel)
.bold()
Text("Please ensure the web map is offline enabled.")
Text(offlineDisabledSubtitleLabel)
.font(.subheadline)
.foregroundStyle(.secondary)
}
Expand All @@ -140,3 +144,45 @@ public struct OfflineMapAreasView: View {
}
return OfflineMapAreasViewPreview()
}

private extension OfflineMapAreasView {
var mapAreasLabel: String {
.init(
localized: "Map Areas",
bundle: .toolkitModule,
comment: "A label for the map areas view."
)
}

var noMapAreasTitleLabel: String {
.init(
localized: "No map areas",
bundle: .toolkitModule,
comment: "A label indicating that the map has no map areas."
)
}

var noMapAreasSubtitleLabel: String {
.init(
localized: "You don't have any map areas yet.",
bundle: .toolkitModule,
comment: "A label indicating that the map has no map areas yet. "
)
}

var offlineDisabledTitleLabel: String {
.init(
localized: "Offline disabled",
bundle: .toolkitModule,
comment: "A label indicating that the web map is offline disabled."
)
}

var offlineDisabledSubtitleLabel: String {
.init(
localized: "Please ensure the web map is offline enabled.",
bundle: .toolkitModule,
comment: "A label indicating that the user should check that the web map is offline enabled."
)
}
}
112 changes: 101 additions & 11 deletions Sources/ArcGISToolkit/Components/Offline/PreplannedListItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct PreplannedListItemView: View {
@ViewBuilder private var deleteButton: some View {
if model.status.allowsRemoval,
!isSelected {
Button("Delete") {
Button(deleteLabel) {
model.removeDownloadedPreplannedMapArea()
}
.tint(.red)
Expand All @@ -100,7 +100,7 @@ struct PreplannedListItemView: View {
}
}
} label: {
Text("Open")
Text(openLabel)
.font(.footnote)
.fontWeight(.bold)
}
Expand Down Expand Up @@ -134,7 +134,7 @@ struct PreplannedListItemView: View {
.foregroundStyle(.secondary)
.lineLimit(2)
} else {
Text("This area has no description.")
Text(noDescriptionLabel)
.font(.footnote)
.foregroundStyle(.tertiary)
}
Expand All @@ -144,25 +144,25 @@ struct PreplannedListItemView: View {
HStack(spacing: 4) {
switch model.status {
case .notLoaded, .loading:
Text("Loading")
Text(loadingLabel)
case .loadFailure, .mmpkLoadFailure:
Image(systemName: "exclamationmark.circle")
Text("Loading failed")
Text(loadingFailedLabel)
case .packaging:
Image(systemName: "clock.badge.xmark")
Text("Packaging")
Text(packagingLabel)
case .packaged:
Text("Package ready for download")
Text(packagedLabel)
case .packageFailure:
Image(systemName: "exclamationmark.circle")
Text("Packaging failed")
Text(packageFailureLabel)
case .downloading:
Text("Downloading")
Text(downloadingLabel)
case .downloaded:
Text("Downloaded")
Text(downloadedLabel)
case .downloadFailure:
Image(systemName: "exclamationmark.circle")
Text("Download failed")
Text(downloadFailureLabel)
}
}
.font(.caption2)
Expand Down Expand Up @@ -194,3 +194,93 @@ struct PreplannedListItemView: View {
)
.padding()
}

private extension PreplannedListItemView {
var openLabel: String {
.init(
localized: "Open",
bundle: .toolkitModule,
comment: "A label for a button to open the map area."
)
}

var deleteLabel: String {
.init(
localized: "Delete",
bundle: .toolkitModule,
comment: "A label for a button to delete the map area."
)
}

var noDescriptionLabel: String {
.init(
localized: "This area has no description.",
bundle: .toolkitModule,
comment: "A label indicating that the map area has no description."
)
}

var loadingLabel: String {
.init(
localized: "Loading",
bundle: .toolkitModule,
comment: "A status message indicating that the map area is loading."
)
}

var loadingFailedLabel: String {
.init(
localized: "Loading failed",
bundle: .toolkitModule,
comment: "A status message indicating that the map area failed to load."
)
}

var packagingLabel: String {
.init(
localized: "Packaging",
bundle: .toolkitModule,
comment: "A status message indicating that the map area is packaging."
)
}

var packagedLabel: String {
.init(
localized: "Package ready for download",
bundle: .toolkitModule,
comment: "A status message indicating that the map area is packaged."
)
}

var packageFailureLabel: String {
.init(
localized: "Packaging failed",
bundle: .toolkitModule,
comment: "A status message indicating that the map area packaging failed."
)
}

var downloadingLabel: String {
.init(
localized: "Downloading",
bundle: .toolkitModule,
comment: "A status message indicating that the map area mobile map package is downloading."
)
}

var downloadedLabel: String {
.init(
localized: "Downloaded",
bundle: .toolkitModule,
comment: "A status message indicating that the map area mobile map package is downloaded."
)
}

var downloadFailureLabel: String {
.init(
localized: "Download failed",
bundle: .toolkitModule,
comment: "A status message indicating that the map area mobile map package download failed."
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ struct PreplannedMetadataView: View {
}
}
VStack(alignment: .leading) {
Text("Name")
Text(nameLabel)
.font(.caption)
.foregroundStyle(.secondary)
Text(model.preplannedMapArea.title)
.font(.subheadline)
}
VStack(alignment: .leading) {
Text("Description")
Text(descriptionLabel)
.font(.caption)
.foregroundStyle(.secondary)
if model.preplannedMapArea.description.isEmpty {
Text("This area has no description.")
Text(noDescriptionLabel)
.font(.subheadline)
.foregroundStyle(.tertiary)
} else {
Expand All @@ -58,7 +58,7 @@ struct PreplannedMetadataView: View {
}
}
VStack(alignment: .leading) {
Text("Size")
Text(sizeLabel)
.font(.caption)
.foregroundStyle(.secondary)
Text(Int64(model.directorySize), format: .byteCount(style: .file, allowedUnits: [.kb, .mb]))
Expand All @@ -72,7 +72,7 @@ struct PreplannedMetadataView: View {
.symbolRenderingMode(.palette)
.foregroundStyle(.red, .gray.opacity(0.1))
.font(.title)
Button("Delete Map Area", role: .destructive) {
Button(deleteLabel, role: .destructive) {
dismiss()
model.removeDownloadedPreplannedMapArea()
}
Expand All @@ -84,7 +84,11 @@ struct PreplannedMetadataView: View {
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("Done") { dismiss() }
Button {
dismiss()
} label: {
Text.done
}
}
}
}
Expand Down Expand Up @@ -113,3 +117,45 @@ struct PreplannedMetadataView: View {
isSelected: false
)
}

private extension PreplannedMetadataView {
var nameLabel: String {
.init(
localized: "Name",
bundle: .toolkitModule,
comment: "A label for the name of the map area."
)
}

var descriptionLabel: String {
.init(
localized: "Description",
bundle: .toolkitModule,
comment: "A label for the description of the map area."
)
}

var noDescriptionLabel: String {
.init(
localized: "This area has no description.",
bundle: .toolkitModule,
comment: "A label indicating that the map area has no description."
)
}

var sizeLabel: String {
.init(
localized: "Size",
bundle: .toolkitModule,
comment: "A label for the file size of the map area."
)
}

var deleteLabel: String {
.init(
localized: "Delete Map Area",
bundle: .toolkitModule,
comment: "A label for the button to delete a map area."
)
}
}