diff --git a/Apps/Attendi/Catalogs/Localizable.xcstrings b/Apps/Attendi/Catalogs/Localizable.xcstrings index ee7a36c..84d5238 100644 --- a/Apps/Attendi/Catalogs/Localizable.xcstrings +++ b/Apps/Attendi/Catalogs/Localizable.xcstrings @@ -62,13 +62,13 @@ } }, "view.recording.navigation.title" : { - "comment" : "The title of the navigation bar in the recording view.", + "comment" : "The title of the navigation bar in the recording view. %@ is the name of the selected locale β€” its language name followed by the region flag, e.g. \"English πŸ‡ΊπŸ‡Έ\".", "extractionState" : "manual", "localizations" : { "en" : { "stringUnit" : { "state" : "translated", - "value" : "Recording" + "value" : "Transcribe to %@" } } } diff --git a/Apps/Attendi/Sources/View Models/ContentViewModel.swift b/Apps/Attendi/Sources/View Models/ContentViewModel.swift index 2601788..2100ce1 100644 --- a/Apps/Attendi/Sources/View Models/ContentViewModel.swift +++ b/Apps/Attendi/Sources/View Models/ContentViewModel.swift @@ -97,6 +97,14 @@ extension ContentView { self.reporter = reporter self.transcriber = transcriber } + + // MARK: Computed + + /// The navigation title of ``ContentView``: the localized "Transcribe to …" filled with the name of the selected ``locale``, so + /// the title updates on every locale change. + var navigationTitle: LocalizedStringResource { + .viewRecordingNavigationTitle(name(for: locale)) + } // MARK: Methods diff --git a/Apps/Attendi/Sources/Views/ContentView.swift b/Apps/Attendi/Sources/Views/ContentView.swift index 127e48c..16f5875 100644 --- a/Apps/Attendi/Sources/Views/ContentView.swift +++ b/Apps/Attendi/Sources/Views/ContentView.swift @@ -62,7 +62,7 @@ struct ContentView: View { maxWidth: .infinity, maxHeight: .infinity ) - .navigationTitle(.viewRecordingNavigationTitle) + .navigationTitle(model.navigationTitle) #if !os(macOS) .navigationBarTitleDisplayMode(.inline) #endif diff --git a/Apps/Attendi/Tests/View Models/ContentViewModelTests.swift b/Apps/Attendi/Tests/View Models/ContentViewModelTests.swift index 0202f62..dc732ce 100644 --- a/Apps/Attendi/Tests/View Models/ContentViewModelTests.swift +++ b/Apps/Attendi/Tests/View Models/ContentViewModelTests.swift @@ -256,6 +256,38 @@ struct ContentViewModelTests { } + // MARK: Navigation Title + + @MainActor + @Suite("Navigation title") + struct NavigationTitle { + + @Test + func `navigation title names the selected locale`() { + let model = Model(preinstaller: PreinstallingMock()) + + model.locale = .english + + #expect(String(localized: model.navigationTitle) == "Transcribe to \(model.name(for: .english))") + } + + @Test + func `navigation title updates when the locale changes`() { + let model = Model(preinstaller: PreinstallingMock()) + + model.locale = .english + let english = String(localized: model.navigationTitle) + + model.locale = .dutch + let dutch = String(localized: model.navigationTitle) + + #expect(english == "Transcribe to \(model.name(for: .english))") + #expect(dutch == "Transcribe to \(model.name(for: .dutch))") + #expect(english != dutch) + } + + } + } // MARK: - Constants