Skip to content

Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more

1.2 KB
Raw Blame
@testable import FluidVoice_Debug
import XCTest

final class AppleSpeechLocaleSelectionTests: XCTestCase {
    func testLocaleOptionsAreNormalizedDeduplicatedAndSortedByName() {
        let english = Locale(identifier: "en")
        let options = VoiceEngineLanguageCatalog.appleSpeechLocaleOptions(
            identifiers: ["en-US", "zh_TW", "zh-TW"],
            displayLocale: english
        )

        XCTAssertEqual(options.map(\.id), ["zh-TW", "en-US"])
        XCTAssertEqual(options.map(\.displayName), [
            english.localizedString(forIdentifier: "zh-TW"),
            english.localizedString(forIdentifier: "en-US"),
        ])
    }

    func testLocaleOptionNamesFollowDisplayLocale() {
        let english = VoiceEngineLanguageCatalog.appleSpeechLocaleOptions(
            identifiers: ["zh-TW"],
            displayLocale: Locale(identifier: "en")
        )
        let traditionalChinese = VoiceEngineLanguageCatalog.appleSpeechLocaleOptions(
            identifiers: ["zh-TW"],
            displayLocale: Locale(identifier: "zh-Hant-TW")
        )

        XCTAssertNotEqual(english.first?.displayName, "zh-TW")
        XCTAssertNotEqual(english.first?.displayName, traditionalChinese.first?.displayName)
    }
}