Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entity translation support #178

Merged
merged 4 commits into from
Sep 3, 2023
Merged

Conversation

piitaya
Copy link
Contributor

@piitaya piitaya commented Aug 24, 2023

This PR add translation support to any entity following Home Assistant documentation.

Translations

strings.json has been deleted because it's not needed for custom components. Only en.json is useful.
Translation keys has been added to any entities.

I also added french translations as it's my native language.

Entity options

options has been added to current stage, speed profile and printing speed to add autocompletion in automation editor and translations.

Lowercasing string value

Unknown has been changed to unknown so it can be translated too.
Speed value has be converted to lowercase to support translations too.

Device class for online entity

Online entity has been changed to running instead of power because power is for electricity power detection not device power on.

Feel free to give any feedback if you find something strange or wrong.

@piitaya piitaya marked this pull request as ready for review August 24, 2023 16:28
@greghesp
Copy link
Owner

greghesp commented Sep 3, 2023

@AdrianGarside Looks good to me, however there are quite a few changes to get the translation in and didn't want this to impact you might have been working on. You OK to review and merge if happy?

Copy link
Collaborator

@AdrianGarside AdrianGarside left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we need to do as/when we add new translatable strings - do we need to duplicate them (untranslated / online translated) into the fr.json file or is it ok to just add them to the en.json file and it'll automatically use them until someone (like yourself) adds the missing translations?

name="Cooling Fan",
value_fn=lambda device: device.fans.cooling_fan_speed
translation_key="cooling_fan",
value_fn=lambda device: device.fans.cooling_fan_speed,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, but am not sure, that this extra comma will cause problems? But maybe not if this is running fine for you as-is. But it is inconsistent with the other code in this file.

@AdrianGarside AdrianGarside merged commit 03101ac into greghesp:main Sep 3, 2023
2 checks 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.

None yet

3 participants