# How to Configure Emoji and Translation Filters in the Wanxiang Rime Schema

> Learn how to configure emoji and translation filters in the Wanxiang Rime schema. Enhance your input experience with visual symbols and bilingual translations.

- Repository: [amzxyz/rime_wanxiang](https://github.com/amzxyz/rime_wanxiang)
- Tags: how-to-guide
- Published: 2026-02-24

---

**Wanxiang provides two built-in Lua filters—`emoji` and `chinese_english`—that append visual symbols or bilingual translations to candidates when activated via schema switches in [`wanxiang.schema.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang.schema.yaml).**

The Wanxiang RIME input method schema (amzxyz/rime_wanxiang) enriches the candidate list through optional **super_replacer** filters that operate on tab-separated dictionary files. By configuring these filters, you can display emoji characters next to Chinese phrases or show English-Chinese translation pairs without modifying the core dictionary. This guide details the switch configuration, data file formats, and runtime activation methods.

## Understanding the Filter Architecture

Wanxiang implements emoji and translation support through a single Lua module called **`super_replacer`**, defined in [`wanxiang/lua/super_replacer.lua`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang/lua/super_replacer.lua). This module acts as a dynamic replacer that loads external data files and appends content to candidates only when specific option switches are enabled.

The architecture separates presentation logic from data storage:

- **`emoji` filter**: Reads [`lua/data/emoji.txt`](https://github.com/amzxyz/rime_wanxiang/blob/main/lua/data/emoji.txt) and appends graphic symbols to candidates when the switch is set to "表情开" (emoji on).
- **`chinese_english` filter**: Reads [`lua/data/english_chinese.txt`](https://github.com/amzxyz/rime_wanxiang/blob/main/lua/data/english_chinese.txt) and [`lua/data/chinese_english.txt`](https://github.com/amzxyz/rime_wanxiang/blob/main/lua/data/chinese_english.txt) to display bilingual translation comments (e.g., "hello 〔你好 | 哈喽〕") when the switch is set to "翻译开" (translation on).

Both filters use **tab-separated values (TSV)** where the first column represents the input trigger and subsequent columns define the replacement or comment text.

## Enabling Filters in wanxiang.schema.yaml

To activate these features, you must define switches in the schema configuration and map them to the `super_replacer` engine.

**Step 1: Declare the switches** (lines 24–32 in [`wanxiang.schema.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang.schema.yaml)):

```yaml
switches:
  - name: emoji
    states: [ 表情关, 表情开 ]
    reset: 0
  - name: chinese_english
    states: [ 翻译关, 翻译开 ]
    reset: 0

```

