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

Capitalize a bunch of translations #95421

Merged
merged 2 commits into from Jun 28, 2023
Merged

Capitalize a bunch of translations #95421

merged 2 commits into from Jun 28, 2023

Conversation

balloob
Copy link
Member

@balloob balloob commented Jun 28, 2023

Breaking change

Proposed change

Capitalize a bunch of translations that didn't start with capital letter.

Found with

diff --git a/script/hassfest/translations.py b/script/hassfest/translations.py
index 9efe01cf96..002c948b41 100644
--- a/script/hassfest/translations.py
+++ b/script/hassfest/translations.py
@@ -126,6 +126,14 @@ def translation_value_validator(value: Any) -> str:
     value = cv.string_with_no_html(value)
     if RE_COMBINED_REFERENCE.search(value):
         raise vol.Invalid("the string should not contain combined translations")
+
+    if (
+        value[0] not in ("[", "{", '"', '!', '`')
+        and not value[0].isupper()
+        and not value[0].isdigit()
+    ):
+        raise vol.Invalid("String needs to start with uppercase")
+
     return str(value)
 
 

Not adding that change to hassfest as there are a few false positives.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@balloob balloob added this to the 2023.7.0b0 milestone Jun 28, 2023
@balloob balloob requested a review from a team as a code owner June 28, 2023 02:25
@home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (update) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of update can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign update Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@balloob balloob changed the title Capitalize entity name for update entity firmware device class Capitalize a bunch of translations Jun 28, 2023
@@ -302,7 +302,7 @@
}
},
"device_class": {
Copy link
Member Author

Choose a reason for hiding this comment

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

I think that all these need to be capitalized but I am not 100% sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Binary sensor is also the only one using this.

Copy link
Member

Choose a reason for hiding this comment

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

If we change these the documentation will need to clarify the difference between GUI and YAML configuration.

https://www.home-assistant.io/integrations/binary_sensor/#device-class

Copy link
Member

@frenck frenck Jun 28, 2023

Choose a reason for hiding this comment

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

I think that all these need to be capitalized but I am not 100% sure.

They should not I think? They are used by the frontend rendering the logbook, and are used mid-sentence. All other use cases have been removed and replaced by the entity attribute translations.

IMHO, this whole list should be refactored out and removed.

Copy link
Member

Choose a reason for hiding this comment

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

I added some auto casing logic into the frontend for binary sensor device classes in the logbook just a day or so ago. So that when a "heat" device class sensor switches on, it says "Detected heat" with a lower case "h" in EN, but keeps it capitalized for example in German.

Copy link
Member

Choose a reason for hiding this comment

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

@spacegaier right, so it could use the translations provided by the entity component instead?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, those are now already used by the frontend for the binary sensors in the logbook as of two days ago (there might be other places, where we still need to add the auto casing as well):

https://github.com/home-assistant/frontend/blob/4d4bd3e912bd55531ae7186dc6c2c974208ddf60/src/data/logbook.ts#L365

Copy link
Member

Choose a reason for hiding this comment

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

Nice ok, let's keep this out of scope for this PR in that case 👍

@frenck frenck merged commit 149ac4f into dev Jun 28, 2023
51 checks passed
@frenck frenck deleted the update-firmware-translation branch June 28, 2023 09:08
@github-actions github-actions bot locked and limited conversation to collaborators Jun 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants