Skip to content

Commit 5abd19b

Browse files
committed
Add more localization
1 parent f944bb1 commit 5abd19b

File tree

6 files changed

+1696
-1432
lines changed

6 files changed

+1696
-1432
lines changed

LongevityMaster/Components/Habits/HabitForm.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class HabitFormViewModel: HashableObject {
1919

2020
var todayHabit: TodayDraftHabit {
2121
let frequencyDescription: String? = switch habit.frequency {
22-
case .nDaysEachWeek: "1/\(habit.nDaysPerWeek) this week"
23-
case .nDaysEachMonth: "1/\(habit.nDaysPerMonth) this month"
22+
case .nDaysEachWeek: String(localized: "1/\(habit.nDaysPerWeek) this week")
23+
case .nDaysEachMonth: String(localized: "1/\(habit.nDaysPerMonth) this month")
2424
default: nil
2525
}
2626
return habit.toTodayDraftHabit(
27-
streakDescription: "🔥 1d streak",
27+
streakDescription: String(localized: "🔥 1d streak"),
2828
frequencyDescription: frequencyDescription
2929
)
3030
}

LongevityMaster/Components/Me/MeFeature.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct MeView: View {
1919
@FetchAll(Reminder.all, animation: .default) var allReminders
2020
@ObservationIgnored
2121
@FetchAll(Achievement.all, animation: .default) var allAchievements
22-
@AppStorage("userName") private var userName: String = "Your Name"
22+
@AppStorage("userName") private var userName: String = String(localized: "Your Name")
2323
@AppStorage("userAvatar") private var userAvatar: String = "😀"
2424
@State private var showPurchaseSheet = false
2525
@State private var showEmojiPicker = false
@@ -58,13 +58,13 @@ struct MeView: View {
5858
}
5959
// Stats Section
6060
HStack(spacing: AppSpacing.small) {
61-
statView(title: "Habits", value: "\(allHabits.filter { !$0.isArchived }.count)/\(allHabits.count)")
61+
statView(title: String(localized: "Habits"), value: "\(allHabits.filter { !$0.isArchived }.count)/\(allHabits.count)")
6262
Divider()
63-
statView(title: "Check-ins", value: "\(allCheckIns.count)")
63+
statView(title: String(localized: "Check-ins"), value: "\(allCheckIns.count)")
6464
Divider()
65-
statView(title: "Reminders", value: "\(allReminders.count)")
65+
statView(title: String(localized: "Reminders"), value: "\(allReminders.count)")
6666
Divider()
67-
statView(title: "Achievements", value: "\(allAchievements.filter { $0.isUnlocked }.count)/\(allAchievements.count)")
67+
statView(title: String(localized: "Achievements"), value: "\(allAchievements.filter { $0.isUnlocked }.count)/\(allAchievements.count)")
6868
}
6969
.padding(.top, AppSpacing.small)
7070
if !purchaseManager.isPremiumUserPurchased {
@@ -160,24 +160,24 @@ struct MeView: View {
160160
.appSectionHeader(theme: themeManager.current)
161161
LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 3), spacing: AppSpacing.large) {
162162
NavigationLink(destination: MoreAppsView()) {
163-
moreItem(icon: "storefront", title: "More Apps")
163+
moreItem(icon: "storefront", title: String(localized: "More Apps"))
164164
}
165165
if let url = URL(string: "https://itunes.apple.com/app/id\(Constants.AppID.longevityMasterID)?action=write-review") {
166166
Button {
167167
openURL(url)
168168
} label: {
169-
moreItem(icon: "star.fill", title: "Rate Us")
169+
moreItem(icon: "star.fill", title: String(localized: "Rate Us"))
170170
}
171171
}
172172
Button {
173173
let email = SupportEmail()
174174
email.send(openURL: openURL)
175175
} label: {
176-
moreItem(icon: "envelope.fill", title: "Feedback")
176+
moreItem(icon: "envelope.fill", title: String(localized: "Feedback"))
177177
}
178178
if let appURL = URL(string: "https://itunes.apple.com/app/id\(Constants.AppID.longevityMasterID)") {
179179
ShareLink(item: appURL) {
180-
moreItem(icon: "square.and.arrow.up", title: "Share App")
180+
moreItem(icon: "square.and.arrow.up", title: String(localized: "Share App"))
181181
}
182182
}
183183
}
@@ -191,19 +191,19 @@ struct MeView: View {
191191
.appSectionHeader(theme: themeManager.current)
192192
LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 3), spacing: AppSpacing.large) {
193193
NavigationLink(destination: SettingView()) {
194-
featureItem(icon: "gear", title: "Settings")
194+
featureItem(icon: "gear", title: String(localized: "Settings"))
195195
}
196196
NavigationLink(destination: CheckInHistoryView()) {
197-
featureItem(icon: "clock", title: "Checkin History")
197+
featureItem(icon: "clock", title: String(localized: "Checkin History"))
198198
}
199199
NavigationLink(destination: RemindersView()) {
200-
featureItem(icon: "bell", title: "Reminders")
200+
featureItem(icon: "bell", title: String(localized: "Reminders"))
201201
}
202202
NavigationLink(destination: AchievementsView()) {
203-
featureItem(icon: "trophy", title: "Achievements")
203+
featureItem(icon: "trophy", title: String(localized: "Achievements"))
204204
}
205205
NavigationLink(destination: ThemeColorView()) {
206-
featureItem(icon: "paintbrush.fill", title: "Theme Color")
206+
featureItem(icon: "paintbrush.fill", title: String(localized: "Theme Color"))
207207
}
208208
}
209209
}

