Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction to Kanji Master

Kanji Master is a cross-platform desktop application built in Rust, designed for learning Japanese. The main focus is on studying kanji: their readings, stroke order, and usage in vocabulary.

The application uses:

  • egui / eframe for the graphical interface
  • rusqlite for working with the kanji database

Key Features

  • Kanji Database & Search Search for characters by shape, meaning, readings (onyomi/kunyomi), and JLPT levels.
  • Draw & Search Draw kanji directly on the screen using your mouse or stylus to find characters you don’t know how to read.
  • Stroke Order Animation Visualizes the correct stroke order for each kanji.
  • Kana Reference & Romaji Converter Complete tables for Hiragana and Katakana, plus a smart Romaji to Kana converter with a built-in Kanji Assistant.
  • Anki Export Select kanji, review them, and export them directly to a TSV file ready to be imported into Anki.
  • Localization & Custom Translations Full support for switching the interface language (TOML) and editing kanji meanings (JSON) via a built-in Translation Tool.

Tech Stack

  • Language: Rust
  • GUI: eframe / egui
  • Database: SQLite
  • Configuration & UI Localization: TOML
  • Kanji Data Translation: JSON

Installation and Setup

Kanji Master is written in Rust. To build and run the application, ensure you have Rust and the necessary system libraries installed.


Prerequisites

  1. Install Rust and Cargo.

  2. Ensure your system has the required libraries for compiling GUI applications:

    • Linux: fontconfig, xcb, and other dependencies specific to your distribution.
    • macOS / Windows: Usually, no additional libraries beyond Rust are required.

⚠️ The list of system libraries may vary depending on your OS.


Building and Installation

1. Cloning the Repository

git clone https://github.com/atxxxm/KANJI-MASTER
cd KANJI-MASTER

2. Installation via Cargo

There are several ways to install Kanji Master:

a) Installing directly from GitHub:

cargo install --git https://github.com/atxxxm/KANJI-MASTER

b) Installing from a local copy of the repository:

cargo install --path .

🔹 Using --path is convenient for testing or if you plan to modify the project locally.


3. Configuring the PATH

To make Cargo binaries and installed applications runnable from anywhere, ensure that the path $HOME/.cargo/bin (Linux/macOS) or the corresponding Windows path is added to your system’s PATH variable.

Linux / macOS (bash / zsh)

Add to ~/.bashrc or ~/.zshrc:

export PATH="$HOME/.cargo/bin:$PATH"

Apply the changes:

source ~/.bashrc   # or source ~/.zshrc

Verification:

cargo --version
kanji-master --help

Fish shell

set -Ux PATH $HOME/.cargo/bin $PATH

Windows (PowerShell / CMD)

When installing Rust via rustup, the PATH variable is usually configured automatically. If you need to add it manually, the typical path to Cargo is:

C:\Users\<Your_Username>\.cargo\bin
  • In PowerShell, you can add it temporarily like this:
$env:PATH += ";C:\Users\<Your_Username>\.cargo\bin"
  • To add it permanently, use System Properties → Advanced → Environment Variables → PATH.

After this, all Cargo commands and installed applications (including kanji-master) will be accessible from anywhere.


4. Running the Application

To run from source:

cargo run --release

If the application was installed via Cargo:

kanji-master

🔹 The --release flag is needed for optimized animations and interface performance.


5. First Launch and Data Initialization

On the first launch of Kanji Master:

  • The application will automatically create all necessary data and configuration files.
  • Wait for the process to complete before starting to work with the program.

User Guide

The Kanji Master interface is designed for quick access to information and convenient study of kanji and kana.

Top Navigation Bar

  • Logo – returns to the home screen.
  • Kanji – navigates to the list of kanji characters (filterable by JLPT).
  • Kana – opens the Hiragana and Katakana tables.
  • Tools – a dropdown menu with utilities:
    • Romaji to Kana Converter
    • Translate Kanji
    • Export to Anki
    • Draw & Search
  • Settings (⚙) – opens the settings panel.

Settings

The settings menu provides the following options:

  • Change the interface font size and kanji character size.
  • Adjust the speed of the kanji writing animation.
  • Enable/disable displaying kanji meanings in the general list.
  • Configure focus behavior for the search function.
  • Specify paths to localization files for using your own translations.

Interface & Navigation

Kanji Master is built around a modern, highly productive Tab-based Interface. This allows you to multitask seamlessly: you can have a kanji dictionary open in one tab, the drawing tool in another, and the Romaji converter in a third.

