tvhong/autodefine-cn-vn

★ 0Forks 0PythonGitHub ↗Compare

README

AutoDefine Chinese-Vietnamese for Anki

An Anki addon that automatically fills card fields with Chinese word definitions, Vietnamese translations, pinyin, and audio pronunciations when you enter Chinese vocabulary.

Features

  • Automatic Field Population: Enter Chinese text and automatically get definitions, translations, and pronunciations
  • Chinese to Vietnamese Translation: Native support for Chinese-Vietnamese language pairs
  • Multiple Data Sources:
    • Chinese definitions and explanations
    • Vietnamese translations
    • Pinyin romanization
    • Audio pronunciations
  • Configurable Field Mapping: Customize which fields get populated with what data
  • Keyboard Shortcuts: Quick activation with Ctrl+Alt+D
  • Custom Note Types: Pre-configured templates optimized for Chinese-Vietnamese learning

Installation

  1. Download the latest release from Releases
  2. In Anki, go to Tools > Add-ons > Install from file...
  3. Select the downloaded .ankiaddon file
  4. Restart Anki

Configuration

After installation:

  1. Go to Tools > Add-ons
  2. Select "AutoDefine Chinese-Vietnamese"
  3. Click Config to customize:
    • Field mappings
    • Translation sources
    • Keyboard shortcuts
    • Cache settings

Usage

Basic Usage

  1. Create or edit a card with Chinese vocabulary
  2. Enter Chinese text in your designated input field
  3. Press Ctrl+Alt+D or use the auto-trigger feature
  4. Watch as definitions, translations, and pronunciations are automatically filled

Field Mapping

Default field configuration:

  • Chinese: Source vocabulary field
  • Vietnamese: Vietnamese translation
  • Pinyin: Romanized pronunciation
  • Audio: Pronunciation audio file

Development

Requirements

  • Python 3.12+
  • Anki 25.09.x
  • uv for dependency management
  • just for running tasks

Setup

git clone https://github.com/yourusername/autodefine-cn-vn.git
cd autodefine-cn-vn
just install  # Installs dependencies with uv

Common Commands

See the justfile for all available commands. Most commonly used:

just test          # Run tests
just lint          # Check code style
just format        # Format code
just fix           # Auto-fix lint and format issues
just ci            # Run full CI pipeline (format, lint, test)
just link-to-anki  # Set up addon for development testing (macOS)
just run-anki-macos  # Run Anki on macos

Manual Testing

Automated Setup (macOS)

just link-to-anki  # Builds and symlinks to Anki's addon folder

This command will automatically build the addon and create a symlink to Anki's addon directory. After making code changes, run just link-to-anki again and restart Anki to test your changes.

Manual Setup (All Platforms)

To iterate quickly on your changes, you should symlink the addon to Anki's addon folder. The manual testing cycle then becomes: make code changes, rebuild, restart Anki, and test.

Steps:

  1. Find where Anki stores addons: Open Anki > Tools > Add-ons > View Files

  2. Build the addon and create a symlink:

    # Build the addon (includes vendored dependencies)
    just build
    
    # Create symlink (example paths - adjust for your system)
    ln -s $HOME/workplace/autodefine-cn-vn/build/autodefine_cn_vn \
          $HOME/.local/share/Anki2/addons21/autodefine_cn_vn

Running Anki for Testing

Create a "Test" profile for safer testing, then run Anki from terminal to see debug output:

just run-anki-macos

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Acknowledgments

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter issues or have suggestions:


Note: This addon is currently under development. Please report any bugs or feature requests through GitHub Issues.

Contributors

tvhong

Issues