LongevityMaster/Components/Me/ThemeColorView.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,7 @@ struct ThemeColorView: View {
8888
.background(themeManager.current.background.ignoresSafeArea())
8989
.navigationTitle("Theme Color")
9090
.navigationBarTitleDisplayMode(.inline)
91-
.navigationBarBackButtonHidden()
92-
.toolbar {
93-
ToolbarItem(placement: .navigationBarLeading) {
94-
Button {
95-
dismiss()
96-
} label: {
97-
Text(String(localized: "Done"))
98-
.appRectButtonStyle()
99-
}
100-
}
101-
}
91+
// .navigationBarBackButtonHidden()
10292
}
10393
}
10494
}
@@ -122,7 +112,7 @@ struct ThemeColorCard: View {
122112
ZStack {
123113
Circle()
124114
.fill(themeOption.color)
125-
.frame(width: 80, height: 80)
115+
.frame(width: 50, height: 50)
126116
.shadow(color: themeOption.color.opacity(0.3), radius: 8, x: 0, y: 4)
127117

128118
Image(systemName: themeOption.icon)

LongevityMaster/Components/Today/TodayViewModel.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class TodayViewModel {
8888
let dayOfWeek = userCalendar.component(.weekday, from: selectedDate)
8989
if habit.daysOfWeek.contains(dayOfWeek) {
9090
let streak = calculateStreakForFixedDays(habit: habit, days: habit.daysOfWeek, unit: .weekday, checkIns: checkInsForHabit)
91-
let streakDescription = streak > 0 && isCompletedToday ? "🔥 \(streak)d streak" : nil
91+
let streakDescription = streak > 0 && isCompletedToday ? String(localized: "🔥 \(streak)d streak") : nil
9292
return TodayHabit(
9393
habit: habit,
9494
isCompleted: isCompletedToday,
@@ -102,7 +102,7 @@ class TodayViewModel {
102102
let dayOfMonth = userCalendar.component(.day, from: selectedDate)
103103
if habit.daysOfMonth.contains(dayOfMonth) {
104104
let streak = calculateStreakForFixedDays(habit: habit, days: habit.daysOfMonth, unit: .day, checkIns: checkInsForHabit)
105-
let streakDescription = streak > 0 && isCompletedToday ? "🔥 \(streak)d streak" : nil
105+
let streakDescription = streak > 0 && isCompletedToday ? String(localized: "🔥 \(streak)d streak") : nil
106106
return TodayHabit(
107107
habit: habit,
108108
isCompleted: isCompletedToday,
@@ -120,12 +120,12 @@ class TodayViewModel {
120120
}
121121
if habit.nDaysPerWeek > checkInsThisWeek.count || isCompletedToday {
122122
let streak = calculateStreakForNDaysPerPeriod(habit: habit, checkIns: checkInsForHabit)
123-
let streakDescription = streak > 0 && isCompletedToday ? "🔥 \(streak)d streak" : nil
123+
let streakDescription = streak > 0 && isCompletedToday ? String(localized: "🔥 \(streak)d streak") : nil
124124
let checkInsThisWeekUntilToday = checkInsForHabit.filter { checkIn in
125125
checkIn.date >= startOfWeek &&
126126
checkIn.date <= endOfDay
127127
}
128-
let frequencyDescription = "\(checkInsThisWeekUntilToday.count)/\(habit.nDaysPerWeek) this week"
128+
let frequencyDescription = String(localized: "\(checkInsThisWeekUntilToday.count)/\(habit.nDaysPerWeek) this week")
129129
return TodayHabit(
130130
habit: habit,
131131
isCompleted: isCompletedToday,
@@ -144,12 +144,12 @@ class TodayViewModel {
144144
}
145145
if habit.nDaysPerMonth > checkInsThisMonth.count || isCompletedToday {
146146
let streak = calculateStreakForNDaysPerPeriod(habit: habit, checkIns: checkInsForHabit)
147-
let streakDescription = streak > 0 && isCompletedToday ? "🔥 \(streak)d streak" : nil
147+
let streakDescription = streak > 0 && isCompletedToday ? String(localized: "🔥 \(streak)d streak") : nil
148148
let checkInsThisMonthUntilToday = checkInsForHabit.filter { checkIn in
149149
checkIn.date >= startOfMonth &&
150150
checkIn.date <= endOfDay
151151
}
152-
let frequencyDescription = "\(checkInsThisMonthUntilToday.count)/\(habit.nDaysPerMonth) this month"
152+
let frequencyDescription = String(localized: "\(checkInsThisMonthUntilToday.count)/\(habit.nDaysPerMonth) this month")
153153
return TodayHabit(
154154
habit: habit,
155155
isCompleted: isCompletedToday,

0 commit comments

Comments
 (0)