Interface Overview (Note: add a screenshot of your app with multiple tabs open here)

Tab Management

Working with tabs in Kanji Master is similar to how you browse the web:

  • Opening a new tab: Click the + button on the right side of the tab bar. By default, it opens the Home (Search) screen.
  • Quick Actions: Right-click the + button to directly open a new “Kanji List” or “Translator” tab.
  • Closing a tab: Click the × icon on the tab, or Middle-click (mouse wheel) anywhere on the tab title.
  • Reordering: Click and drag any tab to move it left or right.
  • Context Menu: Right-click any tab to see options like “Close Tab” or “Close Others”.

Opening Content in Background

When browsing the Dictionary, Home screen, or Draw & Search results, you will see lists of Kanji cards.

  • Left-click on a Kanji card opens its detailed view and instantly switches your focus to that new tab.
  • Middle-click (or Right-click) on a Kanji card opens its detailed view in a background tab. This is incredibly useful when you want to open several kanji from a search result without losing your place in the list!

Top Navigation Bar

The bar at the top of the window provides quick access to core features:

  • Logo (Kanji Master): Instantly opens a new Home search tab.
  • Kanji: Opens the full, filterable list of all kanji.
  • Kana: Opens the Hiragana and Katakana reference tables.
  • Tools: A dropdown menu containing advanced utilities (Draw & Search, Anki Export, Romaji Converter, etc.).
  • Settings (⚙): Opens the configuration panel for UI and paths.

Dictionary and Search

The Home screen and the Kanji List tab provide full access to the comprehensive kanji database.

The main search bar allows you to quickly filter and find kanji based on multiple criteria simultaneously:

  • Character (Kanji) – paste or type the symbol itself.
  • Readings (On’yomi / Kun’yomi) – supports both kana and romaji (e.g., mizu or みず).
  • Meaning – search through your localized English/custom translations.

Tip: In the Settings, you can enable Focus on search when opening. This automatically places your typing cursor in the search field when you open a new Home tab, allowing for lightning-fast lookups.

Filter by JLPT (Kanji List Tab)

If you open a Kanji List tab from the top menu, you get access to a dropdown filter. This allows you to narrow down the displayed kanji by their JLPT (Japanese-Language Proficiency Test) levels:

  • N5 (Beginner)N1 (Advanced)
  • All – show all available kanji.

Detailed Kanji View

Clicking on any kanji card opens its detailed view in a new tab.

  1. Stroke Animation & Copying
    • An animated stroke order diagram is displayed on the left.
    • Clicking on the animation area replays it.
    • Below the animation, there is a 📋 Copy button to instantly copy the character to your clipboard.
  2. Kanji Information
    • Primary Meaning.
    • Badges for JLPT level, School Grade, Stroke Count, and Frequency.
    • Readings: On’yomi and Kun’yomi displayed in both Kana and Romaji.
  3. Usage Examples
    • A scrollable list of vocabulary words or phrases containing this kanji.
    • If your localization file contains translations for these examples, they are displayed in gray italics right below the original Japanese text.

Kana (Hiragana and Katakana)

The Kana tab serves as a quick, interactive reference guide for Japanese syllabaries.

Switching Modes

A toggle pill is prominently located at the top of the screen:

  • Hiragana (あ) – The primary Japanese syllabary used for native words and grammar.
  • Katakana (ア) – The syllabary used for loanwords, foreign names, and emphasis.

Clicking the toggle instantly swaps the displayed character grid.

Character Cards

Each kana character is displayed inside a responsive, hoverable card grid. Each card contains:

  1. The Character – Rendered in a large, clean font for high visibility.
  2. Romaji Reading – Displayed in a smaller, muted font at the bottom of the card to help you memorize the pronunciation.

💡 Tip: If you are struggling to memorize these, try using the Romaji to Kana Converter (found in the Tools menu) to practice typing them out!

Draw & Search

Encountered a kanji in a book or a game, but don’t know how to read it? The Draw & Search tool allows you to write the character manually and find it in the database.

Draw and Search

How to use

  1. Open the Tools menu and select Draw & Search.
  2. Use your mouse, trackpad, or stylus to draw the kanji on the large canvas.
  3. Use the Undo (⬅) button to remove the last stroke if you made a mistake.
  4. Use the Clear (🗑) button to wipe the canvas and start over.
  5. Click the Search (🔍) button.

The algorithm will analyze your drawing and display the best matches in the right panel (or below the canvas on smaller screens). Click on any result to open its detailed page.

