architecture icon indicating copy to clipboard operation
architecture copied to clipboard

Translate or allow translation of Google Assistant commands to languages other than English

Open RobertoRanieri opened this issue 5 years ago • 5 comments

Context

There are currently many devices and domains that Home Assistant can expose to Google Assistant which are currently unusable, apart from basic turn on/off functionality, in a language other than English. In my personal experience using Home Assistant I've noticed the domains alarm_control_panel and media_player having this issue, but I doubt those to be the only ones. For instance, there is simply no Italian phrasing whatsoever (that I could find) to make Google Assistant understand the commands to change input source on my TV, or to arm my security system.

Proposal

This issue would be solved by translating said commands manually in each language. Given that such a task would require a considerable effort, it would probably be best to adopt the usage of a collaborative translation platform.

Consequences

Implementing such translations would probably require a significant amount of refactoring in the code-base in order not to rely as much on string literals and move to a more modular approach.

Other considerations

Having personally never used Alexa, I don't know if the same problem applies to that voice assistant too. If it did, I would imagine that it could be solved in a similar way.

RobertoRanieri avatar Apr 27 '20 21:04 RobertoRanieri

You actually can. I do provide both Dutch and English phrases and aliases to my devices. I prefer to use English myself and my family likes to use Dutch.

My Google assistant devices are configured for primary (Dutch) and secondary language (English).

Example from my own configuration: https://github.com/frenck/home-assistant-config/blob/master/config/assistants/google/light.office_desk.yaml

For things like actions on tv's and stuff, those are exposed as such towards Google, in those cases the language as set on your Google Assistant takes care of that. (e.g., Dutch "bron" and English "source").

frenck avatar Apr 27 '20 21:04 frenck

I think what @RobertoRanieri is referring to is that Google assistant requires the translation of attributes that are sent for traits. This issue is one example related to alarm_control_panel.

engrbm87 avatar May 19 '20 07:05 engrbm87

Here is initial work in progress to fix this: https://github.com/home-assistant/core/compare/dev...elupus:google_assistant_translations

This uses the standard state translations of HA. Currently we don't seem to translate anything else than the core state? We need translations for attributes here.

elupus avatar May 24 '20 17:05 elupus

So, there is no infrastructure in place for attribute translation as of now. Stuff like source or sound mode on a media player, stuff like speed on a fan.

Speed on a fan is at least standardized so would fit into current translation approach

Custom state translations can be done, but they are done somewhat problematic for our needs. They require a custom device class on your entity. Then you can translate that device class in your integration. So the translation is linked to the device class, not the integration.

Custom device class is a problem, since we use device class to adjust what we report to Google.

So my branch mentioned above should work for anything that is linked to state. Which seems to only be the alarm entity sadly.

To get the other stuff working we need to plumb the translation stuff for non state attributes which should fit okey, but we must handle per integration translation without relying on device class.

elupus avatar May 24 '20 20:05 elupus

State attribute translations will be provided as part of https://github.com/home-assistant/core/issues/34264#

balloob avatar May 26 '20 01:05 balloob

This architecture issue is old, stale, and possibly obsolete. Things changed a lot over the years. Additionally, we have been moving to discussions for these architectural discussions.

For that reason, I'm going to close this issue.

../Frenck

frenck avatar May 11 '23 14:05 frenck