Skip to content

Fix cast translations#5582

Merged
balloob merged 6 commits intodevfrom
fix-cache-translations
Apr 21, 2020
Merged

Fix cast translations#5582
balloob merged 6 commits intodevfrom
fix-cache-translations

Conversation

@balloob
Copy link
Copy Markdown
Member

@balloob balloob commented Apr 21, 2020

Breaking change

Proposed change

Fix state translations for cache using two hacks:

  • We cache the current version of Home Assistant in a variable so we can check if we're using a specific version without having access to hass object
  • I made a copy of the old state translations for cast and they are merged into the translations when doing a build
  • computeStateDisplay is now falling back to old behavior if Home Assistant is using a version before 109.
  • Remove no longer used translation keys from source file

Type of change

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

Example configuration

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.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

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

stateObj: HassEntity,
language: string
): string => {
if (__BACKWARDS_COMPAT__ && !atLeastCachedVersion(0, 109)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we move this to a separate function?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  if (__BACKWARDS_COMPAT__ && !atLeastCachedVersion(0, 109)) {
	return legacyComputeStateDisplay(localize, stateObj, language);
  }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

@balloob balloob merged commit 82442bb into dev Apr 21, 2020
@balloob balloob deleted the fix-cache-translations branch April 21, 2020 22:02
@bramkragten bramkragten mentioned this pull request Apr 22, 2020
@lock lock Bot locked and limited conversation to collaborators Apr 25, 2020
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.

3 participants