Skip to content

Commit

Permalink
Localize more strings (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdmontgomery authored Sep 18, 2024
2 parents 0f51ba2 + 42f66e8 commit 76bf559
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
12 changes: 12 additions & 0 deletions Sources/GravatarUI/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
/* Title of a button that will take you to your Gravatar profile, with an arrow indicating that this action will cause you to leave this view */
"AvatarPickerProfile.Button.ViewProfile.title" = "View profile →";

/* An message that will appear in a small 'toast' message overlaying the current view */
"AvatarPickerViewModel.Toast.Error.message" = "Oops, there was an error uploading the image.";

/* Text on a sample Gravatar profile, appearing in the place where a Gravatar profile would display your short biography. */
"ClaimProfile.Label.AboutMe" = "Tell the world who you are. Your avatar and bio that follows you across the web.";

Expand All @@ -49,6 +52,9 @@
/* Text on a sample Gravatar profile, appearing in the place where a Gravatar profile would display information like location, your preferred pronouns, etc. */
"ClaimProfile.Label.Location" = "Add your location, pronouns, etc";

/* Title of a button that closes the current view */
"GravatarNavigationModifier.Button.Done.title" = "Done";

/* Title for a button that allows you to claim a new Gravatar profile */
"ProfileButton.title.create" = "Claim profile";

Expand All @@ -58,3 +64,9 @@
/* Title for a button that allows you to view your Gravatar profile */
"ProfileButton.title.view" = "View profile";

/* An option in a menu that will display the camera for taking a picture */
"SystemImagePickerView.Source.Camera.title" = "Take a Photo";

/* An option in a menu that display the user's Photo Library and allow them to choose a photo from it */
"SystemImagePickerView.Source.PhotoLibrary.title" = "Choose a Photo";

Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class AvatarPickerViewModel: ObservableObject {
} catch {
let newModel = AvatarImageModel(id: localID, source: .local(image: squareImage), uploadHasFailed: true)
grid.replaceModel(withID: localID, with: newModel)
toastManager.showToast("Oops, there was an error uploading the image.", type: .error)
toastManager.showToast(Localized.toastError, type: .error)
}
}

Expand Down Expand Up @@ -226,6 +226,16 @@ class AvatarPickerViewModel: ObservableObject {
}
}

extension AvatarPickerViewModel {
private enum Localized {
static let toastError = SDKLocalizedString(
"AvatarPickerViewModel.Toast.Error.message",
value: "Oops, there was an error uploading the image.",
comment: "An message that will appear in a small 'toast' message overlaying the current view"
)
}
}

extension Result<[AvatarImageModel], Error> {
func isEmpty() -> Bool {
switch self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,17 @@ extension ImagePicker.SourceType {
var localizedTitle: String {
switch self {
case .photoLibrary:
"Chose a Photo"
SDKLocalizedString(
"SystemImagePickerView.Source.PhotoLibrary.title",
value: "Choose a Photo",
comment: "An option in a menu that display the user's Photo Library and allow them to choose a photo from it"
)
case .camera:
"Take Photo"
SDKLocalizedString(
"SystemImagePickerView.Source.Camera.title",
value: "Take a Photo",
comment: "An option in a menu that will display the camera for taking a picture"
)
}
}

Expand Down
12 changes: 11 additions & 1 deletion Sources/GravatarUI/SwiftUI/GravatarNavigationModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct GravatarNavigationModifier: ViewModifier {
Button(action: {
onDoneButtonPressed?()
}) {
Text("Done")
Text(Localized.doneButtonTitle)
.tint(Color(UIColor.gravatarBlue))
}
}
Expand All @@ -45,6 +45,16 @@ struct GravatarNavigationModifier: ViewModifier {
}
}

extension GravatarNavigationModifier {
private enum Localized {
static let doneButtonTitle = SDKLocalizedString(
"GravatarNavigationModifier.Button.Done.title",
value: "Done",
comment: "Title of a button that closes the current view"
)
}
}

extension View {
func gravatarNavigation(
title: String,
Expand Down

0 comments on commit 76bf559

Please sign in to comment.