💡 Tip: Middle-click a result card to open it in a background tab so you don’t lose your search results!

How the Recognition Algorithm Works

Kanji Master uses a shape and distance-based recognition engine. For the best results, keep the following in mind:

  • Stroke Count matters: The algorithm heavily relies on the number of strokes. If a kanji has 5 strokes, try to draw exactly 5 strokes.
  • Proportions matter: Try to center your drawing and maintain the relative size of radicals (e.g., if the left radical is small, draw it small).
  • Stroke Order: While the algorithm tries to be forgiving, drawing strokes in the traditional Japanese stroke order significantly increases accuracy.

Anki Export Tool

The Anki Export feature allows you to seamlessly transfer the kanji you are studying directly into Anki, the popular spaced repetition flashcard software.

Step-by-Step Export

The export process is divided into three simple steps:

Step 1: Select Kanji

Use the search bar and the JLPT dropdown filter to find the kanji you want to study. Click on a kanji card to select it (it will become highlighted). Click again to deselect. Once you have selected your kanji, click Next.

Step 2: Review Selection

Here you will see a list of all the kanji you’ve selected. You can review their readings. If you accidentally added a kanji you don’t need, click the button next to it. Click Next to proceed.

Step 3: Export Options

Choose exactly which data fields you want to include in your Anki cards:

  • Kanji (The character itself)
  • Meaning (Your localized translation)
  • Onyomi & Kunyomi (Readings)
  • JLPT Level
  • Examples (HTML) (Usage examples, formatted with line breaks for Anki)

Click the green Export to TSV button and choose where to save the .txt file on your computer.


How to Import the File into Anki

Once you have your exported .txt file, follow these steps to get it into Anki:

  1. Open Anki and click on Import File at the bottom of the main window.
  2. Select the .txt file you just exported from Kanji Master.
  3. In the Import window, ensure the following settings are correct:
    • Type: Basic (or any custom Note Type you prefer).
    • Deck: Choose the deck where you want the cards to go.
    • Field separator: Make sure it is set to Tab (Kanji Master exports as Tab-Separated Values).
    • Allow HTML in fields: Make sure this is Checked ✅ (This is required for the “Examples” field to display multiple lines correctly).
  4. Map the fields from the file (Field 1, Field 2, etc.) to your Anki note’s Front and Back fields.
  5. Click Import.

Other Tools

The Tools menu provides utility features for text manipulation and localization.

1. Romaji to Kana Converter & Kanji Assistant

This tool allows you to convert text typed in Latin letters (Romaji) into Japanese syllabaries in real time.

  • Input Mode: Type text in the large editor (e.g., watashi wa mizu wo nomimasu).
  • Output Mode: Toggle between Hiragana and Katakana output.
  • Copying: Use the Copy Result button to copy the converted text to your clipboard.

💡 The Kanji Assistant

The true power of this tool lies in the Kanji Assistant panel on the right side.

As you type kana, the Assistant continuously analyzes the last word you typed. It searches the database and instantly suggests kanji that match that reading.

  • Typing みず will instantly show a card for .
  • Clicking the card in the Assistant will automatically replace みず with in your text editor.
  • Cards are smartly sorted: exact matches appear first, followed by JLPT N5-N1 order.

This turns the converter into an interactive learning tool, helping you visually memorize kanji while typing!


2. Translate Kanji Tool

A built-in editor designed for translating kanji meanings and examples into your native language. (Note: these changes are saved to your local kanji-localization.json file).

  1. Search & Navigation:
    • Type a kanji, romaji reading, or ID into the search box.
    • A dropdown will appear. Click on a result to jump directly to that kanji.
    • Alternatively, use the Previous / Next buttons to browse sequentially.
  2. Editing:
    • Meaning: Type the primary translation of the kanji.
    • Examples: Translate the Japanese vocabulary words into your language. The original Japanese word is shown above the input box for reference.
  3. Saving: Click the Save Progress button at the top right to write all changes to disk.

Settings

The Settings panel allows you to customize Kanji Master’s appearance, behavior, and file paths.

To open it, click the gear icon () on the far right of the top navigation bar.


Files & Data

This section manages paths to external resource files. It is useful if you want to use custom community translations or switch between different language packs.

  • Language (TOML) – Path to the UI translation file (localization.toml).
  • Kanji Localization (JSON) – Path to the kanji meanings and examples file (kanji-localization.json).

Managing files: Click the 📂 Select button next to a path to choose a different file via your system’s file explorer. The application will instantly load the new file.