**Step 2: Configure the super_replacer** (lines 124–138 in [`wanxiang.schema.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang.schema.yaml)):

```yaml
super_replacer:
  types:
    - option: emoji
      mode: append
      comment_mode: none
      tags: [abc]
      prefix: "_em_"
      files:
        - lua/data/emoji.txt
    - option: chinese_english
      mode: append
      comment_mode: none
      tags: [abc]
      prefix: "_en_"
      files:
        - lua/data/english_chinese.txt
        - lua/data/chinese_english.txt

```

The **`option`** field must match the switch `name` exactly. The **`files`** array specifies the data sources, while `mode: append` ensures the content appears after the candidate text rather than replacing it.

## Runtime Toggle and Session Persistence

Once configured, users can toggle these filters without editing configuration files.

**Via the Rime UI:**
Press `Control+grave` (default schema selector shortcut) to open the *方案选单*. Navigate to:
- **表情开 / 表情关** — Enables or disables the emoji filter.
- **翻译开 / 翻译关** — Enables or disables the translation filter.

**Persistence Configuration:**
Switch states are automatically remembered across sessions because both `emoji` and `chinese_english` are listed in the `save_options` array in [`wanxiang/default.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang/default.yaml) (line 28):

```yaml
switcher:
  save_options:
    - emoji
    - chinese_english
    - ascii_mode
    - full_shape
    # ... other options

```

This ensures your preferences persist after reloading the Rime engine or restarting your system.

## Customizing Emoji and Translation Data

You can extend the built-in dictionaries by editing the tab-separated data files. Changes require a Rime reload (`Ctrl+Shift+F5` in the Rime menu) to take effect.

**Adding Custom Emoji:**
Edit [`wanxiang/lua/data/emoji.txt`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang/lua/data/emoji.txt) and append entries in the format:

```

keyword<TAB>text_representation<TAB>emoji_symbol

```

For example:

```

笑脸	🙂
火箭	🚀

```

When the emoji filter is active, typing `笑脸` will display the candidate followed by 🙂.

**Adding Translation Pairs:**
Edit [`wanxiang/lua/data/english_chinese.txt`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang/lua/data/english_chinese.txt) (English to Chinese) or [`wanxiang/lua/data/chinese_english.txt`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang/lua/data/chinese_english.txt) (Chinese to English):

```

world	世界
example	例子

```

The translation filter will then display "世界" as a comment when you type "world" (or vice versa depending on the file).

## Core Implementation Files

| File | Purpose | Key Components |
|------|---------|----------------|
| [`wanxiang/wanxiang.schema.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang/wanxiang.schema.yaml) | Schema definition | Switch declarations (lines 24–32), `super_replacer` configuration (lines 124–138) |
| [`wanxiang/default.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang/default.yaml) | Default settings | `save_options` list (line 28) for persistence |
| [`wanxiang/lua/super_replacer.lua`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang/lua/super_replacer.lua) | Filter engine | Lua logic for reading TSV files and appending content |
| [`wanxiang/lua/data/emoji.txt`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang/lua/data/emoji.txt) | Emoji database | Tab-separated keyword-to-symbol mappings |
| [`wanxiang/lua/data/english_chinese.txt`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang/lua/data/english_chinese.txt) | EN→CN dictionary | Bilingual pairs for translation comments |
| [`wanxiang/lua/data/chinese_english.txt`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang/lua/data/chinese_english.txt) | CN→EN dictionary | Reverse translation pairs |

## Summary

- **Two filters available**: `emoji` for symbols and `chinese_english` for bilingual translations, both implemented via [`super_replacer.lua`](https://github.com/amzxyz/rime_wanxiang/blob/main/super_replacer.lua).
- **Schema configuration**: Define switches in [`wanxiang.schema.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang.schema.yaml) (lines 24–32) and link them to file paths in the `super_replacer` block (lines 124–138).
- **Runtime control**: Toggle via `Control+grave` menu using "表情开/关" and "翻译开/关" options.
- **Data customization**: Edit TSV files in `lua/data/` to add new emoji or translations, then reload Rime with `Ctrl+Shift+F5`.
- **Persistence**: Switch states are saved automatically via [`default.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/default.yaml) `save_options`.

## Frequently Asked Questions

### How do I permanently enable the emoji filter by default?

Set `reset: 1` instead of `reset: 0` in the switch definition within [`wanxiang.schema.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang.schema.yaml). This initializes the filter to the "on" state (表情开) when Rime starts, though users can still toggle it off via the schema menu.

### Can I use custom data files for the emoji filter?

Yes. Modify the `files` array under the `emoji` option in the `super_replacer` configuration to point to your own TSV files. Ensure the format matches `keyword<TAB>text<TAB>symbol`, and place the files in a location accessible to the Rime Lua engine (typically under the `lua/` directory).

### Why don't my new emoji appear immediately after editing the text file?

The `super_replacer` module loads data into memory when Rime initializes. You must reload the Rime engine using the menu shortcut (usually `Ctrl+Shift+F5` or `F5` depending on your frontend) to re-import the updated [`emoji.txt`](https://github.com/amzxyz/rime_wanxiang/blob/main/emoji.txt) or translation files.

### What is the difference between `mode: append` and other modes in super_replacer?

As implemented in [`wanxiang.schema.yaml`](https://github.com/amzxyz/rime_wanxiang/blob/main/wanxiang.schema.yaml), `mode: append` adds the matched content after the candidate text. The `comment_mode: none` setting ensures the addition appears as part of the candidate rather than as a separate comment field, creating the inline display effect for emoji and translations.