Skip to content

Conversation

@rosch100
Copy link

@rosch100 rosch100 commented Dec 1, 2025

Add Multilingual README Support

Summary

This PR adds support for multilingual README files in HACS. Users will automatically see content in their Home Assistant language setting if available, with fallback to default English content.

Changes

  1. Multilingual README Support

    • Added async_get_info_file_contents_with_language() method
    • Supports README.{language_code}.md files (e.g., README.de.md, README.fr.md)
    • Automatic language detection with fallback to README.md
  2. Manifest Updates

    • Renamed supported_languages to content_languages in hacs.json manifest
    • Updated validator to use content_languages key
    • Validates language codes and checks for corresponding README files
  3. WebSocket Handler Updates

    • Extended hacs/repository/info to use language parameter for README content

Related PRs

Checklist

  • Code follows project style guidelines
  • Changes are backward compatible
  • Code tested locally
  • Validators updated
  • WebSocket handlers updated

Notes

  • Repository maintainers can provide multilingual README files using README.{language_code}.md (e.g., README.de.md, README.fr.md)
  • Language codes must be 2-letter ISO 639-1 codes (e.g., de, fr, es)
  • The content_languages key in hacs.json can optionally declare supported languages for validation

- Add optional language parameter to hacs/repository/info websocket command
- Implement async_get_info_file_contents_with_language method
- Support language-specific README files (README.{language}.md)
- Fallback to README.md if language-specific version not found
- Validate language codes (2-letter ISO 639-1)
- Fully backward compatible
@hacs-bot hacs-bot bot marked this pull request as draft December 1, 2025 20:34
- Add supported_languages field to HacsManifest class
- Add _supported_languages_validator to validate ISO 639-1 language codes
- Add supported_languages to HACS_MANIFEST_JSON_SCHEMA
- Add validation in hacsjson.py to check if declared README files exist
- Add runtime check in async_get_info_file_contents_with_language to only use declared languages
- Fixes review comments from ludeeus
@rosch100 rosch100 force-pushed the feature/multilingual-readme branch from 4f826be to 33e8da3 Compare December 1, 2025 20:40
@rosch100
Copy link
Author

rosch100 commented Dec 1, 2025

All requested changes have been implemented:

supported_languages field added to hacs.json schema

  • Added supported_languages: list[str] = [] to HacsManifest class
  • Added _supported_languages_validator to validate ISO 639-1 language codes (2-letter codes)
  • Added supported_languages to HACS_MANIFEST_JSON_SCHEMA

Validation on repository registration and HACS action

  • Added validation in hacsjson.py to check if README files exist for all declared languages
  • Validates that README.{lang}.md files exist for each language in supported_languages
  • Runtime validation in async_get_info_file_contents_with_language to only use declared languages

Formatting issues fixed

  • Reset validate.py to main branch and only added the necessary _supported_languages_validator function
  • Only relevant changes in base.py and hacsjson.py (no unnecessary formatting changes)

All changes have been committed and pushed. Ready for review.

@rosch100
Copy link
Author

rosch100 commented Dec 1, 2025

Hi @hacs/maintainers, could you please add the pr: enhancement label to this PR? This is a new feature implementation for multilingual README support. Thank you!

rosch100 added 2 commits December 2, 2025 11:53
- Extract base language code from BCP47 format (e.g., 'de-DE' -> 'de')
- Keep supported_languages runtime check as per ludeeus requirement
- All language processing logic now in backend
- Fix case combination mismatch: validator now checks same 6 combinations as runtime
- Add language code format validation in validator (2-letter alphabetic)
- Fix filename vs full_path inconsistency: use full_path consistently
- Normalize supported_languages to lowercase when loading from manifest
- Remove unnecessary comments
@rosch100
Copy link
Author

rosch100 commented Dec 2, 2025

Hi @ludeeus,

All requested changes have been implemented and pushed. The code is ready for re-review.

rosch100 added 2 commits December 2, 2025 13:32
- Add _supported_languages_validator to validate language codes
- Add supported_languages to HACS_MANIFEST_JSON_SCHEMA as optional field
- Validator handles None values and normalizes to lowercase
- Remove unnecessary comment in websocket handler
- Add language code validation for string values in validator
- Fix filename vs full_path inconsistency in hacsjson validator
- Use filename instead of full_path for README file matching (consistent with information.py)
rosch100 added 3 commits December 2, 2025 14:50
…o content_languages

- Add async_get_description_with_language() method to support multilingual descriptions
- Extend WebSocket handlers to use language parameter for descriptions
- Rename supported_languages to content_languages in manifest and validators
- Update validation to check content_languages for both README and description files
- Support DESCRIPTION.{language_code}.txt files with automatic language detection
- Remove async_get_description_with_language() method
- Remove language parameter from hacs/repositories/list WebSocket command
- Remove description language handling from hacs/repository/info
- Update PR description to reflect README-only support
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.

2 participants