Skip to content

Commit

Permalink
Add localizsable keys for notification titles
Browse files Browse the repository at this point in the history
  • Loading branch information
daneden committed Oct 1, 2023
1 parent 97afd44 commit df925fb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
24 changes: 24 additions & 0 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,9 @@
}
}
},
"December Solstice Today" : {
"comment" : "Notification title for December solstice"
},
"Delete Location" : {
"localizations" : {
"it" : {
Expand Down Expand Up @@ -806,6 +809,15 @@
}
}
},
"Good Afternoon" : {
"comment" : "Notification title for afternoon notification"
},
"Good Evening" : {
"comment" : "Notification title for evening notification"
},
"Good Morning" : {
"comment" : "Notification title for morning notification"
},
"Graphical" : {
"localizations" : {
"it" : {
Expand Down Expand Up @@ -856,6 +868,9 @@
}
}
},
"June Solstice Today" : {
"comment" : "Notification title for June solstice"
},
"Learn more about the equinox and solstice" : {
"localizations" : {
"it" : {
Expand Down Expand Up @@ -987,6 +1002,9 @@
}
}
},
"March Equinox Today" : {
"comment" : "Notification title for March equinox"
},
"more" : {
"comment" : "More daylight middle of sentence",
"localizations" : {
Expand Down Expand Up @@ -1412,6 +1430,9 @@
}
}
},
"September Equinox Today" : {
"comment" : "Notification title for September equinox"
},
"Set Up Location Access" : {
"localizations" : {
"it" : {
Expand Down Expand Up @@ -1732,6 +1753,9 @@
}
}
},
"Today’s Daylight" : {
"comment" : "Notification title fallback"
},
"Tomorrow" : {
"localizations" : {
"it" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = "it"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
16 changes: 8 additions & 8 deletions Solstice/Helpers/NotificationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,24 @@ class NotificationManager: NSObject, UNUserNotificationCenterDelegate, Observabl
let septemberEquinox = SolsticeCalculator.septemberEquinox(year: year)

if calendar.isDate(date, inSameDayAs: marchEquinox) {
content.title = "March Equinox Today"
content.title = NSLocalizedString("March Equinox Today", comment: "Notification title for March equinox")
} else if calendar.isDate(date, inSameDayAs: septemberEquinox) {
content.title = "September Equinox Today"
content.title = NSLocalizedString("September Equinox Today", comment: "Notification title for September equinox")
} else if calendar.isDate(date, inSameDayAs: juneSolstice) {
content.title = "June Solstice Today"
content.title = NSLocalizedString("June Solstice Today", comment: "Notification title for June solstice")
} else if calendar.isDate(date, inSameDayAs: decemberSolstice) {
content.title = "December Solstice Today"
content.title = NSLocalizedString("December Solstice Today", comment: "Notification title for December solstice")
} else {
let components = calendar.dateComponents([.hour], from: date)
let hour = components.hour ?? 0
if hour >= 18 || hour < 3 {
content.title = "Good Evening"
content.title = NSLocalizedString("Good Evening", comment: "Notification title for evening notification")
} else if hour >= 3 && hour < 12 {
content.title = "Good Morning"
content.title = NSLocalizedString("Good Morning", comment: "Notification title for morning notification")
} else if hour >= 12 && hour < 18 {
content.title = "Good Afternoon"
content.title = NSLocalizedString("Good Afternoon", comment: "Notification title for afternoon notification")
} else {
content.title = "Today’s Daylight"
content.title = NSLocalizedString("Today’s Daylight", comment: "Notification title fallback")
}
}

Expand Down

0 comments on commit df925fb

Please sign in to comment.