feat: TypeWhisper Flow sessions, Phase 4 UX, and GitHub Pages privacy site
Migrate keyboard dictation to continuous Flow sessions with auto-start, tap-to-toggle recording, 60s countdown, five-step onboarding, and App Group IPC. Add docs/ GitHub Pages site with en/zh privacy policy for App Store compliance.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// SpeechLocaleResolver.swift
|
||||
// OSGKeyboard · Shared
|
||||
//
|
||||
// Maps persisted `localeId` settings to a `Locale` suitable for
|
||||
// `DictationTranscriber.supportedLocale(equivalentTo:)`.
|
||||
|
||||
import Foundation
|
||||
|
||||
public enum SpeechLocaleResolver {
|
||||
/// Resolve a stored locale id (`auto`, `zh-Hans`, …) for on-device ASR.
|
||||
public static func resolve(_ localeId: String) -> Locale {
|
||||
let raw: String
|
||||
if localeId == "auto" {
|
||||
raw = Locale.preferredLanguages.first ?? "en-US"
|
||||
} else {
|
||||
raw = localeId
|
||||
}
|
||||
let normalized = raw.replacingOccurrences(of: "_", with: "-").lowercased()
|
||||
if normalized.hasPrefix("zh") { return Locale(identifier: "zh-Hans") }
|
||||
if normalized.hasPrefix("ja") { return Locale(identifier: "ja-JP") }
|
||||
if normalized.hasPrefix("ko") { return Locale(identifier: "ko-KR") }
|
||||
if normalized.hasPrefix("en") { return Locale(identifier: "en-US") }
|
||||
return Locale(identifier: raw.replacingOccurrences(of: "_", with: "-"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user