Skip to content

Fix Anki integration to support non-English environments and custom models#273

Open
ShengWang1017 wants to merge 1 commit into
Nitrino:masterfrom
ShengWang1017:fix/anki
Open

Fix Anki integration to support non-English environments and custom models#273
ShengWang1017 wants to merge 1 commit into
Nitrino:masterfrom
ShengWang1017:fix/anki

Conversation

@ShengWang1017

Copy link
Copy Markdown

Problem

The extension only worked with English Anki installations using the "Basic" model with "Front"/"Back" fields,
failing for users with:

  • Non-English Anki (Chinese, Japanese, etc.)
  • Custom note types
  • Different field names

Solution

  • Auto-detect compatible models: Scans all available note types and tests compatibility by creating/deleting test
    cards
  • Language-agnostic: Works with any field names in any language
  • Smart fallback: Prefers Front/Back fields but falls back to first two fields of any model
  • Better error handling: Clear error messages when no compatible model is found

Changes

  • Added findCompatibleModel() to automatically discover usable note types
  • Added testModelCompatibility() to verify models work before use
  • Removed hardcoded "Basic" model and "Front"/"Back" field names
  • Added duplicate prevention with allowDuplicate: false

Testing

Tested with:

  • ✅ English Anki (Basic model)
  • ✅ Chinese Anki (基础 model)

Fixes #272

- Add comprehensive error handling for network requests
- Implement proper JSON parsing with error recovery
- Add detailed error messages for debugging
- Fix duplicate card detection logic
- Improve connection error handling for localhost:8765

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@Nitrino

Nitrino commented Jan 20, 2026

Copy link
Copy Markdown
Owner

Hey @ShengWang1017. Thanks for your contribution, this is a really useful change, I will do a review soon

@ShengWang1017

Copy link
Copy Markdown
Author

Hi @Nitrino . If need any help, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] There is an error when adding the word to Anki

2 participants