Skip to content

feat: tag vocabulary terms with a language (#52) - #57

Merged
DavidHruby1 merged 2 commits into
mainfrom
feat/vocabulary-language-tags
Nov 4, 2026
Merged

DavidHruby1 merged 2 commits into
mainfrom
feat/vocabulary-language-tags

Conversation

@DavidHruby1

Copy link
Copy Markdown
Owner

Closes #52. Foundation for #53, #54 and #55.

Changes

  • Data model (src/config.py): VocabularyTerm(term, language=""), where "" = All languages. normalize_vocabulary_entries accepts VocabularyTerm, {"term","language"} dicts and legacy str. It validates the language with normalize_language_code, dedups by term.casefold() across the whole list (first occurrence wins) and keeps the existing limits (128 terms, 128 chars, 8,000 rendered chars).
  • Persistence: an array of {"term","language"} objects. A legacy array of strings loads as All languages and is rewritten in the new format on the next save. Damaged data is still backed up to settings-damaged.txt.
  • select_vocabulary(entries, language): Auto picks only All-languages terms. Any other language picks that language's terms first, then All-languages terms, each group in list order. Languages match on the primary subtag (pt-br ↔ pt).
  • STT + rewrite: both use the same pick for config.stt_language from the session snapshot.
  • UI: the Vocabulary tab is now a QTableWidget with an editable Term column and a Language column (a QComboBox per row). The new-term combo lists All languages, built-in and common languages, favorites, and a saved code missing from those. Add / Update selected / Remove still work as before, with validation through QMessageBox.
  • Docs: docs/IMPLEMENTATION.md.

Open question from the issue

"Allow the same term for several languages?" This PR keeps one label per term: a duplicate added under another language is merged, and the first one wins.

Tests

  • New tests/test_vocabulary_languages.py: selection, migration, roundtrip, validation, request prompts and the settings dialog.
  • Updated test_roadmap_backends, test_roadmap_settings and test_profiles for the new type.
  • python -m unittest discover -s tests: 476 OK (5 skipped), and ruff check is clean.
  • Not verified on Windows; the UI is tested offscreen only.

🤖 Generated with Claude Code

- config: VocabularyTerm(term, language); normalize accepts terms, dicts and legacy
  strings, dedups by term across languages; select_vocabulary() picks the dictation's
  language terms then All-languages terms (primary subtag match)
- persistence: JSON array of {"term", "language"} objects; legacy string lists load as
  All languages and are rewritten on the next save
- stt/rewrite: both use the same select_vocabulary() pick for stt_language
- settings: Vocabulary tab is a Term | Language table with a per-row language combo
- docs and tests

Closes #52

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Term cells are editable, so blank, duplicate or untrimmed rows could stay
visible while the save dropped or normalized them. Repopulate the table from
the normalized list when it differs.

Co-Authored-By: Claude <noreply@anthropic.com>
@DavidHruby1
DavidHruby1 merged commit c311575 into main Nov 4, 2026
9 checks passed
DavidHruby1 added a commit that referenced this pull request Nov 4, 2026
DavidHruby1 added a commit that referenced this pull request Nov 4, 2026
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.

Slovník: termíny se štítkem jazyka (4.1)

1 participant