Skip to content

Commit

Permalink
Update config_flow.py to work better with translations
Browse files Browse the repository at this point in the history
Removed device_count and scanner_count strings. The variables from these strings have been split into separate keys: device_counter_active, device_counter_devices, scanner_counter_active, scanner_counter_scanners. These keys only contain the numerical values ​​and are applied as such in the translation file.

I also tried to move the status messages to the translation file, but I haven't succeeded yet. The preparations for this are already in the .json translation files.
  • Loading branch information
createthisnl authored Nov 27, 2024
1 parent f392caa commit 928f721
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions custom_components/bermuda/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ async def async_step_init(self, user_input=None): # pylint: disable=unused-argu
active_devices = self.coordinator.count_active_devices()
active_scanners = self.coordinator.count_active_scanners()

messages["device_count"] = f"{active_devices} active out of {len(self.devices)}"
messages["scanner_count"] = f"{active_scanners} active out of {len(self.coordinator.scanner_list)}"
messages["device_counter_active"] = f"{active_devices}"
messages["device_counter_devices"] = f"{len(self.devices)}"
messages["scanner_counter_active"] = f"{active_scanners}"
messages["scanner_counter_scanners"] = f"{len(self.coordinator.scanner_list)}"

if len(self.coordinator.scanner_list) == 0:
messages["status"] = (
"You need to configure some bluetooth scanners before Bermuda will have anything to work with. "
Expand All @@ -159,7 +162,7 @@ async def async_step_init(self, user_input=None): # pylint: disable=unused-argu
messages["status"] = "You have at least some active devices, this is good."

# Build a markdown table of scanners so the user can see what's up.
scanner_table = "\nStatus of scanners:\n\n|Scanner|Address|Last advertisement|\n|---|---|---:|\n"
scanner_table = "\n\nStatus of scanners:\n\n|Scanner|Address|Last advertisement|\n|---|---|---:|\n"
# Use emoji to indicate if age is "good"
for scanner in self.coordinator.get_active_scanner_summary():
age = int(scanner.get("last_stamp_age", 999))
Expand Down

0 comments on commit 928f721

Please sign in to comment.