Skip to content

Commit fa851a0

Browse files
committed
Localize Insights view and set locale
Replace hard-coded navigation title with the localization key 'tab.insights'. Add a view id tied to selectedLanguageCode and inject the app locale via .environment(\.locale, ...) so the Insights view refreshes and displays localized strings when the user changes language.
1 parent 9293946 commit fa851a0

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

CycleOne/Views/Insights/InsightsView.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ struct InsightsView: View {
206206
.padding(.bottom, 24)
207207
}
208208
.background(Color(.systemGroupedBackground))
209-
.navigationTitle("Insights")
209+
.navigationTitle("tab.insights")
210210
.navigationBarTitleDisplayMode(.inline)
211211
.onAppear {
212212
viewModel.calculateStats()
@@ -215,6 +215,11 @@ struct InsightsView: View {
215215
viewModel.calculateStats()
216216
}
217217
}
218+
.id("insights-stack-\(selectedLanguageCode)")
219+
.environment(
220+
\.locale,
221+
AppLanguage.fromStoredValue(selectedLanguageCode).locale
222+
)
218223
}
219224

220225
static func dayShortValue(_ days: Int) -> String {

0 commit comments

Comments
 (0)