Appearance

Customize the visual presentation of the application to suit your monitor size and reading preferences:

  • Interface font size – Adjusts the size of buttons, menus, and standard text. (Range: 12px — 32px)
  • Kanji font size – Adjusts the size of kanji characters displayed inside lists and cards. (Range: 20px — 120px)
  • Kanji animation speed – Controls how fast the strokes are drawn in the Kanji Detail tab. Moves on a logarithmic scale (from 0.1x to 5.0x).

Behavior

  • Focus on search when opening If enabled, whenever you open a new Home tab, your cursor will be automatically placed in the search box. Highly recommended for keyboard-heavy users.
  • Show kanji meaning Toggles the display of kanji meanings underneath the characters in the search results and kanji lists. Turn this off if you want to use the lists for strict memory recall testing!

Tools

  • Create default localization file Clicking this button opens a save dialog to generate a fresh, default localization.toml template. This is incredibly useful for translators who want to create a new UI language pack from scratch without guessing the required TOML keys.

Note: All changes made in the settings panel are automatically saved to your config.toml file the moment you close the window.

Localization

Kanji Master fully supports localization through external JSON files. This allows translating the interface and content without needing to recompile the program.


File Locations

Upon first launch, localization files are automatically extracted to the system configuration folder:

  • Windows: C:\Users\<Username>\AppData\Roaming\KanjiMaster\localization\
  • Linux: /home/<username>/.config/kanjimaster/localization/
  • macOS: /Users/<Username>/Library/Application Support/KanjiMaster/localization/

You can open the current folder with localization files directly from the application settings by clicking the 📂 button.


Key Files

The system uses two key JSON files:

  1. Interface: localization.json – contains translations for user interface elements.
  2. Data: kanji-localization.json – contains translations for kanji meanings and usage examples.

By editing these files, you can add your own translations or modify existing ones without changing the application’s code.

Interface Localization

The localization.toml file is responsible for all GUI text labels: buttons, headers, tooltips, and error messages. The file structure corresponds to the Rust structures defined in localization.rs.


Example Structure (TOML)

lang = "English"

[local.home]
kanji_search_hint = "Type meanings, reading or kanji..."
kanji_not_found = "No kanji found"

[local.top_bar.kanji]
title = "Kanji"
all = "All"

[local.top_bar.tools]
title = "Tools"
romaji_to_kana = "Romaji to Kana"
translate_kanji = "Translate Kanji"
anki_export = "Export to Anki"

Creating a New Translation

  1. Create a copy of the localization.toml file.
  2. Translate the field values into the target language.
  3. In the application settings, select the new file for use in the interface.

Tip: Ensure the TOML structure and all keys are preserved so the application displays translations correctly.

Kanji Localization (JSON)

The kanji-localization.json file contains your personal translations for kanji meanings and usage examples.

🛠 Highly Recommended: Instead of editing this raw JSON file manually, use the built-in Translate Kanji Tool (found in the Tools menu). The tool provides a clean UI for translating and automatically saves the JSON file with the correct formatting and IDs!


File Structure

If you prefer to edit the file manually or write a script to generate it, the root object contains an entries dictionary where:

  • Key – the kanji character itself (e.g., "日").
  • Value – an object with the translation and an array of examples.

Example structure:

{
  "last_id": 100,
  "entries": {
    "日": {
      "meaning": "Day, sun, Japan",
      "translate_examples": [
        "Sunday",
        "Japan",
        "Holiday"
      ]
    },
    "月": {
      "meaning": "Month, moon",
      "translate_examples": [
        "Monday",
        "Next month"
      ]
    }
  }
}

Field Descriptions

    last_id – Keeps track of the last kanji you translated using the built-in UI tool.

    meaning – The main meaning of the kanji (String).

    translate_examples – An array of strings containing translations for the usage examples. The order of elements must exactly match the order of the original Japanese examples in the core.db database.

About the Project

Kanji Master was initially created as a tool for personal kanji study. Over time, the project was opened to the public so others could use it freely and contribute to its growth.

The project’s goal is to provide a fast, lightweight, and visually appealing tool for learning Japanese and working with kanji on desktop systems. It is aimed at users who need free, offline, and customizable solutions, bypassing the limitations of many commercial or closed-source applications.


License

The application is distributed under the GPL-3 license. You are free to use, modify, and distribute this software.

Go to the GitHub repository


Acknowledgments and Libraries Used

