add language menu item to tui configuration
This commit is contained in:
@@ -37,6 +37,7 @@ type ConfigSection string
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
SectionProviders ConfigSection = "providers"
|
SectionProviders ConfigSection = "providers"
|
||||||
|
SectionLanguage ConfigSection = "language"
|
||||||
SectionTranscription ConfigSection = "transcription"
|
SectionTranscription ConfigSection = "transcription"
|
||||||
SectionLLM ConfigSection = "llm"
|
SectionLLM ConfigSection = "llm"
|
||||||
SectionKeywords ConfigSection = "keywords"
|
SectionKeywords ConfigSection = "keywords"
|
||||||
@@ -110,6 +111,11 @@ func runEditExisting(cfg *config.Config) (*ConfigureResult, error) {
|
|||||||
}
|
}
|
||||||
configuredProviders = getConfiguredProviders(cfg)
|
configuredProviders = getConfiguredProviders(cfg)
|
||||||
|
|
||||||
|
case SectionLanguage:
|
||||||
|
if err := editLanguage(cfg); err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
case SectionTranscription:
|
case SectionTranscription:
|
||||||
var err error
|
var err error
|
||||||
configuredProviders, err = editTranscription(cfg, configuredProviders)
|
configuredProviders, err = editTranscription(cfg, configuredProviders)
|
||||||
@@ -154,6 +160,7 @@ func runEditExisting(cfg *config.Config) (*ConfigureResult, error) {
|
|||||||
func selectSection(cfg *config.Config) (ConfigSection, error) {
|
func selectSection(cfg *config.Config) (ConfigSection, error) {
|
||||||
options := []huh.Option[ConfigSection]{
|
options := []huh.Option[ConfigSection]{
|
||||||
huh.NewOption(formatProvidersLabel(cfg), SectionProviders),
|
huh.NewOption(formatProvidersLabel(cfg), SectionProviders),
|
||||||
|
huh.NewOption(formatLanguageMenuLabel(cfg), SectionLanguage),
|
||||||
huh.NewOption(formatTranscriptionLabel(cfg), SectionTranscription),
|
huh.NewOption(formatTranscriptionLabel(cfg), SectionTranscription),
|
||||||
huh.NewOption(formatLLMLabel(cfg), SectionLLM),
|
huh.NewOption(formatLLMLabel(cfg), SectionLLM),
|
||||||
huh.NewOption(formatKeywordsLabel(cfg), SectionKeywords),
|
huh.NewOption(formatKeywordsLabel(cfg), SectionKeywords),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/charmbracelet/huh"
|
"github.com/charmbracelet/huh"
|
||||||
"github.com/leonardotrapani/hyprvoice/internal/config"
|
"github.com/leonardotrapani/hyprvoice/internal/config"
|
||||||
|
"github.com/leonardotrapani/hyprvoice/internal/language"
|
||||||
)
|
)
|
||||||
|
|
||||||
// formatProvidersLabel formats the providers menu option
|
// formatProvidersLabel formats the providers menu option
|
||||||
@@ -13,6 +14,16 @@ func formatProvidersLabel(cfg *config.Config) string {
|
|||||||
return "Providers"
|
return "Providers"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// formatLanguageMenuLabel formats the language menu option showing current setting
|
||||||
|
func formatLanguageMenuLabel(cfg *config.Config) string {
|
||||||
|
langCode := cfg.General.Language
|
||||||
|
if langCode == "" {
|
||||||
|
return "Language (Auto-detect)"
|
||||||
|
}
|
||||||
|
lang := language.FromCode(langCode)
|
||||||
|
return fmt.Sprintf("Language (%s)", lang.Name)
|
||||||
|
}
|
||||||
|
|
||||||
// formatTranscriptionLabel formats the transcription menu option
|
// formatTranscriptionLabel formats the transcription menu option
|
||||||
func formatTranscriptionLabel(cfg *config.Config) string {
|
func formatTranscriptionLabel(cfg *config.Config) string {
|
||||||
return "Transcription"
|
return "Transcription"
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package tui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/leonardotrapani/hyprvoice/internal/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
// editLanguage allows the user to select the global transcription language
|
||||||
|
func editLanguage(cfg *config.Config) error {
|
||||||
|
// implementation in task 5
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -527,4 +527,13 @@ Started: Sun Feb 1 12:22:47 AM CET 2026
|
|||||||
- Added `language = ""` with comment about ISO 639-1 codes and auto-detect
|
- Added `language = ""` with comment about ISO 639-1 codes and auto-detect
|
||||||
- Removed `language = ""` from `[transcription]` section
|
- Removed `language = ""` from `[transcription]` section
|
||||||
- Added commented `# language = ""` in transcription section with note about override
|
- Added commented `# language = ""` in transcription section with note about override
|
||||||
|
- All tests passing, typecheck passes
|
||||||
|
|
||||||
|
### Task 4: Add SectionLanguage to TUI configure menu
|
||||||
|
- Added `SectionLanguage ConfigSection = "language"` constant in configure.go
|
||||||
|
- Added Language option to selectSection() options list after Providers
|
||||||
|
- Created `formatLanguageMenuLabel(cfg)` helper in configure_helpers.go (renamed from formatLanguageLabel to avoid collision with languages.go)
|
||||||
|
- Shows "Language (Auto-detect)" when empty, "Language ({name})" when set
|
||||||
|
- Added case SectionLanguage in runEditExisting switch calling editLanguage()
|
||||||
|
- Created stub configure_language.go with editLanguage() function (implementation in Task 5)
|
||||||
- All tests passing, typecheck passes
|
- All tests passing, typecheck passes
|
||||||
+1
-1
@@ -62,7 +62,7 @@
|
|||||||
"Selecting Language enters language edit flow",
|
"Selecting Language enters language edit flow",
|
||||||
"Typecheck passes"
|
"Typecheck passes"
|
||||||
],
|
],
|
||||||
"passes": false
|
"passes": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Create editLanguage function in TUI",
|
"title": "Create editLanguage function in TUI",
|
||||||
|
|||||||
Reference in New Issue
Block a user