Skip to content

feat: add hiragana furigana option#90

Open
kongjianguan wants to merge 3 commits into
chenmozhijin:devfrom
kongjianguan:feat/kana-ruby
Open

feat: add hiragana furigana option#90
kongjianguan wants to merge 3 commits into
chenmozhijin:devfrom
kongjianguan:feat/kana-ruby

Conversation

@kongjianguan

@kongjianguan kongjianguan commented May 22, 2026

Copy link
Copy Markdown

概述

新增"平假名"复选框,将罗马字文本行转换为无空格的平假名。该复选框仅在"罗马音"勾选时才可启用。

改动内容

  • 新增 LDDC/core/romaji.py — 纯 Python 罗马字→平假名转换器,包含完整音节表,采用最长前缀匹配策略。无法映射的 token(英文、数字等)原样保留。
  • UI — 在搜索、打开歌词、本地匹配、导出和桌面歌词选择视图中,于罗马音复选框旁添加了 kana_checkBox
  • 逻辑 — 启用平假名时,以下场景中罗马字文本会转换为无空格平假名:
    • 桌面歌词显示(service.py
    • 搜索预览和保存到标签(converter/__init__.py
    • 歌词导出(LRC/SRT/ASS 文件)
  • 配置 — 新增 cfg["kana"] 布尔值(默认 false
  • 测试 — 73 项单元测试覆盖基本音节、浊音、拗音、促音、撇号促音('t)、混合文本和边界情况。

视觉效果

状态 显示
罗马音 ON, 平假名 OFF ko re wa ha na ga sa ku(带空格的罗马字)
罗马音 ON, 平假名 ON これははながさく(无空格平假名)
罗马音 OFF 平假名复选框禁用

测试计划

  1. 搜索日语歌曲 → 双击结果 → 切换罗马音 → 切换平假名
  2. 验证罗马音未勾选时平假名复选框为禁用状态
  3. 启用平假名导出歌词 → 验证输出为平假名而非罗马字
  4. 运行 pytest tests/test_romaji.py -v — 73/73 通过

kongjianguan added 2 commits May 22, 2026 11:22
Add a "平假名" checkbox that converts romaji text to hiragana
(no spaces) when enabled. The checkbox is conditionally enabled
only when the "罗马音" checkbox is checked.

- LDDC/core/romaji.py: new romaji→hiragana converter (pure Python)
- tests/test_romaji.py: 73 unit tests covering all conversion patterns
- 5 view UIs: add kana_checkBox next to romanized_checkBox
- 5 view controllers: wire conditional enable + cfg["kana"] toggle
- gui/service.py: convert roma line to kana during desktop lyrics render
- core/converter/__init__.py: convert before export/save-to-tag/preview
- config.py: add "kana": False default config entry
The romaji→kana conversion block in convert2() creates
FSLyricsData/FSLyricsLine/FSLyricsWord instances but these
were not imported, causing a silent NameError that left the
lyrics preview stuck on "处理中...".
@codacy-production

codacy-production Bot commented May 22, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 23 complexity · 4 duplication

Metric Results
Complexity 23
Duplication 4

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

- converter/__init__.py: remove duplicate cfg import, sort imports
- romaji.py: add missing blank line after "Returns" docstring section
@kongjianguan

Copy link
Copy Markdown
Author

本地测试功能,没发现问题

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.

1 participant