Anki Auto Translator is an Anki add-on designed to streamline the translation process within your flashcards. This tool automatically translates content from a specified source field to a target field based on predefined language mappings. It is particularly useful for language learners who want to maintain bilingual notes efficiently.
Configuration:
{
"auto_translate_fields": [
{
"language": "jp-en",
"after_field": "textfield_en",
"before_field": "textfield_jp"
}
]
}
Features
Automated Translation: Automatically translates terms from one language to another using a predefined dictionary.
Customizable Cleaning: Removes unwanted characters from the source text before translation to ensure accurate results.
Flexible Delimiters: Splits and rejoins terms using customizable delimiters, allowing for precise handling of multi-word entries.
Debug Logging: Provides detailed logs to help troubleshoot and verify the translation process.
Easy Configuration: Simple JSON-based configuration allows beginners to easily set up and modify translation settings.
Extendable for Multiple Languages: While initially configured for Japanese to English translations, the add-on can be easily extended to support additional languages.
How It Works
Configuration Setup:
Define the source field (before_field), target field (after_field), and language pair (language) in the config.json file.
Specify characters to remove (before_remove_001, before_remove_002, before_remove_003) and delimiters for splitting (before_delemeter_001, before_delemeter_002, before_delemeter_003) as well as the delimiter to use when rejoining translated terms (after_delemeter_001).
Processing Steps:
Cleaning: The add-on removes specified unwanted characters from the content of the before_field.
Splitting: It splits the cleaned text into individual terms using the defined delimiters.
Translation: Each term is checked against the translation dictionary. If a match is found, the term is translated; otherwise, it remains unchanged.
Rejoining: Translated terms are joined using the specified after_delemeter.
Saving: The final translated string is saved into the after_field.
Logging:
Detailed debug logs are maintained in logs/error_log.txt, capturing each step of the translation process, including which terms were found or not found in the translation dictionary and the final output for each note.