The project was made possible thanks to the Rust ecosystem and numerous open-source libraries:

  • egui — a fast, highly portable, and ergonomic Immediate Mode GUI library.
  • rusqlite — an ergonomic wrapper for working with SQLite databases.
  • serde — a powerful framework for serializing and deserializing data (JSON/TOML).
  • rust-embed — for embedding databases and assets directly into the binary.

Fonts and Data Sources

  • Font: Uses Noto Sans JP by Google (OFL license).
  • Dictionary Data: Based on open sources such as EDICT / JMdict and KANJIDIC.
  • SVG Data: Kanji stroke order animations and handwritten recognition paths are sourced from the KanjiVG project.

FAQ and Troubleshooting

This section contains answers to frequently asked questions and guidance for resolving potential technical issues.


Where is my data stored?

The application stores configuration, the database, and localization files in the user’s system directory:

  • Windows: C:\Users\<Username>\AppData\Roaming\KanjiMaster\
  • Linux: /home/<username>/.config/kanjimaster/
  • macOS: /Users/<Username>/Library/Application Support/KanjiMaster/

To transfer your progress to another computer:

  1. Copy the config.toml file.
  2. Copy the kanji-localization.json file, if you have edited kanji translations.

The application is “laggy” or animations are stuttering

Make sure you are running the application in Release mode.

In Debug mode, Rust performs numerous checks that can slow down the graphical interface and data processing.

To run in Release mode, use the command:

cargo run --release

How to reset all settings?

If the application fails to start or you wish to return to the default settings:

  1. Close the application.
  2. Navigate to the data folder (paths are listed above).
  3. Delete the entire KanjiMaster folder.
  4. On the next launch, the program will recreate all files with default settings.

I found an error in a translation or a kanji

  • To correct localized translations, use the built-in Translate Kanji Tool or edit the JSON file manually.
  • If the error is in the core kanji data (e.g., an incorrect reading or JLPT level), you will need to modify the core.db file using an SQLite browser, as this data is part of the application’s core.

Project Architecture

Kanji Master is built on a modular architecture that clearly separates data logic (Backend) and presentation (UI). This facilitates maintenance, feature expansion, and testing.


Tech Stack

  • Language: Rust (Edition 2024)
  • Graphics Engine: eframe (wrapper over egui) — Immediate Mode GUI.
  • Database: SQLite (via the rusqlite crate).
  • Serialization: serde + serde_json / toml.
  • Resource Embedding: rust-embed (for DB, JSON, fonts, and SVG).

Module Structure

back (Backend)

Contains business logic independent of the GUI:

  • core.rs — working with SQLite (core.db), Kanji structures.
  • config.rs — configuration management (config.toml).
  • localization.rs — handling TOML UI localization.
  • translation.rs — handling JSON kanji translations and examples.
  • recognition.rs — logic for the handwritten kanji recognition system.
  • svg_cache.rs — parsing and caching SVG path data for stroke animations.
  • romaji_kana.rs — text conversion from Latin script to kana.

ui (Interface)

Responsible for rendering and handling user input:

  • interface.rs — the main application loop (impl eframe::App), screen routing (enum Screen), and layout of all panels.
  • settings.rs — the settings window and management of user preferences.
  • animator.rs — component for rendering SVG kanji stroke order animations.

Database (core.db)

The application uses a relational SQLite database. Main tables:

  1. kanji — core information (id, character, JLPT, grade, strokes).
  2. read — kanji readings (on’yomi and kun’yomi).
  3. examples — example words and phrases containing the kanji.

The data is joined in Rust via a single large JOIN query at startup and then held in memory for fast search and filtering.


Resources and Asset

Using rust-embed, all static files (DB, JSON, fonts, SVG) are embedded into the binary.

  • On the first launch (main.rs -> initialize_app_data), resources are extracted to the user’s system configuration folder:

    • Windows: C:\Users\<Username>\AppData\Roaming\KanjiMaster\
    • Linux: /home/<username>/.config/kanjimaster/
    • macOS: /Users/<Username>/Library/Application Support/KanjiMaster/
  • This ensures application autonomy and allows the user to easily reset settings or change localization.

Code Internals

This document is a technical guide for developers who want to modify the Kanji Master core. It covers architectural decisions, state management, data flow, and specifics of working with Immediate Mode GUI in Rust.


1. Application Lifecycle

Kanji Master operates as a hybrid of a utility and a game engine, rather than a standard CRUD application.

Initialization (main.rs)

