Skip to content

Add French (fr) translation and make entity names/states translatable#3

Open
ADNPolymerase wants to merge 6 commits into
SmartServicePL:mainfrom
ADNPolymerase:i18n
Open

Add French (fr) translation and make entity names/states translatable#3
ADNPolymerase wants to merge 6 commits into
SmartServicePL:mainfrom
ADNPolymerase:i18n

Conversation

@ADNPolymerase

@ADNPolymerase ADNPolymerase commented Jun 27, 2026

Copy link
Copy Markdown

Summary

Adds a complete French (fr) translation and routes everything through Home Assistant's native i18n, so en, pl and fr all work. Several strings were previously hard-coded Polish in the Python code, bypassing the translation files — those are fixed here too.

This PR is self-contained (it also adds translations/fr.json).

What changed

1. French translation

  • New translations/fr.json mirroring en.json / pl.json (identical key structure).

2. Entity names that ignored translations

Three entities used a hard-coded Polish _attr_name, which overrides translation_key:

Entity Was Now
Calendar _attr_name = "Harmonogram koszenia" _attr_translation_key = "schedule"
RTK map camera _attr_name = "Mapa RTK" _attr_translation_key = "rtk_map_camera"
RTK position tracker _attr_name = "Pozycja RTK" _attr_translation_key = "rtk_position"

Added the missing device_tracker.rtk_position name to en/pl/fr.

3. Sensor states that were hard-coded Polish

status, error and mowing_readiness mapped raw Worx descriptions to Polish strings via in-code dicts (STATUS_LABELS_PL / READINESS_LABELS_PL). These are now enum sensors (SensorDeviceClass.ENUM) emitting canonical keys (home, mowing, going_home, …), with labels moved to translations/*.json under each sensor's state. The exact previous Polish wording is preserved in pl.json.

Also enum-ified cloud_connection (ok/check/offline) and maintenance_status (ok/blade_service_due/battery_service_due), which previously emitted raw English keys with no localization.

4. Free-text schedule summary

The schedule sensor builds a free-form string ("brak aktywnych slotow", "+ krawedz", Polish day abbreviations). HA cannot translate arbitrary state text, so the hard-coded Polish was replaced with neutral English. Structured data remains available via the sensor's attributes and the calendar entity for localized dashboards.

⚠️ Behavior change (please read)

  • Sensor state values change from localized text to canonical keys (e.g. koszeniemowing, displayed via translations). Automations/templates that compared the raw Polish text must compare the canonical key instead. This is the standard HA enum approach required for multi-language support.
  • Unmapped/rare error descriptions now yield an empty enum state; the original text is still exposed via the sensor's raw_description attribute.

Validation

  • en.json / pl.json / fr.json have identical key structure (221 keys each), valid JSON.
  • python -m py_compile passes on all modified modules.
  • No remaining hard-coded Polish display strings in the Python code.

- Replace hardcoded Polish _attr_name with translation_key on the
  calendar, RTK map camera and RTK position device_tracker entities
- Add the missing device_tracker translation section (en/pl/fr)
- Convert status, error, mowing_readiness, cloud_connection and
  maintenance_status to enum sensors that emit canonical state keys,
  with localized labels in translations/*.json (Polish wording preserved)
- Replace remaining hardcoded Polish in the free-text schedule summary
  and day labels with neutral English (HA cannot translate free text)
@ADNPolymerase ADNPolymerase changed the title Make entity names and sensor states translatable (i18n) Add French (fr) translation and make entity names/states translatable Jun 27, 2026
- Rename the select to a shorter 'Mowing zone' / 'Zone de tonte' / 'Mähzone'
- Localize the dynamically built zone option labels (all zones / Zone N /
  Zones N, M) from the HA UI language instead of hard-coded Polish;
  Polish wording preserved, unknown languages fall back to English
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