Skip to content

Show closest word suggestion when translation or conjugation is invalid #640

@prince-0408

Description

@prince-0408

Terms

Description

Summary

When a user enters a word that isn't found during Translate or Conjugate, Scribe currently shows a generic "invalid" error with no further guidance. Users are left with no idea whether they made a typo or the word simply doesn't exist in the database.

Problem

The invalid state (commandState = .invalid) gives zero actionable feedback. A user who types "hause" instead of "Haus" gets the same error as someone who types complete nonsense — no distinction, no hint.

Proposed Solution

Reuse the existing queryAutocompletions infrastructure to find the closest matching word when a command returns invalid, and display it in the command bar as:

"Did you mean: Haus?"

This covers both Translate and Conjugate commands since both already funnel through commandState = .invalid.

Affected Files

File Change
Translate.swift Surface closest match on invalid result
Conjugate.swift Surface closest match on invalid result
CommandVariables.swift State handling for "did you mean" display
KeyboardViewController.swift Render suggestion in command bar

Notes

  • LanguageDBManager.shared.queryAutocompletions(word:) already returns close matches — no new DB queries needed
  • Purely additive, no existing logic removed
  • Strings can be hard-coded for now pending i18n entry

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions