Skip to content

Internationalization Polish#2002

Merged
ksylvan merged 2 commits intodanielmiessler:mainfrom
ksylvan:kayvan/i18n-polish
Feb 14, 2026
Merged

Internationalization Polish#2002
ksylvan merged 2 commits intodanielmiessler:mainfrom
ksylvan:kayvan/i18n-polish

Conversation

@ksylvan
Copy link
Collaborator

@ksylvan ksylvan commented Feb 14, 2026

Internationalization Polish

Note: This PR code was generated using Maestro and the i18n Cleanup playbook in my maestro-playbooks-custom repo.

Summary

This PR introduces comprehensive internationalization (i18n) support across multiple modules of the Fabric project by replacing hardcoded English string literals with localized message keys via i18n.T() calls. The changes span four major subsystems: the Ollama server, the OpenAI client, the LM Studio client, the extension system, and the Spotify integration. Corresponding translation strings have been added to all 10 supported locale files.

Files Changed

Locale Files (10 files)

File Change
internal/i18n/locales/en.json Added ~117 new translation keys
internal/i18n/locales/de.json Added German translations
internal/i18n/locales/es.json Added Spanish translations
internal/i18n/locales/fa.json Added Persian/Farsi translations
internal/i18n/locales/fr.json Added French translations
internal/i18n/locales/it.json Added Italian translations
internal/i18n/locales/ja.json Added Japanese translations
internal/i18n/locales/pt-BR.json Added Brazilian Portuguese translations
internal/i18n/locales/pt-PT.json Added European Portuguese translations
internal/i18n/locales/zh.json Added Chinese translations

Each locale file received the same set of ~117 new keys covering five domains:

  • openai_* — Image generation model compatibility warnings
  • ollama_*num_ctx validation, request/response errors, SSE streaming errors, address validation
  • extension_* — Registry management, execution, validation, hash verification
  • lmstudio_* — Request lifecycle errors, response parsing
  • spotify_* — Token management, API requests, metadata parsing

Go Source Files (6 files)

File Change
internal/server/ollama.go Replaced ~40 hardcoded error/log strings with i18n.T() calls
internal/plugins/ai/openai/openai.go Replaced 2 image generation warning/error strings
internal/plugins/ai/lmstudio/lmstudio.go Replaced ~25 error strings across all client methods
internal/plugins/template/extension_executor.go Replaced ~12 error/log strings
internal/plugins/template/extension_manager.go Replaced ~20 error/log strings
internal/plugins/template/extension_registry.go Replaced ~30 error/log strings
internal/tools/spotify/spotify.go Replaced ~15 error strings

Code Changes

Pattern: Direct format string replacement

Most changes follow this pattern where a hardcoded fmt.Errorf format string is replaced with an i18n.T() lookup:

// Before
return nil, fmt.Errorf("failed to create request: %w", err)

// After
return nil, fmt.Errorf(i18n.T("lmstudio_failed_create_request"), err)

Pattern: Static error messages (no format verbs)

For error messages without format parameters, the %s wrapper pattern is used to avoid go vet complaints about non-constant format strings:

// Before
return "", fmt.Errorf("empty command after formatting")

// After
return "", fmt.Errorf("%s", i18n.T("extension_empty_command"))

Pattern: Composed format strings

Some messages require an intermediate fmt.Sprintf before being passed tofmt.Errorf:

// Before
return "", fmt.Errorf("operation %s not found for extension %s", operation, ext.Name)

// After
return "", fmt.Errorf("%s", fmt.Sprintf(i18n.T("extension_operation_not_found"), operation, ext.Name))

OpenAI image generation warning

// Before
fmt.Fprintf(os.Stderr, "Warning: Model '%s' does not support image generation. ...")

// After
fmt.Fprintf(os.Stderr, "%s", fmt.Sprintf(i18n.T("openai_warning_model_no_image_generation"),
    model, strings.Join(ImageGenerationSupportedModels, ", ")))

Reason for Changes

Previously, all user-facing error messages, log output, and CLI feedback were hardcoded in English. This made the application inaccessible to non-English-speaking users. This PR extends the existing i18n framework (already in use for other parts of the codebase) to cover five additional subsystems:

  1. Ollama server — Validates num_ctx, handles upstream communication, and manages SSE streaming
  2. OpenAI client — Image generation model compatibility checks
  3. LM Studio client — Full request/response lifecycle
  4. Extension system — Registration, verification, execution, and management
  5. Spotify integration — Authentication, API requests, and metadata parsing

Impact of Changes

  • User Experience: All error messages and warnings in the affected subsystems are now displayed in the user's configured locale
  • Maintainability: New translation keys follow a consistent naming convention (module_action_detail), making them easy to discover and maintain
  • No functional changes: The underlying logic remains identical — onlythe string sourcing has changed
  • 10 languages supported: English, German, Spanish, French, Italian, Japanese, Chinese, Persian, Brazilian Portuguese, and European Portuguese

Test Plan

  1. Existing tests should pass unchanged — Since only string sourcing changed (not logic), all existing unit and integration tests for ollama.go, lmstudio.go, openai.go, the extension system, and spotify.go shouldcontinue to pass
  2. Verify locale loading — Confirm that setting FABRIC_LANG=de (or any supported locale) produces German error messages in the affected subsystems
  3. Verify format string correctness — Ensure all %d, %s, %v, %w placeholders in translation values match the arguments passed in Go code
  4. Edge case testing — Test with an unsupported locale to verify graceful fallback to English
  5. Run go vet — Confirm no printf format string warnings from the new fmt.Errorf("%s", i18n.T(...)) patterns

Additional Notes

  • Potential bug: Format string mismatches — The correctness of this PRdepends entirely on each translation value having the exact same format verbs (in the same order) as the original English string. Any mismatch (e.g.,%d vs %s, or a missing %w) would cause runtime panics or incorrect error wrapping. This should be validated with automated tooling or careful review of each locale file.
  • Inconsistent fmt.Errorf patterns — Some messages use fmt.Errorf(i18n.T("key"), args...) directly (when the translation contains %w), while others use fmt.Errorf("%s", fmt.Sprintf(i18n.T("key"), args...)). The latter pattern loses Go's error wrapping semantics when the translation contains %w. This inconsistency should be reviewed to ensure error wrapping (errors.Is / errors.As) works as expected.
  • Translation quality — Machine-translated strings should ideally be reviewed by native speakers to ensure technical accuracy, especially for languages like Japanese and Persian where technical terminology conventions may differ.

…tify modules

- Add i18n translation keys for Ollama `num_ctx` validation error messages
- Add i18n strings for Ollama server chat endpoint and SSE streaming errors
- Add i18n strings for extension registry, executor, and manager operations
- Add i18n strings for LM Studio client error messages and response handling
- Add i18n strings for Spotify API client error messages
- Add OpenAI image generation model compatibility warning translations
- Replace hardcoded English strings with `i18n.T()` calls across all modules
- Add translations for all new keys in de, en, es, fa, fr, it, ja, pt-BR, pt-PT, and zh locales
@ksylvan ksylvan merged commit 4626fd6 into danielmiessler:main Feb 14, 2026
1 check passed
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