The entry point is the main function. It performs critical tasks before the interface is rendered:

  1. Resource Extraction (initialize_app_data):

    • The application is compiled into a single binary file, including the SQLite database core.db, JSON localization files, and SVG resources using the rust-embed crate.
    • Logic: On startup, it checks for the existence of the system configuration folder (e.g., %APPDATA%\KanjiMaster on Windows or /home/<user>/.config/kanjimaster/ on Linux). If the files are missing—they are extracted from the binary and written to disk.
    • Why: Guarantees the presence of valid data, and the user can reset settings by deleting the configs.
  2. Loading Configuration (load_config):

    • Attempts to read config.toml.
    • If the file is missing or corrupted, a default configuration is created (Config::default()).
  3. Launching the GUI (eframe::run_native):

    • Initializes the OpenGL/Vulkan/Metal context.
    • Creates the main state object — App.

2. Monolithic State (App)

All application logic is managed through a single state structure App (interface.rs), which is a standard pattern for egui.

#![allow(unused)]
fn main() {
struct App {
    // 1. Navigation
    tab_manager: TabManager,

    // 2. "Cold" data (Read-only)
    kanji: Vec<Arc<Kanji>>,

    // 3. "Hot" data (Mutable)
    config: Config,
    settings: Settings,
    paths: Paths,
    localization: Localization,

    // 4. Subsystems
    translate_state: TranslateState,
    recognition: RecognitionSystem,
    svg_cache: SvgCache,
}
}

Key Points on Memory Management

  • In-Memory Database: self.kanji is loaded once at startup. ~2-3 thousand objects take only a few megabytes of RAM — this speeds up searching and filtering without disk queries.
  • Cloning: kanji.clone() is used instead of complex schemes with Rc/RefCell to simplify working with the Borrow Checker.

3. Immediate Mode GUI and the update Cycle

Kanji Master uses egui (Immediate Mode GUI). The interface is completely rebuilt every frame.

Core Principles

  1. The update(&mut self, ctx, frame) method is called on each frame (e.g., on mouse movement or at 60 FPS for animations).
  2. No stored UI objects — all buttons and windows are recreated each frame.
  3. Events are checked immediately during rendering:
#![allow(unused)]
fn main() {
if ui.button("Click me").clicked() {
    self.counter += 1;
}
}

UI Architecture (interface.rs)

#![allow(unused)]
fn main() {
fn update(...) {
    // 1. Global styles (fonts, sizes)
    // 2. TopBar (always visible)
    self.top_bar(ctx);

    // 3. Central panel
    egui::CentralPanel::default().show(ctx, |ui| {
        match &self.current_screen {
            Screen::Home => self.home_screen(ui),
            Screen::Kanji(k) => self.kanji_screen(ui, k),
            // ... routing for other screens
        }
    });

    // 4. Overlay windows (Settings)
    if self.settings.setting(...) {
        self.save();
    }
}
}

4. Data Subsystem (back/core.rs)

Working with SQLite (rusqlite) is encapsulated in the Database struct.

  • SQL Query: One large JOIN is executed between the kanji, read, and examples tables.
  • NULL Handling: Via Option<String>, mapped to empty strings for the UI.
  • Sorting: Data is sorted at the Rust vector level for predictable display.

5. Localization

  • Dynamic Switching: reload_interface_localization replaces self.localization. The GUI updates instantly.
  • Two Layers:
    1. localization.json — interface.
    2. kanji-localization.json — kanji and example translations.

6. Flashcard Subsystem (back/cards.rs)

  • Session State Machine:
    • queue: A shuffled Vec<Kanji> for studying.
    • current_index: The current card.
    • is_card_flipped: The flipped state of the card.
  • Session Creation: Filtering by JLPT/deck, shuffling, card limit.
  • Lifecycle: Stored in Option<CardsSession> inside App.

7. Practical Guide: Adding New Features

Example: Adding a “Dark Mode” Parameter

  1. Backend (config.rs): Add pub dark_mode: bool to Config.
  2. State (settings.rs): Add a field to Settings.
  3. UI: Add a checkbox in the setting(...) method.
  4. Logic (interface.rs): Apply the value during update and save it to config.

Example: Adding a New Screen

  1. Add a variant to the enum Screen.
  2. Implement a rendering method in App.
  3. Add handling in update for routing.

8. Common Issues and Nuances

  1. Borrow Checker in UI: Avoid mutating self inside ui.show(|ui| { ... }).
  2. Performance: Execute heavy operations during initialization or in a separate thread, not in update.
  3. Input Focus: Managed using ui.memory(|m| m.request_focus(id)).