feat(translation-v2): refactor translationEnabled into computed + onboarding row visibility
This commit is contained in:
@@ -87,13 +87,17 @@ public final class KeyboardState: ObservableObject {
|
||||
/// CoreML local engine. Always `false` now — there are no weights
|
||||
/// for the host app to preload.
|
||||
@Published public var localModelsLoaded: Bool = false
|
||||
/// v0.2.1: translation toggle mirrored from `ProviderConfig`. The
|
||||
/// pipeline asks `isTranslationEffective` before honouring it —
|
||||
/// the local engine ignores translation regardless of this flag.
|
||||
@Published public var translationEnabled: Bool = false
|
||||
/// v0.2.1 follow-up: derived — translation is on iff a target
|
||||
/// locale has been selected (mirrors `ProviderConfig.translationEnabled`
|
||||
/// so the chip / pipeline read the same source of truth).
|
||||
public var translationEnabled: Bool {
|
||||
translationTargetLocaleId != TranslationLanguageCatalog.offLocaleId
|
||||
}
|
||||
/// v0.2.1: target locale id the translate-and-polish prompt should
|
||||
/// produce (e.g. `"en"`, `"ja"`). Mirrored from `ProviderConfig`.
|
||||
@Published public var translationTargetLocaleId: String = TranslationLanguageCatalog.defaultLocaleId
|
||||
/// Defaults to `offLocaleId` so the keyboard boots in the "off"
|
||||
/// state on first install.
|
||||
@Published public var translationTargetLocaleId: String = TranslationLanguageCatalog.offLocaleId
|
||||
/// v0.2.1: effective predicate — translation is honoured only on
|
||||
/// the cloud engine. The keyboard's chip / picker read this so the
|
||||
/// UI can show a "需要云端" hint when the toggle is on while the
|
||||
@@ -115,11 +119,9 @@ public final class KeyboardState: ObservableObject {
|
||||
public var setLocale: (String) -> Void = { _ in }
|
||||
public var setEngineMode: (String) -> Void = { _ in }
|
||||
public var setLocalASRBackend: (LocalASRBackend) -> Void = { _ in }
|
||||
/// v0.2.1: persist translation toggle. Wired in
|
||||
/// `KeyboardViewController.installStateActions`.
|
||||
public var setTranslationEnabled: (Bool) -> Void = { _ in }
|
||||
/// v0.2.1: persist translation target locale id. Same wiring as
|
||||
/// `setTranslationEnabled`.
|
||||
/// v0.2.1 follow-up: only the locale picker remains — `enabled`
|
||||
/// is derived from the locale id, so there's no separate toggle to
|
||||
/// persist. Wired in `KeyboardViewController.installStateActions`.
|
||||
public var setTranslationTargetLocaleId: (String) -> Void = { _ in }
|
||||
public var insertNewline: () -> Void = {}
|
||||
public var insertSpace: () -> Void = {}
|
||||
|
||||
Reference in New Issue
Block a user